Skip to content

Commit

Permalink
feat: reconcile but dont make deployments label (suuuper useful for t…
Browse files Browse the repository at this point in the history
…esting w/out spawning a bunch of stuff)
  • Loading branch information
carlmontanari committed Aug 12, 2024
1 parent 6fe9a29 commit 6e4d416
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions constants/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ const (
// Note that this basically ignored during deletion since our controller doest do anything in
// the delete case (owner reference handles clean up).
LabelIgnoreReconcile = "clabernetes/ignoreReconcile"

// LabelDisableDeployments indicates that controller should reconcile normally but not create
// update or delete any deployments.
LabelDisableDeployments = "clabernetes/disableDeployments"
)

const (
Expand Down
4 changes: 4 additions & 0 deletions constants/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ const (
// NodeStatusUnknown is reported in the topology.status.nodereadiness map for nodes that have
// no deployment available for whatever reason.
NodeStatusUnknown = "unknown"

// NodeStatusDeploymentDisabled is reported in the topology.status.nodereadiness map when the
// parent topology has the "clabernetes/disableDeployments" label set.
NodeStatusDeploymentDisabled = "deploymentDisabled"
)
17 changes: 16 additions & 1 deletion controllers/topology/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ func (r *Reconciler) reconcileDeploymentsHandleRestarts(
}

// ReconcileDeployments reconciles the deployments that make up a clabernetes Topology.
func (r *Reconciler) ReconcileDeployments( //nolint: gocyclo
func (r *Reconciler) ReconcileDeployments( //nolint: gocyclo,funlen
ctx context.Context,
owningTopology *clabernetesapisv1alpha1.Topology,
reconcileData *ReconcileData,
Expand All @@ -789,6 +789,21 @@ func (r *Reconciler) ReconcileDeployments( //nolint: gocyclo
return err
}

_, disableDeployments := owningTopology.ObjectMeta.Labels[clabernetesconstants.LabelDisableDeployments] //nolint:lll
if disableDeployments {
r.Log.Warn("skipping reconciling deployments due to disable deployments label set")

apimachinerymeta.SetStatusCondition(&owningTopology.Status.Conditions, metav1.Condition{
Type: "TopologyReady",
Status: "False",
Reason: clabernetesconstants.NodeStatusDeploymentDisabled,
Message: "topology has 'clabernetes/disableDeployments' label set," +
" skipping reconciling deployments",
})

return nil
}

r.Log.Info("pruning extraneous deployments")

for _, extraDeployment := range deployments.Extra {
Expand Down

0 comments on commit 6e4d416

Please sign in to comment.