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

Repo hooks are executed outside k8s job #31

Open
keith opened this issue Jun 4, 2021 · 4 comments
Open

Repo hooks are executed outside k8s job #31

keith opened this issue Jun 4, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@keith
Copy link
Collaborator

keith commented Jun 4, 2021

When using buildkite's repo hooks as described here https://buildkite.com/docs/agent/v3/hooks#available-hooks if you have a post-checkout or pre-command hook, they are run outside of the k8s job that actually ends up running your code. This fails in a few ways for us since we use those to do some setup that depends on tools that are in our custom docker image, and to export environment variables we expect to exist later.

I believe this is because the core command is not run by buildkite-agent but instead is run directly

command: ['/bin/sh', '-c'],
args: [env.BUILDKITE_COMMAND],

I'm sure there was a good reason but I wonder if we could somehow run this with the buildkite-agent bootstrap command, which I assume would fix the issue?

args: ['bootstrap', '--experiment=git-mirrors', '--git-mirrors-path=/git-mirrors', '--ssh-keyscan', '--command', 'true'],

@keith keith added the enhancement New feature or request label Jun 4, 2021
@keith
Copy link
Collaborator Author

keith commented Jun 4, 2021

Note that buildkite-agent bootstrap supports --phases to do potentially less work. This could mean, depending on the background of that container being separate, we could change that command to run less and also run the second command through buildkite-agent

@iffyio
Copy link
Contributor

iffyio commented Jun 10, 2021

I'm wondering if this is already possible, by default the buildkite agent binary is available to the job, thinking it should be possible to run bootstrap as the job's command instead - would those work in this case?

@keith
Copy link
Collaborator Author

keith commented Jun 10, 2021

Interesting! So I guess we could override that nice, I'm not sure if that's still how it should work though?

@iffyio
Copy link
Contributor

iffyio commented Jun 11, 2021

Yeah it might not be, I'd say we give it a try first and if it'll be significantly simpler to have the plugin run via buidlkite-agent we can look into that - I can't really think of any disadvantages atm with running via the agent beyond the command's logs including buildkite output which should be fine (especially if we make it an opt-in feature)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants