Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove integration delete action and finalizer #996

Merged
merged 1 commit into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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