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

fix: Retry foghorn LighthouseJob update using original variable instead of DeepCopy variable #1591

Merged
merged 3 commits into from
Jan 9, 2024

Conversation

dippynark
Copy link
Contributor

@dippynark dippynark commented Jan 8, 2024

We are using Lighthouse foghorn v1.14.4 and very occasionally it is getting into a continuous loop trying to update a LighthouseJob when there is a conflict.

Initially there is a failure with the following message:

Failed to update LighthouseJob status: Operation cannot be fulfilled on lighthousejobs.lighthouse.jenkins.io "[LIGHTHOUSE_JOB_NAME]": the object has been modified; please apply your changes to the latest version and try again

It does try again and succeeds: took 2 attempts to update Job

However, I think this is false positive because jobCopy (instead of &job) is being passed into retryModifyJob so on retry r.client.Get is overwriting jobCopy and reverting the updated status, meaning the retry is just updating the LighthouseJob to its current value.

This PR instead passes &job into retryModifyJob which matches with the Tekton controller:

err = r.retryModifyJob(ctx, req.NamespacedName, &job, f)

I don't fully understand why foghorn is getting into a continuous loop, I would have thought the update just wouldn't happen (perhaps the noop update is actually triggering another event and foghorn is continuously conflicting with itself), but either way this should fix the problem because on next reconciliation we shouldn't get past the reflect.DeepEqual check.

For a future improvement, Lighthouse foghorn and other controllers could instead use RetryOnConflict from client-go to handle conflicts instead of the custom retryModifyJob function: https://pkg.go.dev/k8s.io/client-go/util/retry#RetryOnConflict

@jenkins-x-bot
Copy link
Contributor

Hi @dippynark. Thanks for your PR.

I'm waiting for a jenkins-x member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the jenkins-x/lighthouse repository.

@dippynark dippynark changed the title fix: Use semantic DeepEqual in foghorn controller fix: Retrieve fresh copy of LighthouseJob using original variable instead of copy in foghorn controller Jan 8, 2024
@dippynark dippynark changed the title fix: Retrieve fresh copy of LighthouseJob using original variable instead of copy in foghorn controller fix: Retry LighthouseJob update using original variable instead of DeepCopy in foghorn controller Jan 8, 2024
@dippynark dippynark changed the title fix: Retry LighthouseJob update using original variable instead of DeepCopy in foghorn controller fix: Retry foghorn LighthouseJob update using original variable instead of DeepCopy Jan 8, 2024
@dippynark dippynark changed the title fix: Retry foghorn LighthouseJob update using original variable instead of DeepCopy fix: Retry foghorn LighthouseJob update using original variable instead of DeepCopied variable Jan 8, 2024
@dippynark dippynark changed the title fix: Retry foghorn LighthouseJob update using original variable instead of DeepCopied variable fix: Retry foghorn LighthouseJob update using original variable instead of DeepCopy variable Jan 8, 2024
@msvticket
Copy link
Member

/ok-to-test

@msvticket
Copy link
Member

/approve

@jenkins-x-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: msvticket

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1591]: [Method Not Allowed]

@jenkins-x-bot jenkins-x-bot merged commit f7cb024 into jenkins-x:main Jan 9, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants