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

Improve the tester handling when a cluster is upgraded #2130

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 additions & 14 deletions controllers/bounce_processes.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,37 @@ func getProcessesReadyForRestart(logger logr.Logger, cluster *fdbv1beta2.Foundat
return addresses, nil
}

// getUpgradeAddressesFromStatus will return the processes that can be upgraded and all the processes that are not ready to be upgraded.
func getUpgradeAddressesFromStatus(logger logr.Logger, status *fdbv1beta2.FoundationDBStatus, pendingUpgrades map[fdbv1beta2.ProcessGroupID]bool, version string) ([]fdbv1beta2.ProcessAddress, []string) {
notReadyProcesses := make([]string, 0)
addresses := make([]fdbv1beta2.ProcessAddress, 0, len(status.Cluster.Processes))
for _, process := range status.Cluster.Processes {
// Ignore any tester processes as those are not restarted with the kill command.
if process.ProcessClass == fdbv1beta2.ProcessClassTest {
continue
}

processID, ok := process.Locality[fdbv1beta2.FDBLocalityInstanceIDKey]
if !ok {
logger.Info("Ignore process with missing locality field", "address", process.Address.String())
continue
}

if process.Version == version {
continue
}

if pendingUpgrades[fdbv1beta2.ProcessGroupID(processID)] {
addresses = append(addresses, process.Address)
continue
}

notReadyProcesses = append(notReadyProcesses, processID)
}

return addresses, notReadyProcesses
}

// getAddressesForUpgrade checks that all processes in a cluster are ready to be
// upgraded and returns the full list of addresses.
func getAddressesForUpgrade(logger logr.Logger, r *FoundationDBClusterReconciler, status *fdbv1beta2.FoundationDBStatus, lockClient fdbadminclient.LockClient, cluster *fdbv1beta2.FoundationDBCluster, version fdbv1beta2.Version) ([]fdbv1beta2.ProcessAddress, *requeue) {
Expand All @@ -300,20 +331,7 @@ func getAddressesForUpgrade(logger logr.Logger, r *FoundationDBClusterReconciler
return nil, &requeue{message: "Deferring upgrade until database is available"}
}

notReadyProcesses := make([]string, 0)
addresses := make([]fdbv1beta2.ProcessAddress, 0, len(status.Cluster.Processes))
for _, process := range status.Cluster.Processes {
processID := process.Locality[fdbv1beta2.FDBLocalityInstanceIDKey]
if process.Version == version.String() {
continue
}
if pendingUpgrades[fdbv1beta2.ProcessGroupID(processID)] {
addresses = append(addresses, process.Address)
} else {
notReadyProcesses = append(notReadyProcesses, processID)
}
}

addresses, notReadyProcesses := getUpgradeAddressesFromStatus(logger, status, pendingUpgrades, version.String())
if len(notReadyProcesses) > 0 {
logger.Info("Deferring upgrade until all processes are ready to be upgraded", "remainingProcesses", notReadyProcesses)
message := fmt.Sprintf("Waiting for processes to be updated: %v", notReadyProcesses)
Expand Down
Loading
Loading