Skip to content

Commit

Permalink
refacotr: re-fix the print column for topologyReady
Browse files Browse the repository at this point in the history
  • Loading branch information
carlmontanari committed May 27, 2024
1 parent a9a28a5 commit 5e74231
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apis/v1alpha1/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ type TopologyStatus struct {
// by the k8s startup/readiness probe (which is in turn managed by the status probe
// configuration of the topology). The possible values are "notready" and "ready", "unknown".
NodeReadiness map[string]string `json:"nodeReadiness"`
// TopologyReady indicates if all nodes in the topology have reported ready. This is duplicated
// from the conditions so we can easily snag it for print columns!
TopologyReady bool `json:"topologyReady"`
// Conditions is a list of conditions for the topology custom resource.
Conditions []metav1.Condition `json:"conditions"`
}
Expand Down
6 changes: 6 additions & 0 deletions assets/crd/clabernetes.containerlab.dev_topologies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,11 @@ spec:
if it is unset (nil) when a Topology is created, the controller will use the default global
config value (false); if the field is non-nil, this status field will hold the non-nil value.
type: boolean
topologyReady:
description: |-
TopologyReady indicates if all nodes in the topology have reported ready. This is duplicated
from the conditions so we can easily snag it for print columns!
type: boolean
required:
- conditions
- configs
Expand All @@ -781,6 +786,7 @@ spec:
- nodeReadiness
- reconcileHashes
- removeTopologyPrefix
- topologyReady
type: object
type: object
served: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,11 @@ spec:
if it is unset (nil) when a Topology is created, the controller will use the default global
config value (false); if the field is non-nil, this status field will hold the non-nil value.
type: boolean
topologyReady:
description: |-
TopologyReady indicates if all nodes in the topology have reported ready. This is duplicated
from the conditions so we can easily snag it for print columns!
type: boolean
required:
- conditions
- configs
Expand All @@ -781,6 +786,7 @@ spec:
- nodeReadiness
- reconcileHashes
- removeTopologyPrefix
- topologyReady
type: object
type: object
served: true
Expand Down
1 change: 1 addition & 0 deletions controllers/topology/reconciledata.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (r *ReconcileData) SetStatus(
}

owningTopologyStatus.NodeReadiness = r.NodeStatuses
owningTopologyStatus.TopologyReady = r.TopologyReady

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions controllers/topology/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,8 @@ func (r *Reconciler) ReconcileDeployments( //nolint: gocyclo
}

if topologyReady {
reconcileData.TopologyReady = true

apimachinerymeta.SetStatusCondition(&owningTopology.Status.Conditions, metav1.Condition{
Type: "TopologyReady",
Status: "True",
Expand Down
9 changes: 9 additions & 0 deletions generated/openapi/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions testhelper/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func NormalizeTopology(t *testing.T, objectData []byte) []byte {
objectData,
"del(.status.nodeReadiness)",
)
objectData = YQCommand(
t,
objectData,
"del(.status.topologyReady)",
)

return objectData
}
Expand Down

0 comments on commit 5e74231

Please sign in to comment.