From 5e74231beec4f579d134d2cb79c622b6a7d023e0 Mon Sep 17 00:00:00 2001 From: Carl Montanari Date: Mon, 27 May 2024 10:57:31 -0700 Subject: [PATCH] refacotr: re-fix the print column for topologyReady --- apis/v1alpha1/topology.go | 3 +++ assets/crd/clabernetes.containerlab.dev_topologies.yaml | 6 ++++++ .../crds/clabernetes.containerlab.dev_topologies.yaml | 6 ++++++ controllers/topology/reconciledata.go | 1 + controllers/topology/reconciler.go | 2 ++ generated/openapi/openapi_generated.go | 9 +++++++++ testhelper/kubernetes.go | 5 +++++ 7 files changed, 32 insertions(+) diff --git a/apis/v1alpha1/topology.go b/apis/v1alpha1/topology.go index 713e3c1..ec9f6dd 100644 --- a/apis/v1alpha1/topology.go +++ b/apis/v1alpha1/topology.go @@ -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"` } diff --git a/assets/crd/clabernetes.containerlab.dev_topologies.yaml b/assets/crd/clabernetes.containerlab.dev_topologies.yaml index 922dba0..a04c69d 100644 --- a/assets/crd/clabernetes.containerlab.dev_topologies.yaml +++ b/assets/crd/clabernetes.containerlab.dev_topologies.yaml @@ -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 @@ -781,6 +786,7 @@ spec: - nodeReadiness - reconcileHashes - removeTopologyPrefix + - topologyReady type: object type: object served: true diff --git a/charts/clabernetes/crds/clabernetes.containerlab.dev_topologies.yaml b/charts/clabernetes/crds/clabernetes.containerlab.dev_topologies.yaml index 922dba0..a04c69d 100644 --- a/charts/clabernetes/crds/clabernetes.containerlab.dev_topologies.yaml +++ b/charts/clabernetes/crds/clabernetes.containerlab.dev_topologies.yaml @@ -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 @@ -781,6 +786,7 @@ spec: - nodeReadiness - reconcileHashes - removeTopologyPrefix + - topologyReady type: object type: object served: true diff --git a/controllers/topology/reconciledata.go b/controllers/topology/reconciledata.go index 0141040..13cdbe1 100644 --- a/controllers/topology/reconciledata.go +++ b/controllers/topology/reconciledata.go @@ -91,6 +91,7 @@ func (r *ReconcileData) SetStatus( } owningTopologyStatus.NodeReadiness = r.NodeStatuses + owningTopologyStatus.TopologyReady = r.TopologyReady return nil } diff --git a/controllers/topology/reconciler.go b/controllers/topology/reconciler.go index 883304b..cf52868 100644 --- a/controllers/topology/reconciler.go +++ b/controllers/topology/reconciler.go @@ -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", diff --git a/generated/openapi/openapi_generated.go b/generated/openapi/openapi_generated.go index d7a23ad..1eab516 100644 --- a/generated/openapi/openapi_generated.go +++ b/generated/openapi/openapi_generated.go @@ -1998,6 +1998,14 @@ func schema_srl_labs_clabernetes_apis_v1alpha1_TopologyStatus( }, }, }, + "topologyReady": { + SchemaProps: spec.SchemaProps{ + 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!", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, "conditions": { SchemaProps: spec.SchemaProps{ Description: "Conditions is a list of conditions for the topology custom resource.", @@ -2022,6 +2030,7 @@ func schema_srl_labs_clabernetes_apis_v1alpha1_TopologyStatus( "configs", "exposedPorts", "nodeReadiness", + "topologyReady", "conditions", }, }, diff --git a/testhelper/kubernetes.go b/testhelper/kubernetes.go index 1df5e61..7f496d7 100644 --- a/testhelper/kubernetes.go +++ b/testhelper/kubernetes.go @@ -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 }