Skip to content

Commit d2bd842

Browse files
Merge pull request #2937 from jluhrsen/CORENET-6572-codex
CORENET-6572: only report Progressing for active network rollouts
2 parents bc5af87 + 996b1b8 commit d2bd842

4 files changed

Lines changed: 815 additions & 213 deletions

File tree

pkg/controller/statusmanager/machineconfig_status.go

Lines changed: 47 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -140,55 +140,43 @@ func (status *StatusManager) SetFromMachineConfigPool(mcPools []mcfgv1.MachineCo
140140
// No degraded pools, so clear degraded status
141141
status.setNotDegraded(MachineConfig)
142142

143-
// Now check for progressing and process machine configs
144143
for role, machineConfigs := range status.renderedMachineConfigs {
145144
pools, err := status.findMachineConfigPoolsForLabel(mcPools, map[string]string{names.MachineConfigLabelRoleKey: role})
146145
if err != nil {
147146
klog.Errorf("failed to get machine config pools for the role %s: %v", role, err)
148147
}
148+
for _, machineConfig := range machineConfigs.UnsortedList() {
149+
mcSet := sets.New[string](machineConfig)
150+
beingRemoved := status.machineConfigsBeingRemoved[role].Has(machineConfig)
149151

150-
progressingPool := status.isAnyMachineConfigPoolProgressing(pools)
151-
if progressingPool != "" {
152-
status.setProgressing(MachineConfig, "MachineConfig", fmt.Sprintf("%s machine config pool in progressing state", progressingPool))
153-
return nil
154-
}
155-
for _, pool := range pools {
156-
if pool.Spec.Paused {
157-
// When a machine config pool is in paused state, then it is expected that mco doesn't process any machine configs for the pool.
158-
// so if we report network status as progressing state then it blocks networking upgrade until machine config pool is changed
159-
// into unpaused state. so let's not consider the pool for reporting status.
160-
continue
161-
}
162-
for _, machineConfig := range machineConfigs.UnsortedList() {
163-
added := true
164-
removed := true
165-
mcSet := sets.Set[string]{}
166-
mcSet.Insert(machineConfig)
167-
if mcsBeingRemoved, ok := status.machineConfigsBeingRemoved[role]; ok && mcsBeingRemoved.Has(machineConfig) {
168-
removed = mcutil.AreMachineConfigsRemovedFromPool(pool.Status, mcSet)
169-
if removed {
170-
status.machineConfigsBeingRemoved[role].Delete(machineConfig)
171-
// Delete map entry from status cache if role doesn't have machine configs. By deleting the entry,
172-
// there won't be any unnecessary processing of pools in the reconcile loop when it's not dealing
173-
// with network operator machine configs anymore.
174-
if status.machineConfigsBeingRemoved[role].Len() == 0 {
175-
delete(status.machineConfigsBeingRemoved, role)
176-
}
177-
status.renderedMachineConfigs[role].Delete(machineConfig)
178-
if status.renderedMachineConfigs[role].Len() == 0 {
179-
delete(status.renderedMachineConfigs, role)
180-
}
181-
if err := status.setLastRenderedMachineConfigState(status.renderedMachineConfigs); err != nil {
182-
return fmt.Errorf("failed to update rendered machine config state: %v", err)
183-
}
152+
sawNonPausedPool := false
153+
for _, pool := range pools {
154+
if pool.Spec.Paused {
155+
// When a machine config pool is in paused state, then it is expected that mco doesn't process any machine configs for the pool.
156+
// so if we report network status as progressing state then it blocks networking upgrade until machine config pool is changed
157+
// into unpaused state. so let's not consider the pool for reporting status.
158+
continue
159+
}
160+
sawNonPausedPool = true
161+
162+
if beingRemoved {
163+
if mcutil.AreMachineConfigsRemovedFromPoolSource(pool.Status, mcSet) {
164+
continue
184165
}
185-
} else {
186-
added = mcutil.AreMachineConfigsRenderedOnPool(pool.Status, mcSet)
166+
} else if mcutil.AreMachineConfigsRenderedOnPoolSource(pool.Status, mcSet) {
167+
continue
187168
}
188-
if !added || !removed {
189-
status.setProgressing(MachineConfig, "MachineConfig",
190-
fmt.Sprintf("%s machine config pool is still processing %s machine config", pool.Name, machineConfig))
191-
return nil
169+
170+
status.setProgressing(MachineConfig, "MachineConfig",
171+
fmt.Sprintf("%s machine config pool is still processing %s machine config", pool.Name, machineConfig))
172+
return nil
173+
}
174+
175+
// Wait to prune cached removal state until every non-paused pool for
176+
// this role reflects the updated rendered source.
177+
if beingRemoved && sawNonPausedPool {
178+
if err := status.forgetRemovedMachineConfig(role, machineConfig); err != nil {
179+
return err
192180
}
193181
}
194182
}
@@ -197,6 +185,24 @@ func (status *StatusManager) SetFromMachineConfigPool(mcPools []mcfgv1.MachineCo
197185
return nil
198186
}
199187

188+
func (status *StatusManager) forgetRemovedMachineConfig(role, machineConfig string) error {
189+
status.machineConfigsBeingRemoved[role].Delete(machineConfig)
190+
// Delete map entry from status cache if role doesn't have machine configs. By deleting the entry,
191+
// there won't be any unnecessary processing of pools in the reconcile loop when it's not dealing
192+
// with network operator machine configs anymore.
193+
if status.machineConfigsBeingRemoved[role].Len() == 0 {
194+
delete(status.machineConfigsBeingRemoved, role)
195+
}
196+
status.renderedMachineConfigs[role].Delete(machineConfig)
197+
if status.renderedMachineConfigs[role].Len() == 0 {
198+
delete(status.renderedMachineConfigs, role)
199+
}
200+
if err := status.setLastRenderedMachineConfigState(status.renderedMachineConfigs); err != nil {
201+
return fmt.Errorf("failed to update rendered machine config state: %v", err)
202+
}
203+
return nil
204+
}
205+
200206
func (status *StatusManager) getLastRenderedMachineConfigState() (map[string]sets.Set[string], error) {
201207
renderedMachineConfigs := map[string]sets.Set[string]{}
202208
co := &configv1.ClusterOperator{ObjectMeta: metav1.ObjectMeta{Name: status.name}}
@@ -250,17 +256,6 @@ func (status *StatusManager) isAnyMachineConfigPoolDegraded(pools []mcfgv1.Machi
250256
return degradedPool
251257
}
252258

253-
func (status *StatusManager) isAnyMachineConfigPoolProgressing(pools []mcfgv1.MachineConfigPool) string {
254-
var progressingPool string
255-
for _, pool := range pools {
256-
if mcomcfgv1.IsMachineConfigPoolConditionTrue(pool.Status.Conditions, mcfgv1.MachineConfigPoolUpdating) {
257-
progressingPool = pool.Name
258-
break
259-
}
260-
}
261-
return progressingPool
262-
}
263-
264259
func (status *StatusManager) findMachineConfigPoolsForLabel(mcPools []mcfgv1.MachineConfigPool, mcLabel labels.Set) ([]mcfgv1.MachineConfigPool, error) {
265260
var mcps []mcfgv1.MachineConfigPool
266261
for _, mcPool := range mcPools {

0 commit comments

Comments
 (0)