func (a *UpgradeGatewayAPIV1) runCluster() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
clientNodes, _ := connector.AgentClients(r.Context())
// filter out cluster delegate and non-delegate nodes
var clusterDelegateNode *catalog.Agent
var nonDelegateNodes []*catalog.Agent
for _, node := range clientNodes {
if node.ClusterAttrs.ClusterDelegate{
clusterDelegateNode = node
} else {
nonDelegateNodes = append(nonDelegateNodes, node)
}
}
ctx := r.Context()
// trigger upgrade on non-delegate nodes
response := externalds.ForEachAsync(clientNodes, func(node *catalog.Agent) RunResponse {
node.UpgradeClient().Run(ctx, &upgradegen.RunRequest{
UpgradePackageFile: "",
Version: "3.22.0",
SkipReboot: false,
})
})
// check for upgrade status on non-delegate nodes. It takes 3-4 min for the process above to finish
runFinished := false
for !runFinished {
time.Sleep(5 * time.Second)
response = clusterDelegateNode.UpgradeClient().GetStatus();
runFinished = true
for r := range response {
if r.UUID == clusterDelegateNode.ClusterAttrs.Uuid {
continue
}
if r.OverallStatus == FAILED {
//handle failure case and toleate reboot error
runFinished = false
}
if r.OverallStatus != COMPLETED {
runFinished = false
}
}
// trigger upgrade on cluster delegate nodes
if runFinished{
clusterDelegateNode.UpgradeClient().Run(ctx, &upgradegen.RunRequest{
UpgradePackageFile: "",
Version: "3.22.0",
SkipReboot: false,
})
}
}
}
}
Last active
April 8, 2026 07:58
-
-
Save zheng022/18c55fe217ade8282ec96453b8b88aa2 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment