Skip to content

Commit

Permalink
Merge pull request openshift#1732 from Davoska/ota-1036-control-plane…
Browse files Browse the repository at this point in the history
…-node-status-followup

OTA-1036: `adm update status`: Refactor node status
  • Loading branch information
openshift-merge-bot[bot] authored Apr 9, 2024
2 parents 7094d6f + 09ed836 commit 46db7c2
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 88 deletions.
4 changes: 2 additions & 2 deletions pkg/cli/admin/upgrade/status/examples/4.14.1-degraded.output
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Completion: 97%
Duration: 1h58m50s
Operator Status: 33 Total, 32 Available, 1 Progressing, 4 Degraded

Control Plane Node(s)
Control Plane Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-30-217.us-east-2.compute.internal Outdated Pending 4.14.0-rc.3 ?
ip-10-0-53-40.us-east-2.compute.internal Outdated Pending 4.14.0-rc.3 ?
Expand All @@ -26,7 +26,7 @@ Assessment: Pending
Completion: 0%
Worker Status: 3 Total, 3 Available, 0 Progressing, 3 Outdated, 0 Draining, 0 Excluded, 0 Degraded

Worker Pool Node(s)
Worker Pool Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-20-162.us-east-2.compute.internal Outdated Pending 4.14.0-rc.3 ?
ip-10-0-4-159.us-east-2.compute.internal Outdated Pending 4.14.0-rc.3 ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Completion: 12%
Duration: 6s
Operator Status: 33 Total, 33 Available, 0 Progressing, 0 Degraded

Control Plane Node(s)
Control Plane Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-30-217.us-east-2.compute.internal Outdated Pending 4.14.0 ?
ip-10-0-53-40.us-east-2.compute.internal Outdated Pending 4.14.0 ?
Expand All @@ -20,7 +20,7 @@ Assessment: Excluded
Completion: 0%
Worker Status: 3 Total, 3 Available, 0 Progressing, 3 Outdated, 0 Draining, 3 Excluded, 0 Degraded

Worker Pool Node(s)
Worker Pool Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-20-162.us-east-2.compute.internal Excluded Paused 4.14.0 -
ip-10-0-4-159.us-east-2.compute.internal Excluded Paused 4.14.0 -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,53 +329,6 @@ items:
status: "True"
type: Ready
volumesInUse: []
- apiVersion: v1
kind: Node
metadata:
annotations:
machineconfiguration.openshift.io/controlPlaneTopology: HighlyAvailable
machineconfiguration.openshift.io/currentConfig: rendered-worker-4cec9ed3a634560e5c083a187c8f93a7
machineconfiguration.openshift.io/desiredConfig: rendered-worker-4cec9ed3a634560e5c083a187c8f93a7
machineconfiguration.openshift.io/desiredDrain: uncordon-rendered-worker-4cec9ed3a634560e5c083a187c8f93a7
machineconfiguration.openshift.io/lastAppliedDrain: uncordon-rendered-worker-4cec9ed3a634560e5c083a187c8f93a7
machineconfiguration.openshift.io/lastSyncedControllerConfigResourceVersion: "40375"
machineconfiguration.openshift.io/reason: ""
machineconfiguration.openshift.io/state: Done
creationTimestamp: "2024-02-07T16:09:53Z"
labels:
machine.openshift.io/interruptible-instance: ""
node-role.kubernetes.io/infra: ""
name: ip-10-0-20-162-infra.us-east-2.compute.internal
resourceVersion: "41345"
uid: 88626d63-b4f4-44a5-b0bc-4de955567fbe
spec: {}
status:
conditions:
- lastHeartbeatTime: "2024-02-07T16:45:05Z"
lastTransitionTime: "2024-02-07T16:09:53Z"
message: kubelet has sufficient memory available
reason: KubeletHasSufficientMemory
status: "False"
type: MemoryPressure
- lastHeartbeatTime: "2024-02-07T16:45:05Z"
lastTransitionTime: "2024-02-07T16:09:53Z"
message: kubelet has no disk pressure
reason: KubeletHasNoDiskPressure
status: "False"
type: DiskPressure
- lastHeartbeatTime: "2024-02-07T16:45:05Z"
lastTransitionTime: "2024-02-07T16:09:53Z"
message: kubelet has sufficient PID available
reason: KubeletHasSufficientPID
status: "False"
type: PIDPressure
- lastHeartbeatTime: "2024-02-07T16:45:05Z"
lastTransitionTime: "2024-02-07T16:10:36Z"
message: kubelet is posting ready status
reason: KubeletReady
status: "True"
type: Ready
volumesInUse: []
kind: List
metadata:
resourceVersion: ""
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Completion: 97%
Duration: 14m4s
Operator Status: 33 Total, 32 Available, 1 Progressing, 0 Degraded

Control Plane Node(s)
Control Plane Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-53-40.us-east-2.compute.internal Progressing Draining 4.14.0 +30m
ip-10-0-30-217.us-east-2.compute.internal Outdated Pending 4.14.0 ?
Expand All @@ -20,7 +20,7 @@ Assessment: Progressing
Completion: 0%
Worker Status: 3 Total, 2 Available, 1 Progressing, 3 Outdated, 1 Draining, 0 Excluded, 0 Degraded

Worker Pool Node(s)
Worker Pool Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-4-159.us-east-2.compute.internal Progressing Draining 4.14.0 +30m
ip-10-0-20-162.us-east-2.compute.internal Outdated Pending 4.14.0 ?
Expand All @@ -30,12 +30,11 @@ ip-10-0-99-40.us-east-2.compute.internal Outdated Pending 4.14.0 ?
Worker Pool: infra
Assessment: Progressing
Completion: 0%
Worker Status: 2 Total, 1 Available, 1 Progressing, 2 Outdated, 1 Draining, 0 Excluded, 0 Degraded
Worker Status: 1 Total, 0 Available, 1 Progressing, 1 Outdated, 1 Draining, 0 Excluded, 0 Degraded

Worker Pool Node(s)
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-4-159-infra.us-east-2.compute.internal Progressing Draining 4.14.0 +30m
ip-10-0-20-162-infra.us-east-2.compute.internal Outdated Pending 4.14.0 ?
Worker Pool Node
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-4-159-infra.us-east-2.compute.internal Progressing Draining 4.14.0 +30m

= Update Health =
SINCE LEVEL IMPACT MESSAGE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Completion: 43%
Duration: 52m56s
Operator Status: 7 Total, 7 Available, 0 Progressing, 0 Degraded

Control Plane Node(s)
Control Plane Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-30-217.us-east-2.compute.internal Outdated Pending 4.15.0-ec.1 ?
ip-10-0-53-40.us-east-2.compute.internal Outdated Pending 4.15.0-ec.1 ?
Expand All @@ -20,7 +20,7 @@ Assessment: Pending
Completion: 0%
Worker Status: 3 Total, 3 Available, 0 Progressing, 3 Outdated, 0 Draining, 0 Excluded, 0 Degraded

Worker Pool Node(s)
Worker Pool Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-20-162.us-east-2.compute.internal Outdated Pending 4.15.0-ec.1 ?
ip-10-0-4-159.us-east-2.compute.internal Outdated Pending 4.15.0-ec.1 ?
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/admin/upgrade/status/examples/4.15.0-ec2-early.output
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Completion: 3%
Duration: 1m29s
Operator Status: 33 Total, 33 Available, 2 Progressing, 0 Degraded

Control Plane Node(s)
Control Plane Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-30-217.us-east-2.compute.internal Outdated Pending 4.14.1 ?
ip-10-0-53-40.us-east-2.compute.internal Outdated Pending 4.14.1 ?
Expand All @@ -20,7 +20,7 @@ Assessment: Pending
Completion: 0%
Worker Status: 3 Total, 3 Available, 0 Progressing, 3 Outdated, 0 Draining, 0 Excluded, 0 Degraded

