Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cml-runner self-hosted issues #721

Open
1 of 7 tasks
casperdcl opened this issue Sep 20, 2021 · 7 comments
Open
1 of 7 tasks

cml-runner self-hosted issues #721

casperdcl opened this issue Sep 20, 2021 · 7 comments
Labels
cml-runner Subcommand epic Collection of sub-issues p2-nice-to-have Low priority technical-debt Refactoring, linting & tidying

Comments

@casperdcl
Copy link
Contributor

casperdcl commented Sep 20, 2021

@casperdcl casperdcl added cml-runner Subcommand epic Collection of sub-issues labels Sep 20, 2021
@0x2b3bfa0
Copy link
Member

0x2b3bfa0 commented Sep 21, 2021

Variables stored in the GitHub Actions self–hosted runner .env file will update the existing ones, and not replace them, as you can see in actions/runner@f259e57 → src/Runner.Listener/Program.cs:152.

We can use env(1) or the env option on Node JS' child_process functions to reset the environment and avoid the propagation of variables other than the ones in that file.

The same goes for GitLab and the environment configuration, and chances are Bitbucket Pipelines self–hosted runners will behave similarly.

Shell

env --ignore-environment ./run.sh

Node JS

It would suffice to filter out the environment on utils.js so it doesn't propagate to the child process.

{ ...process.env },

cml/src/drivers/github.js

Lines 227 to 237 in 2e9a21d

await exec(
`${resolve(
workdir,
'config.sh'
)} --unattended --token "${await this.runnerToken()}" --url "${
this.repo
}" --name "${name}" --labels "${labels}" --work "${resolve(
workdir,
'_work'
)}"`
);

@DavidGOrtega
Copy link
Contributor

feature request: local secrets (cml runner --env flag similar to docker run --env)

Why do we exactly want this feature @casperdcl ?

@casperdcl
Copy link
Contributor Author

just realised this is also a problem on all runners (not just manual self-hosted)

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: iterative/setup-cml@v1
    - uses: actions/checkout@v2
    - run: |
        cml runner --labels=cml-runner --cloud=aws --cloud-type=t2.micro
      env:
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        REPO_TOKEN: ${{ secrets.CML_CI_TOKEN }}
  train:
    runs-on: [self-hosted, cml-runner]
    steps:
    - run: env # why does this list AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY ??

should really either

  • whitelist-only vanilla CI vars (GITHUB_ENV etc) or
  • at least blacklist CML config vars (AWS_*ACCESS_KEY etc)

@dacbd
Copy link
Contributor

dacbd commented Nov 4, 2021

What do you mean @casperdcl ? These envs are set by the TPI with the via cml.sh which runs exec on cml runner and starts the GitHub runner with spawn. The default for child_process.spawn is to inherit process.env

return spawn(resolve(workdir, 'run.sh'), {

Maybe you want to override that by adding env: {} into the options from the above?

@dacbd
Copy link
Contributor

dacbd commented Nov 4, 2021

I miss read that, I suspect the above is how they are populated.

I agree they probably shouldn't be there and the user should re-authenticate if they need them so there isn't any accidental use of creds that are meant for cml to create/run/destroy instances.

@DavidGOrtega
Copy link
Contributor

DavidGOrtega commented Nov 4, 2021

There is not a lot of work to do here.
As we discussed the GH runner has the "ability" to propagate its ENV vars.
Here GH runner inherits the CML wrapper vars.
What we should do to fix this and not allow the GH runner to behave this way is simply pass an empty ENV vars in the exec. This way the ENV vars that will always access the runner will be the CI vars and workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cml-runner Subcommand epic Collection of sub-issues p2-nice-to-have Low priority technical-debt Refactoring, linting & tidying
Projects
None yet
Development

No branches or pull requests

4 participants