-
Notifications
You must be signed in to change notification settings - Fork 87
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
Conversation
6b59453
to
3d5ba20
Compare
pkg/handlers/app.go
Outdated
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) |
There was a problem hiding this comment.
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.
pkg/embeddedcluster/util.go
Outdated
return installationList.Items, nil | ||
} | ||
|
||
func GetLatestInstallation(ctx context.Context, installations []embeddedclusterv1beta1.Installation) (*embeddedclusterv1beta1.Installation, error) { |
There was a problem hiding this comment.
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.
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?
Does this PR require documentation?