Worker Pool Node(s)
Worker Pool Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-20-162.us-east-2.compute.internal Outdated Pending 4.14.1 ?
ip-10-0-4-159.us-east-2.compute.internal Outdated Pending 4.14.1 ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Completion: 97%
Duration: 58m53s
Operator Status: 33 Total, 31 Available, 1 Progressing, 1 Degraded

Control Plane Node(s)
Control Plane Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-30-217.us-east-2.compute.internal Outdated Pending 4.14.0-rc.3 ?
ip-10-0-53-40.us-east-2.compute.internal Outdated Pending 4.14.0-rc.3 ?
Expand All @@ -20,7 +20,7 @@ Assessment: Pending
Completion: 0%
Worker Status: 3 Total, 3 Available, 0 Progressing, 3 Outdated, 0 Draining, 0 Excluded, 0 Degraded

Worker Pool Node(s)
Worker Pool Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
ip-10-0-20-162.us-east-2.compute.internal Outdated Pending 4.14.0-rc.3 ?
ip-10-0-4-159.us-east-2.compute.internal Outdated Pending 4.14.0-rc.3 ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Completion: 100%
Duration: 3h30m31s
Operator Status: 36 Total, 36 Available, 0 Progressing, 1 Degraded

Control Plane Node(s)
Control Plane Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
build0-gstfj-m-0.c.openshift-ci-build-farm.internal Completed Updated 4.16.0-ec.3 -
build0-gstfj-m-1.c.openshift-ci-build-farm.internal Completed Updated 4.16.0-ec.3 -
Expand All @@ -26,7 +26,7 @@ Assessment: Degraded
Completion: 39%
Worker Status: 59 Total, 46 Available, 5 Progressing, 36 Outdated, 12 Draining, 0 Excluded, 7 Degraded

Worker Pool Node(s)
Worker Pool Nodes
NAME ASSESSMENT PHASE VERSION EST MESSAGE
build0-gstfj-ci-prowjobs-worker-b-9lztv Degraded Draining 4.16.0-ec.2 ? failed to drain node: build0-gstfj-ci-prowjobs-worker-b-9lztv after 1 hour. Please see machine-config-controller logs for more information
build0-gstfj-ci-prowjobs-worker-b-bg9f5 Degraded Draining 4.16.0-ec.2 ? failed to drain node: build0-gstfj-ci-prowjobs-worker-b-bg9f5 after 1 hour. Please see machine-config-controller logs for more information
Expand Down
12 changes: 7 additions & 5 deletions pkg/cli/admin/upgrade/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ func (o *options) Run(ctx context.Context) error {
}

var updateInsights []updateInsight
var poolsStatusData []poolDisplayData
var workerPoolsStatusData []poolDisplayData
var controlPlanePoolStatusData poolDisplayData
for _, pool := range pools.Items {
nodes, err := selectNodesFromPool(pool, allNodes.Items)
if err != nil {
Expand All @@ -197,9 +198,12 @@ func (o *options) Run(ctx context.Context) error {
updateInsights = append(updateInsights, insights...)
poolStatus, insights := assessMachineConfigPool(pool, nodesStatusData)
updateInsights = append(updateInsights, insights...)
poolsStatusData = append(poolsStatusData, poolStatus)
if poolStatus.Name == mco.MachineConfigPoolMaster {
controlPlanePoolStatusData = poolStatus
} else {
workerPoolsStatusData = append(workerPoolsStatusData, poolStatus)
}
}
controlPlanePoolStatusData, workerPoolsStatusData := separateMasterAndWorkerPools(poolsStatusData)

var isWorkerPoolOutdated bool
for _, pool := range workerPoolsStatusData {
Expand Down Expand Up @@ -240,14 +244,12 @@ func (o *options) Run(ctx context.Context) error {
updateInsights = append(updateInsights, insights...)
fmt.Fprintf(o.Out, "\n")
_ = controlPlaneStatusData.Write(o.Out)
fmt.Fprintf(o.Out, "\nControl Plane Node(s)\n")
controlPlanePoolStatusData.WriteNodes(o.Out)

fmt.Fprintf(o.Out, "\n= Worker Upgrade =\n")
for _, pool := range workerPoolsStatusData {
fmt.Fprintf(o.Out, "\n")
_ = pool.WritePool(o.Out)
fmt.Fprintf(o.Out, "\nWorker Pool Node(s)\n")
pool.WriteNodes(o.Out)
}

Expand Down
35 changes: 18 additions & 17 deletions pkg/cli/admin/upgrade/status/workerpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,6 @@ func getMachineConfig(ctx context.Context, client mcfgv1client.Interface, machin
return client.MachineconfigurationV1().MachineConfigs().Get(ctx, machineConfigName, v1.GetOptions{})
}

func separateMasterAndWorkerPools(pools []poolDisplayData) (poolDisplayData, []poolDisplayData) {
for i := range pools {
if pools[i].Name == mco.MachineConfigPoolMaster {
controlPlane := pools[i]
return controlPlane, append(pools[:i], pools[i+1:]...)
}
}
return poolDisplayData{}, pools
}

func selectNodesFromPool(pool mcfgv1.MachineConfigPool, allNodes []corev1.Node) ([]corev1.Node, error) {
var res []corev1.Node
selector, err := v1.LabelSelectorAsSelector(pool.Spec.NodeSelector)
Expand Down Expand Up @@ -217,7 +207,7 @@ func assessNodesStatus(cv *configv1.ClusterVersion, pool mcfgv1.MachineConfigPoo
})
}

sort.Slice(nodesStatusData[:], func(i, j int) bool {
sort.Slice(nodesStatusData, func(i, j int) bool {
if nodesStatusData[i].Assessment == nodesStatusData[j].Assessment {
if nodesStatusData[i].Phase == nodesStatusData[j].Phase {
return nodesStatusData[i].Name < nodesStatusData[j].Name
Expand Down Expand Up @@ -413,15 +403,17 @@ func assessMachineConfigPool(pool mcfgv1.MachineConfigPool, nodes []nodeDisplayD
}
}

poolStatusData.Assessment = assessmentStateProgressing
if updatedCount == len(nodes) {
switch {
case updatedCount == len(nodes):
poolStatusData.Assessment = assessmentStateCompleted
} else if pendingCount == len(nodes) {
case pendingCount == len(nodes):
poolStatusData.Assessment = assessmentStatePending
} else if poolStatusData.NodesOverview.Degraded > 0 {
case poolStatusData.NodesOverview.Degraded > 0:
poolStatusData.Assessment = assessmentStateDegraded
} else if poolStatusData.NodesOverview.Excluded > 0 {
case poolStatusData.NodesOverview.Excluded > 0:
poolStatusData.Assessment = assessmentStateExcluded
default:
poolStatusData.Assessment = assessmentStateProgressing
}

insights = machineConfigPoolInsights(poolStatusData, pool)
Expand Down Expand Up @@ -462,8 +454,17 @@ Worker Status: {{ .NodesOverview.Total }} Total, {{ .NodesOverview.Available }
`

func (pool *poolDisplayData) WriteNodes(w io.Writer) {
if pool.Name == mco.MachineConfigPoolMaster {
fmt.Fprintf(w, "\nControl Plane Node")
} else {
fmt.Fprintf(w, "\nWorker Pool Node")
}
if len(pool.Nodes) > 1 {
fmt.Fprintf(w, "s")
}

tabw := tabwriter.NewWriter(w, 0, 0, 3, ' ', 0)
_, _ = tabw.Write([]byte("NAME\tASSESSMENT\tPHASE\tVERSION\tEST\tMESSAGE\n"))
_, _ = tabw.Write([]byte("\nNAME\tASSESSMENT\tPHASE\tVERSION\tEST\tMESSAGE\n"))
var total, completed, available, progressing, outdated, draining, excluded int
for i, node := range pool.Nodes {
if i >= 10 {
Expand Down

0 comments on commit 46db7c2

Please sign in to comment.