Skip to content

Instantly share code, notes, and snippets.

@thibault-ketterer
Last active August 30, 2026 10:12
Show Gist options
  • Select an option

  • Save thibault-ketterer/e60ea94af1f0562764b5e2e000de22b4 to your computer and use it in GitHub Desktop.

Select an option

Save thibault-ketterer/e60ea94af1f0562764b5e2e000de22b4 to your computer and use it in GitHub Desktop.
check openshift upgrade from the node
oc get nodes -o json \
| jq -r '.items | group_by(.metadata.labels["hypershift.openshift.io/nodePool"])[] | {nodepool: .[0].metadata.labels["hypershift.openshift.io/nodePool"], desired: length, current: (map(select(.status.conditions[] | select(.type=="Ready" and .status=="True"))) | length), nodes: (map(.metadata.name) | join(","))} | [.nodepool,.desired,.current,.nodes] | @tsv'
oc get nodes -o json | jq -r '
  .items
  | group_by(.metadata.labels["hypershift.openshift.io/nodePool"] // "unknown")
  | .[]
  | {
      nodepool: .[0].metadata.labels["hypershift.openshift.io/nodePool"],
      desired: length,
      current: (map(select(any(.status.conditions[]; .type=="Ready" and .status=="True"))) | length),
      nodes: map(.metadata.name)
    }
  | "\(.nodepool)\t desired=\(.desired) current=\(.current)\n  " + (.nodes | join("\n  "))
'
oc get nodes -o json | jq -r '
  .items
  | group_by(.metadata.labels["hypershift.openshift.io/nodePool"] // "unknown")
  | .[]
  | {
      pool: .[0].metadata.labels["hypershift.openshift.io/nodePool"],
      nodes: map({
        name: .metadata.name,
        current: .metadata.annotations["machineconfiguration.openshift.io/currentConfig"],
        desired: .metadata.annotations["machineconfiguration.openshift.io/desiredConfig"]
      })
    }
  | "=== \(.pool) ===",
    "Desired config: \((.nodes | group_by(.desired) | map({config: .[0].desired, count: length}) | map("\(.config) (\(.count) nodes)") | join(", ")))",
    "Current config: \((.nodes | group_by(.current) | map({config: .[0].current, count: length}) | map("\(.config) (\(.count) nodes)") | join(", ")))",
    "Updated: \([.nodes[] | select(.current == .desired)] | length)/\(.nodes | length)",
    "Updating: \([.nodes[] | select(.current != .desired)] | length)/\(.nodes | length)",
    "",
    (.nodes[] | "  \(.name)\tcurrent=\(.current)\tdesired=\(.desired)\t" +
      (if .current == .desired then "OK" else "UPDATING" end)),
    ""
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment