Skip to content

Commit

Permalink
remove integration delete action and finalizer #995
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Oct 9, 2019
1 parent 1e2368d commit 71f2bed
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 341 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ replace (
)

replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999

go 1.13
2 changes: 0 additions & 2 deletions pkg/apis/camel/v1alpha1/integration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ const (
IntegrationPhaseRunning IntegrationPhase = "Running"
// IntegrationPhaseError --
IntegrationPhaseError IntegrationPhase = "Error"
// IntegrationPhaseDeleting --
IntegrationPhaseDeleting IntegrationPhase = "Deleting"

// IntegrationConditionKitAvailable --
IntegrationConditionKitAvailable IntegrationConditionType = "IntegrationKitAvailable"
Expand Down
10 changes: 0 additions & 10 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (
"strings"
"syscall"

"github.com/apache/camel-k/pkg/util/finalizer"

"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/apache/camel-k/pkg/client"
"github.com/apache/camel-k/pkg/gzip"
Expand Down Expand Up @@ -85,7 +83,6 @@ func newCmdRun(rootCmdOptions *RootCmdOptions) *cobra.Command {
cmd.Flags().BoolVar(&options.Compression, "compression", false, "Enable store source as a compressed binary blob")
cmd.Flags().StringSliceVar(&options.Resources, "resource", nil, "Add a resource")
cmd.Flags().StringSliceVar(&options.OpenAPIs, "open-api", nil, "Add an OpenAPI v2 spec")
cmd.Flags().StringVar(&options.DeletionPolicy, "deletion-policy", "owner", "Policy used to cleanup child resources, default owner")
cmd.Flags().StringSliceVarP(&options.Volumes, "volume", "v", nil, "Mount a volume into the integration container. E.g \"-v pvcname:/container/path\"")
cmd.Flags().StringSliceVarP(&options.EnvVars, "env", "e", nil, "Set an environment variable in the integration container. E.g \"-e MY_VAR=my-value\"")

Expand All @@ -102,7 +99,6 @@ type runCmdOptions struct {
Logs bool
Sync bool
Dev bool
DeletionPolicy string
IntegrationKit string
IntegrationName string
Profile string
Expand Down Expand Up @@ -376,12 +372,6 @@ func (o *runCmdOptions) updateIntegrationCode(c client.Client, sources []string)
})
}

if o.DeletionPolicy == "label" {
integration.Finalizers = []string{
finalizer.CamelIntegrationFinalizer,
}
}

for _, item := range o.Dependencies {
integration.Spec.AddDependency(item)
}
Expand Down
203 changes: 0 additions & 203 deletions pkg/controller/integration/delete.go

This file was deleted.

6 changes: 0 additions & 6 deletions pkg/controller/integration/integration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,6 @@ func (r *ReconcileIntegration) Reconcile(request reconcile.Request) (reconcile.R
target := instance.DeepCopy()
targetLog := rlog.ForIntegration(target)

// Delete phase
if target.GetDeletionTimestamp() != nil {
target.Status.Phase = v1alpha1.IntegrationPhaseDeleting
}

if target.Status.Phase == v1alpha1.IntegrationPhaseNone || target.Status.Phase == v1alpha1.IntegrationPhaseWaitingForPlatform {
pl, err := platform.GetOrLookup(ctx, r.client, target.Namespace, target.Status.Platform)
if err != nil || pl.Status.Phase != v1alpha1.IntegrationPlatformPhaseReady {
Expand Down Expand Up @@ -262,7 +257,6 @@ func (r *ReconcileIntegration) Reconcile(request reconcile.Request) (reconcile.R
NewDeployAction(),
NewMonitorAction(),
NewErrorAction(),
NewDeleteAction(),
}

for _, a := range actions {
Expand Down
35 changes: 10 additions & 25 deletions pkg/trait/owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import (
"strings"

"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/apache/camel-k/pkg/util/finalizer"

"github.com/pkg/errors"

appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -79,30 +76,18 @@ func (t *ownerTrait) Apply(e *Environment) error {
}
}

ok, err := finalizer.Exists(e.Integration, finalizer.CamelIntegrationFinalizer)
if err != nil {
return errors.Wrap(err, "failed to read finalizer"+finalizer.CamelIntegrationFinalizer)
}

e.Resources.VisitMetaObject(func(res metav1.Object) {
//
// do not add owner reference if the finalizer is set
// so resources are not automatically deleted by k8s
// when owner is deleted
//
if !ok {
references := []metav1.OwnerReference{
{
APIVersion: e.Integration.APIVersion,
Kind: e.Integration.Kind,
Name: e.Integration.Name,
UID: e.Integration.UID,
Controller: &controller,
BlockOwnerDeletion: &blockOwnerDeletion,
},
}
res.SetOwnerReferences(references)
references := []metav1.OwnerReference{
{
APIVersion: e.Integration.APIVersion,
Kind: e.Integration.Kind,
Name: e.Integration.Name,
UID: e.Integration.UID,
Controller: &controller,
BlockOwnerDeletion: &blockOwnerDeletion,
},
}
res.SetOwnerReferences(references)

// Transfer annotations
t.propagateLabelAndAnnotations(res, targetLabels, targetAnnotations)
Expand Down
15 changes: 1 addition & 14 deletions pkg/trait/owner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,14 @@ import (
"testing"

"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/apache/camel-k/pkg/util/finalizer"

"github.com/stretchr/testify/assert"

appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestOwnerWithFinalizer(t *testing.T) {
env := SetUpOwnerEnvironment(t)
env.Integration.Finalizers = []string{finalizer.CamelIntegrationFinalizer}

processTestEnv(t, env)

assert.NotEmpty(t, env.ExecutedTraits)
assert.NotNil(t, env.GetTrait(ID("owner")))

ValidateOwnerResources(t, env, false)
}

func TestOwnerWithoutFinalizer(t *testing.T) {
func TestOwner(t *testing.T) {
env := SetUpOwnerEnvironment(t)

processTestEnv(t, env)
Expand Down
Loading

0 comments on commit 71f2bed

Please sign in to comment.