Skip to content

Commit

Permalink
Do not set ongoing-upgrade in IC configmap
Browse files Browse the repository at this point in the history
Single-zone mode is only needed during a 4.13->4.14 upgrade. Switching back to it is not supported. As a consequence, we can further simplify the upgrade logic and remove the "ongoing-upgrade" flag: only CNO pushes the IC configmap to track the upgrade progress, so an upgrade to IC is ongoing if the configmap exists.

Signed-off-by: Riccardo Ravaioli <rravaiol@redhat.com>
  • Loading branch information
ricky-rav committed Dec 5, 2023
1 parent ab2547c commit 0364ebe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
13 changes: 6 additions & 7 deletions pkg/controller/statusmanager/pod_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,14 @@ func (status *StatusManager) SetFromPods() {
if status.isOVNKubernetes != nil && *status.isOVNKubernetes {
// hack for 2-phase upgrade from non-IC to IC ovnk:
// don't update the version field until phase 2 is over
if icConfigMap, err := util.GetInterConnectConfigMap(status.client.ClientFor("").Kubernetes()); err == nil {
// When an upgrade from <= 4.13 is ongoing, the IC configmap exists and exhibits ongoing-upgrade=''.
// When multizone control-plane and node have been rolled out (end of phase 2), the configmap is deleted.
if _, ok := icConfigMap.Data["ongoing-upgrade"]; ok {
reachedAvailableLevel = false
}
if _, err := util.GetInterConnectConfigMap(status.client.ClientFor("").Kubernetes()); err == nil {
// When an upgrade from <= 4.13 is ongoing, CNO has pushed an IC configmap to track it.
// The configmap is deleted when multizone control-plane and node have been rolled out (end of phase 2).
reachedAvailableLevel = false

} else if !apierrors.IsNotFound(err) {
log.Printf("Failed to retrieve interconnect configmap: %v", err)
// don't risk reporting new version during zone mode migration until configmap retrieval is successful
// don't risk reporting the new version during the upgrade to IC until the configmap retrieval is successful
reachedAvailableLevel = false
}
}
Expand Down
35 changes: 12 additions & 23 deletions pkg/network/ovn_kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1256,20 +1256,18 @@ const (
)

type targetZoneModeType struct {
// zoneMode indicates the target zone mode that CNO is supposed to converge to.
// zoneMode indicates the target zone mode that CNO is supposed to converge to. It defaults
// multizone.
zoneMode InterConnectZoneMode
// "configMapFound" indicates whether the interconnect configmap was found; when not found,
// the zone mode defaults to multizone.
// "configMapFound" indicates whether the interconnect configmap was found. The configmap
// is created by CNO itself during a 4.13->4.14 upgrade and deleted once the upgrade is over.
configMapFound bool
// ongoingUpgrade is true when the configmap was pushed by CNO itself; it is used by status manager
// to know it has to keep reporting the old version when this parameter is set.
ongoingUpgrade bool
// fastForwardToMultiZone can be manually set by the cluster admin through the interconnect configmap
// in order to force CNO to deploy multizone OVNK regardless of the current status of OVNK components
// throughout an upgrade to interconnect. This would effectively get the cluster out of phase 1 and phase 2
// during an upgrade to interconnect. This would effectively get the cluster out of phase 1 and phase 2
// and make OVNK jump to the YAMLs in the multi-zone-interconnect folder.
// This can be useful in case of problems during upgrades, if ever the logic in prepareUpgradeToInterconnect
// is not moving forward (e.g. one or more nodes are down and ovnk node is considered as "progressing")
// is not moving forward (e.g. one or more nodes are down and ovnkube-node is considered as "progressing")
fastForwardToMultiZone bool
}

Expand Down Expand Up @@ -1305,10 +1303,6 @@ func getTargetInterConnectZoneMode(kubeClient cnoclient.Client) (targetZoneModeT
targetZoneMode.zoneMode = zoneModeMultiZone
}

if _, ok := interConnectConfigMap.Data["ongoing-upgrade"]; ok {
targetZoneMode.ongoingUpgrade = true
}

if _, ok := interConnectConfigMap.Data["fast-forward-to-multizone"]; ok {
targetZoneMode.fastForwardToMultiZone = true
if targetZoneMode.zoneMode != zoneModeMultiZone {
Expand Down Expand Up @@ -2396,7 +2390,7 @@ func doesVersionEnableInterConnect(string) bool {
// If we're upgrading from a 4.13 cluster, which has no OVN InterConnect support, three phases are necessary.
// Phase 1:
//
// a) prepareUpgradeToInterConnect pushes a configMap with zone-mode=singlezone, ongoing-upgrade='';
// a) prepareUpgradeToInterConnect pushes a configMap with zone-mode=singlezone;
// b) renderOVNKubernetes selects the YAMLs from the single-zone folder
// (node DaemonSet, master DaemonSet [StatefulSet for hypershift], ovnkube-sbdb route [hypershift]);
// c) shouldUpdateOVNKonUpgrade rolls out first node DaemonSet then master DaemonSet/StatefulSet in single-zone mode
Expand Down Expand Up @@ -2426,8 +2420,8 @@ func prepareUpgradeToInterConnect(ovn bootstrap.OVNBootstrapResult, client cnocl

// [start of phase 1]
// if node and master DaemonSets are <= 4.13 (no IC support) and we're upgrading to >= 4.14 (IC),
// go through an intermediate step with IC single-zone DaemonSets. Track this temporary state
// by pushing a configmap.
// go through an intermediate step with IC single-zone DaemonSets. Track that the upgrade is ongoing
// by pushing a configmap with the zone mode that CNO is converging to.
if ovn.NodeUpdateStatus != nil && ovn.MasterUpdateStatus != nil && ovn.ControlPlaneUpdateStatus == nil &&
!ovn.NodeUpdateStatus.InterConnectEnabled &&
!ovn.MasterUpdateStatus.InterConnectEnabled &&
Expand All @@ -2443,10 +2437,6 @@ func prepareUpgradeToInterConnect(ovn bootstrap.OVNBootstrapResult, client cnocl
},
Data: map[string]string{
"zone-mode": fmt.Sprint(zoneModeSingleZone),
// we lookup ongoing-upgrade in SetFromPods (pod_status.go) to distinguish a
// configmap pushed during a non-IC-> IC upgrade from one that is added
// outside of an upgrade by a cluster admin to change the zone mode.
"ongoing-upgrade": "",
},
}
if err := client.ClientFor("").CRClient().Create(context.TODO(), configMap); err != nil {
Expand All @@ -2455,7 +2445,7 @@ func prepareUpgradeToInterConnect(ovn bootstrap.OVNBootstrapResult, client cnocl
targetZoneMode.configMapFound = true
targetZoneMode.zoneMode = zoneModeSingleZone

} else if isMigrationToMultiZoneAboutToStart(ovn, targetZoneMode, true) && targetZoneMode.ongoingUpgrade && !targetZoneMode.fastForwardToMultiZone {
} else if isMigrationToMultiZoneAboutToStart(ovn, targetZoneMode, true) && targetZoneMode.configMapFound && !targetZoneMode.fastForwardToMultiZone {
// [start of phase 2]
// if node and master DaemonSets have already upgraded to >= 4.14 single zone and
// we previously pushed a configmap for single zone,
Expand All @@ -2482,7 +2472,7 @@ func prepareUpgradeToInterConnect(ovn bootstrap.OVNBootstrapResult, client cnocl

targetZoneMode.zoneMode = zoneModeMultiZone

} else if isMigrationToMultiZoneComplete(ovn, targetZoneMode) && targetZoneMode.ongoingUpgrade {
} else if isMigrationToMultiZoneComplete(ovn, targetZoneMode) && targetZoneMode.configMapFound {
// [after completion of phase 2]
// daemonsets have rolled out in multizone mode
// Remove the configmap: this won't trigger any further roll out, but along with the annotation
Expand All @@ -2496,7 +2486,6 @@ func prepareUpgradeToInterConnect(ovn bootstrap.OVNBootstrapResult, client cnocl
return fmt.Errorf("upgrade to interconnect, end of phase2: could not delete interconnect configmap: %w", err)
}
}
targetZoneMode.ongoingUpgrade = false
targetZoneMode.configMapFound = false

// HACK Once we're here, there are no more updates to the DaemonSets and CNO won't update
Expand All @@ -2505,7 +2494,7 @@ func prepareUpgradeToInterConnect(ovn bootstrap.OVNBootstrapResult, client cnocl
}

// Print IC upgrade status when phase 1 or phase 2 are ongoing
if targetZoneMode.ongoingUpgrade {
if targetZoneMode.configMapFound {
if targetZoneMode.zoneMode == zoneModeSingleZone &&
ovn.NodeUpdateStatus != nil && ovn.MasterUpdateStatus != nil && ovn.ControlPlaneUpdateStatus == nil &&
(ovn.NodeUpdateStatus.Progressing || ovn.MasterUpdateStatus.Progressing) {
Expand Down

0 comments on commit 0364ebe

Please sign in to comment.