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

GIT_SYNC_EXECHOOK_COMMAND + GIT_SYNC_ONE_TIME #463

Closed
ChrisERo opened this issue Jan 6, 2022 · 5 comments
Closed

GIT_SYNC_EXECHOOK_COMMAND + GIT_SYNC_ONE_TIME #463

ChrisERo opened this issue Jan 6, 2022 · 5 comments

Comments

@ChrisERo
Copy link
Contributor

ChrisERo commented Jan 6, 2022

Is a command specified by the EXECHOOK_COMMAND environment variable always supposed to execute after git sync pulls/clones a git repo? The documentation suggests this, but when GIT_SYNC_ONE_TIME is true, I do not see where this is enforced. It seems possible that the main thread could execute os.Exit before the exechook/consumer thread processes the "sync event" and executes the specified command.

I looked at version 3.3.4 and it looks like it does not have such a race condition, as the exechook is run by the same main thread.

Forgive me if this is not the correct venue to post this question/issue; it's my first "contribution" to an open-source project.

@thockin
Copy link
Member

thockin commented Jan 6, 2022 via email

@ChrisERo
Copy link
Contributor Author

ChrisERo commented Jan 7, 2022

Hi @thockin, thanks for the prompt response!!

I would find this guarantee to be useful. In my personal use-case, I only need git-sync to perform a one-time 'git clone' on a git tag and store the source code in a specific, preexisting folder. Ideally, git-sync would be an init-container in this scenario, explaining my dependence on GIT_SYNC_ONE_TIME. To put the sourcecode in the right location, I am relying on a shell script inside git-sync container's volume, referenced by GIT_SYNC_EXECHOOK_COMMAND.

I would be happy to take a crack at drafting this PR. I see that in the previous release, the sync-hook was executed in the same thread that terminates if the "ONE_TIME" flag is true. Is this an acceptable solution: removing the asynchrony involved with exec/sync hook?

@thockin
Copy link
Member

thockin commented Jan 7, 2022 via email

ChrisERo pushed a commit to ChrisERo/git-sync that referenced this issue Jan 8, 2022
resolved issue by introducing a boolean chanel by which exechook runner can communicate with main thread.
ChrisERo added a commit to ChrisERo/git-sync that referenced this issue Jan 8, 2022
Resolved original issue by introducing a boolean chanel by which exechook runner can communicate with main thread.
Then introduced and used webhook executed-at-least-once chanel and added documentation explaining sections of of code
only executed when git-sync pulls for first time.
@ChrisERo
Copy link
Contributor Author

ChrisERo commented Jan 8, 2022

Thanks for the insight!

I created the following PR, #466, the code hasn't been tested, but I want to make sure this is the general strategy you were looking for before proceeding.

@ChrisERo
Copy link
Contributor Author

Hi @thockin, just updated the PR to address your concerns, except the e2e tests. I added tests for exechook, but want to make sure that the pattern they use suffices before using it to test webhook.

k8s-ci-robot added a commit that referenced this issue Jan 19, 2022
@thockin thockin closed this as completed Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants