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 cluster upgrade modal not showing intermittently #4488

Merged
merged 3 commits into from Mar 4, 2024

Conversation

cbodonnell
Copy link
Member

@cbodonnell cbodonnell commented Mar 1, 2024

What this PR does / why we need it:

This PR fixes a race condition issue in embedded clusters where the cluster upgrade modal would fail to show intermittently. This issue would arise if the new installation had been applied to the cluster, but had not yet had a state reported back to the UI before downtime occurred. In this scenario, the UI was not able to determine whether a cluster upgrade was pending.

This PR changes the app details response to also include the number of installation objects in the cluster. In this case, we can infer that if the latest installation does not yet have a state, but is not the only installation, then it has just recently been applied and a cluster upgrade may be pending. If there is not actually an upgrade pending, downtime will not occur and the UI will receive another update with the actual state shortly thereafter. If there is an upgrade pending, the downtime may begin before the UI receives an actual state, but with these changes will show the upgrade modal.

Which issue(s) this PR fixes:

https://app.shortcut.com/replicated/story/99951/cluster-upgrade-modal-fails-to-show-intermittently

Special notes for your reviewer:

Steps to reproduce

Does this PR introduce a user-facing change?

Fixes an issue in Embedded Cluster (Beta) where the cluster upgrade modal may fail to show during upgrades

Does this PR require documentation?

@cbodonnell cbodonnell added type::bug Something isn't working bug::normal labels Mar 1, 2024
@cbodonnell cbodonnell force-pushed the cbo/upgrade-modal-shows-intermittently branch from 6b59453 to 3d5ba20 Compare March 1, 2024 16:00
@cbodonnell cbodonnell marked this pull request as ready for review March 1, 2024 18:16
Comment on lines 349 to 357
cluster.NumInstallations = len(embeddedClusterInstallations)

latestEmbeddedClusterInstallation, err := embeddedcluster.GetLatestInstallation(context.TODO(), embeddedClusterInstallations)
if err != nil {
return nil, errors.Wrap(err, "failed to get latest installation")
}

if latestEmbeddedClusterInstallation != nil {
cluster.State = string(latestEmbeddedClusterInstallation.Status.State)
Copy link
Member Author

Choose a reason for hiding this comment

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

if the installation was just recently created, .Status.State may be empty. the goal here is to provide an additional piece of data numInstallations to the UI so it can make the proper determination of whether or not to show the modal in these cases if downtime occurs before it receives an actual state.

return installationList.Items, nil
}

func GetLatestInstallation(ctx context.Context, installations []embeddedclusterv1beta1.Installation) (*embeddedclusterv1beta1.Installation, error) {
Copy link
Member

Choose a reason for hiding this comment

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

IMO this function name is confusing because there's already a GetCurrentInstallation. Listing installations from the cluster isn't an expensive process, so I would suggest basically calling both ListInstallations and GetCurrentInstallation instead of trying to save a function call.

sgalsaleh
sgalsaleh previously approved these changes Mar 4, 2024
@cbodonnell cbodonnell merged commit ad728ed into main Mar 4, 2024
104 checks passed
@cbodonnell cbodonnell deleted the cbo/upgrade-modal-shows-intermittently branch March 4, 2024 16:52
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.

None yet

2 participants