Skip to content

Commit

Permalink
delete without uninstall by execution controller (run-int-tests) (#810)
Browse files Browse the repository at this point in the history
  • Loading branch information
achimweigel authored Sep 4, 2023
1 parent 449077a commit b61300b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/deployer/lib/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ func (c *controller) delete(ctx context.Context, lsCtx *lsv1alpha1.Context, depl
rt *lsv1alpha1.ResolvedTarget) lserrors.LsError {
logger, ctx := logging.FromContextOrNew(ctx, nil)
if lsv1alpha1helper.HasDeleteWithoutUninstallAnnotation(deployItem.ObjectMeta) {
// this case is not required anymore because those items are removed by the execution controller
// but for security reasons not removed
logger.Info("Deleting deployitem %s without uninstall", deployItem.Name)
} else {
if err := c.deployer.Delete(ctx, lsCtx, deployItem, rt); err != nil {
Expand Down
12 changes: 12 additions & 0 deletions pkg/landscaper/execution/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"context"
"fmt"

lc "github.com/gardener/landscaper/controller-utils/pkg/logging/constants"

"github.com/gardener/landscaper/pkg/utils"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -65,6 +67,8 @@ func (o *Operation) UpdateDeployItems(ctx context.Context) lserrors.LsError {
}

func (o *Operation) TriggerDeployItems(ctx context.Context) (*DeployItemClassification, lserrors.LsError) {
logger, ctx := logging.FromContextOrNew(ctx, nil, lc.KeyMethod, "TriggerDeployItems")

items, orphaned, lsErr := o.getDeployItems(ctx)
if lsErr != nil {
return nil, lsErr
Expand All @@ -87,6 +91,7 @@ func (o *Operation) TriggerDeployItems(ctx context.Context) (*DeployItemClassifi
}

if skip {
logger.Info("Deleting deployitem %s without uninstall", item.DeployItem.Name)
if err := o.removeFinalizerFromDeployItem(ctx, item.DeployItem); err != nil {
return nil, err
}
Expand Down Expand Up @@ -121,6 +126,8 @@ func (o *Operation) TriggerDeployItems(ctx context.Context) (*DeployItemClassifi
}

func (o *Operation) TriggerDeployItemsForDelete(ctx context.Context) (*DeployItemClassification, lserrors.LsError) {
logger, ctx := logging.FromContextOrNew(ctx, nil, lc.KeyMethod, "TriggerDeployItemsForDelete")

op := "TriggerDeployItemsForDelete"

items, _, lsErr := o.getDeployItems(ctx)
Expand Down Expand Up @@ -153,6 +160,7 @@ func (o *Operation) TriggerDeployItemsForDelete(ctx context.Context) (*DeployIte
}

if skip {
logger.Info("Deleting deployitem %s without uninstall", item.DeployItem.Name)
if err := o.removeFinalizerFromDeployItem(ctx, item.DeployItem); err != nil {
return nil, err
}
Expand Down Expand Up @@ -189,6 +197,10 @@ func (o *Operation) triggerDeployItem(ctx context.Context, di *lsv1alpha1.Deploy
func (o *Operation) skipUninstall(ctx context.Context, di *lsv1alpha1.DeployItem) (bool, lserrors.LsError) {
op := "skipUninstall"

if lsv1alpha1helper.HasDeleteWithoutUninstallAnnotation(di.ObjectMeta) {
return true, nil
}

if di.Spec.OnDelete == nil || !di.Spec.OnDelete.SkipUninstallIfClusterRemoved || di.Spec.Target == nil {
return false, nil
}
Expand Down

0 comments on commit b61300b

Please sign in to comment.