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

feat(hydrator): handle sourceHydrator fields from webhook #19397

Merged
merged 3 commits into from
Aug 19, 2024

Conversation

daengdaengLee
Copy link
Contributor

@daengdaengLee daengdaengLee commented Aug 6, 2024

Hello. This is a PR resolves #19070.

I added logging when the new code was executed. I confirmed that the logs were recorded when the webhook was triggered.
hydrator-webhook

If you notice anything I missed, please let me know in the comments, and I'll make the necessary corrections!
Thanks.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@daengdaengLee daengdaengLee changed the title hydrator: handle sourceHydrator fields from webhook feat(hydrator): handle sourceHydrator fields from webhook Aug 6, 2024
@daengdaengLee daengdaengLee force-pushed the issue-19070 branch 2 times, most recently from 1d7fbe3 to a76bcb6 Compare August 11, 2024 02:01
@daengdaengLee daengdaengLee marked this pull request as ready for review August 11, 2024 08:51
@daengdaengLee daengdaengLee requested a review from a team as a code owner August 11, 2024 08:51
Signed-off-by: daengdaengLee <gunho1020@gmail.com>
@daengdaengLee
Copy link
Contributor Author

daengdaengLee commented Aug 12, 2024

Hello, @crenshaw-dev .
I rebased after the latest commit and adjusted my code to match the new changes using your code.
Could you check if I'm using the code correctly?
Thanks!

Copy link
Member

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for all the work and for the rebase! Looks like we had some similar ideas over the weekend. :-)

Do you have time to add some tests for apps with source hydrators?

util/webhook/webhook.go Outdated Show resolved Hide resolved
if path.AppFilesHaveChanged(refreshPaths, changedFiles) {
namespacedAppInterface := a.appClientset.ArgoprojV1alpha1().Applications(app.ObjectMeta.Namespace)
log.Debugf("webhook trigger refresh app to hydrate '%s'", app.ObjectMeta.Name)
_, err = argo.RefreshApp(namespacedAppInterface, app.ObjectMeta.Name, v1alpha1.RefreshTypeNormal)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we modify the argo.RefreshApp function to allow setting just the hydrate annotation instead of the refresh annotation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the app's features are functioning properly, I think it's fine as it is.

If I understand correctly, when there’s an update (patch to k8s, and listen that from informer), messages are added to both the appRefreshQueue (roughly) and appHydrateQueue, and the subscribers to each queue check the execution conditions after receiving the messages.
So even if we make something like argo.HydrateApp, it shouldn't make a significant difference in how the messages are handled.

If I misunderstood something, could you correct me in a comment pleaase?
Thanks!

Signed-off-by: daengdaengLee <gunho1020@gmail.com>
@daengdaengLee
Copy link
Contributor Author

daengdaengLee commented Aug 13, 2024

Hello, @crenshaw-dev.

Sure! I can add some tests.
But I have some questions :

  • Should I add tests in this PR?
  • Could you please explain in more detail what kind of tests you're looking for?

@crenshaw-dev
Copy link
Member

Yep, tests in this PR would be great! I'd just copy some of the test cases in webhook_test.go and use a SourceHydrator in the spec instead of a Source.

… SourceHydrator is configured

Signed-off-by: daengdaengLee <gunho1020@gmail.com>
@daengdaengLee
Copy link
Contributor Author

daengdaengLee commented Aug 13, 2024

Hello @crenshaw-dev.

Thank you for letting me know there are tests for webhook.
I’ve added a test to confirm that the new code runs correctly. : TestGitHubCommitEvent_Hydrate

Please let me know if I missed anything.
Thanks!

@daengdaengLee
Copy link
Contributor Author

daengdaengLee commented Aug 19, 2024

Hello, @crenshaw-dev .

Could you check this PR please?
Is there anything else needed for this PR to be merged?
If any changes are needed, please let me know.

Thank you.

Copy link
Member

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thank you!

@crenshaw-dev crenshaw-dev merged commit 7a1dfc2 into argoproj:hydrator Aug 19, 2024
8 of 9 checks passed
@daengdaengLee daengdaengLee deleted the issue-19070 branch August 19, 2024 14:30
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

Successfully merging this pull request may close these issues.

3 participants