Skip to content

Commit

Permalink
controllers/finalizers: respect the enabled status of PDB
Browse files Browse the repository at this point in the history
Signed-off-by: Furkan <[email protected]>
  • Loading branch information
Dentrax committed Sep 19, 2024
1 parent fe90f57 commit 09773d1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
6 changes: 4 additions & 2 deletions internal/controller/operator/factory/finalize/vmagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ func OnVMAgentDelete(ctx context.Context, rclient client.Client, crd *vmv1beta1.
}

// check PDB
if err := finalizePBD(ctx, rclient, crd); err != nil {
return err
if crd.Spec.PodDisruptionBudget != nil {
if err := finalizePBD(ctx, rclient, crd); err != nil {
return err
}
}
// remove vmagents service discovery rbac.
if config.IsClusterWideAccessAllowed() {
Expand Down
6 changes: 4 additions & 2 deletions internal/controller/operator/factory/finalize/vmalert.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ func OnVMAlertDelete(ctx context.Context, rclient client.Client, crd *vmv1beta1.
}

// check PDB
if err := finalizePBD(ctx, rclient, crd); err != nil {
return err
if crd.Spec.PodDisruptionBudget != nil {
if err := finalizePBD(ctx, rclient, crd); err != nil {
return err
}
}
if err := deleteSA(ctx, rclient, crd); err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ func OnVMAlertManagerDelete(ctx context.Context, rclient client.Client, crd *vmv
}

// check PDB
if err := finalizePBD(ctx, rclient, crd); err != nil {
return err
if crd.Spec.PodDisruptionBudget != nil {
if err := finalizePBD(ctx, rclient, crd); err != nil {
return err
}
}

if err := deleteSA(ctx, rclient, crd); err != nil {
Expand Down
6 changes: 4 additions & 2 deletions internal/controller/operator/factory/finalize/vmauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ func OnVMAuthDelete(ctx context.Context, rclient client.Client, crd *vmv1beta1.V
}

// check PDB
if err := finalizePBD(ctx, rclient, crd); err != nil {
return err
if crd.Spec.PodDisruptionBudget != nil {
if err := finalizePBD(ctx, rclient, crd); err != nil {
return err
}
}

// check ingress
Expand Down
18 changes: 12 additions & 6 deletions internal/controller/operator/factory/finalize/vmcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ func OnVMClusterDelete(ctx context.Context, rclient client.Client, crd *vmv1beta
}

// check PDB
if err := finalizePBDWithName(ctx, rclient, obj.GetNameWithPrefix(crd.Name), crd.Namespace); err != nil {
return err
if crd.Spec.VMInsert.PodDisruptionBudget != nil {
if err := finalizePBDWithName(ctx, rclient, obj.GetNameWithPrefix(crd.Name), crd.Namespace); err != nil {
return err
}
}
}

Expand All @@ -84,8 +86,10 @@ func OnVMClusterDelete(ctx context.Context, rclient client.Client, crd *vmv1beta
}

// check PDB
if err := finalizePBDWithName(ctx, rclient, obj.GetNameWithPrefix(crd.Name), crd.Namespace); err != nil {
return err
if crd.Spec.VMSelect.PodDisruptionBudget != nil {
if err := finalizePBDWithName(ctx, rclient, obj.GetNameWithPrefix(crd.Name), crd.Namespace); err != nil {
return err
}
}
}
if crd.Spec.VMStorage != nil {
Expand All @@ -104,8 +108,10 @@ func OnVMClusterDelete(ctx context.Context, rclient client.Client, crd *vmv1beta
}

// check PDB
if err := finalizePBDWithName(ctx, rclient, obj.GetNameWithPrefix(crd.Name), crd.Namespace); err != nil {
return err
if crd.Spec.VMStorage.PodDisruptionBudget != nil {
if err := finalizePBDWithName(ctx, rclient, obj.GetNameWithPrefix(crd.Name), crd.Namespace); err != nil {
return err
}
}
}

Expand Down

0 comments on commit 09773d1

Please sign in to comment.