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: race condition when updating registry settings #4036

Merged
merged 2 commits into from
Sep 13, 2023

Conversation

cbodonnell
Copy link
Contributor

@cbodonnell cbodonnell commented Sep 13, 2023

(cherry picked from commit 004d72d)

What this PR does / why we need it:

This PR fixes a race condition where the backend would return a response from the PUT /api/v1/app/{appSlug}/registry handler before the image re-writing task started. This could result in a scenario where the UI polls the /api/v1/app/{appSlug}/imagerewritestatus endpoint before there is a task status, so the backend will return a response indicating that image re-writing is complete even though it has not even begun. This causes the UI to not display the spinner and status messages, as expected.

Example of this in our tests: https://app.testim.io/#/project/wpYAooUimFDgQxY73r17/branch/ricardomaraschini%2Fsc-86964%2Fkots-test-workflow-for-helmvm/test/aPhWnwQiqtBxx2sn/step/wbZJmRizYrvNWuVc/viewer/screenshots?result-id=XCLtQZlJnzWmYF5k&path=w5blTCkqUInoZuUc%3AwbZJmRizYrvNWuVc

Which issue(s) this PR fixes:

See testim link above...

Special notes for your reviewer:

Changed the Registry Settings step in validate-smoke-test to mark an error if the loading indicator does not show to add coverage for the UI (link).

Steps to reproduce

It's a race condition, so only happens occasionally. To reproduce, change the registry settings and save. The UI will not always show the loading indicator and status messages.

Does this PR introduce a user-facing change?

Fixes an issue where updating the registry settings would not always display the loading indicator and status messages in the UI

Does this PR require documentation?

NONE

@cbodonnell cbodonnell added type::bug Something isn't working bug::normal labels Sep 13, 2023
Comment on lines +213 to +225
skipImagePush := updateAppRegistryRequest.IsReadOnly
if foundApp.IsAirgap {
// TODO: pushing images not yet supported in airgapped instances.
skipImagePush = true
}

latestSequence, err := store.GetStore().GetLatestAppSequence(foundApp.ID, true)
if err != nil {
logger.Error(errors.Wrapf(err, "failed to get latest app sequence for app %s", foundApp.Slug))
updateAppRegistryResponse.Error = err.Error()
JSON(w, http.StatusInternalServerError, updateAppRegistryResponse)
return
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this bit out of the goroutine since we don't want to set an initial task status of "running" if the query fails.

@cbodonnell cbodonnell changed the title fix race condition when updating registry settings fix: race condition when updating registry settings Sep 13, 2023
@cbodonnell cbodonnell marked this pull request as ready for review September 13, 2023 14:16
@@ -22,7 +22,7 @@ metadata:
name: capacity-res-job
spec:
parallelism: 4
backoffLimit: 0
backoffLimit: 6
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated to the issue, but should fix flakiness we've been seeing in this test as it will allow this job, which reserves GKE autopilot capacity, to be retried.

@cbodonnell cbodonnell merged commit 9f8e40a into main Sep 13, 2023
79 checks passed
@cbodonnell cbodonnell deleted the cbo/fix-registry-settings-race-condition branch September 13, 2023 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug::normal type::bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants