This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit d86df4f36bb2ffe42ff8426acfeb0c03fe5f24b6 Author: John Poth <poth.j...@gmail.com> AuthorDate: Mon Sep 6 15:00:27 2021 +0200 Fix #2553: Remove camel-k Phase, Action and Condition tied to SBO --- pkg/apis/camel/v1/integration_types.go | 5 -- .../integration/integration_controller.go | 1 - pkg/controller/integration/wait_for_bindings.go | 65 ---------------------- pkg/trait/service_binding.go | 14 ++--- 4 files changed, 4 insertions(+), 81 deletions(-) diff --git a/pkg/apis/camel/v1/integration_types.go b/pkg/apis/camel/v1/integration_types.go index fe4c469..3a6ea29 100644 --- a/pkg/apis/camel/v1/integration_types.go +++ b/pkg/apis/camel/v1/integration_types.go @@ -116,9 +116,6 @@ const ( IntegrationPhaseWaitingForPlatform IntegrationPhase = "Waiting For Platform" // IntegrationPhaseBuildingKit -- IntegrationPhaseBuildingKit IntegrationPhase = "Building Kit" - // IntegrationPhaseWaitingForBindings means the Integration is currently waiting to be bound - // to other resources, e.g., Service Bindings. - IntegrationPhaseWaitingForBindings IntegrationPhase = "Waiting for Bindings" // IntegrationPhaseDeploying -- IntegrationPhaseDeploying IntegrationPhase = "Deploying" // IntegrationPhaseRunning -- @@ -138,8 +135,6 @@ const ( IntegrationConditionKnativeServiceAvailable IntegrationConditionType = "KnativeServiceAvailable" // IntegrationConditionCronJobAvailable -- IntegrationConditionCronJobAvailable IntegrationConditionType = "CronJobAvailable" - // IntegrationConditionServiceBindingsCollectionReady -- - IntegrationConditionServiceBindingsCollectionReady IntegrationConditionType = "ServiceBindingsCollectionReady" // IntegrationConditionExposureAvailable -- IntegrationConditionExposureAvailable IntegrationConditionType = "ExposureAvailable" // IntegrationConditionPrometheusAvailable -- diff --git a/pkg/controller/integration/integration_controller.go b/pkg/controller/integration/integration_controller.go index 06f2b48..187b6db 100644 --- a/pkg/controller/integration/integration_controller.go +++ b/pkg/controller/integration/integration_controller.go @@ -285,7 +285,6 @@ func (r *reconcileIntegration) Reconcile(ctx context.Context, request reconcile. targetLog := rlog.ForIntegration(target) actions := []Action{ - NewWaitForBindingsAction(), NewPlatformSetupAction(), NewInitializeAction(), newBuildKitAction(), diff --git a/pkg/controller/integration/wait_for_bindings.go b/pkg/controller/integration/wait_for_bindings.go deleted file mode 100644 index b45e9f8..0000000 --- a/pkg/controller/integration/wait_for_bindings.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package integration - -import ( - "context" - - v1 "github.com/apache/camel-k/pkg/apis/camel/v1" - "github.com/apache/camel-k/pkg/trait" - corev1 "k8s.io/api/core/v1" -) - -// NewWaitForBindingsAction waits until Bindings are available and ready to be used by Integrations. -func NewWaitForBindingsAction() Action { - return &waitForBindingsAction{} -} - -type waitForBindingsAction struct { - baseAction -} - -// Name returns a common name of the action -func (action *waitForBindingsAction) Name() string { - return "wait-for-bindings" -} - -// CanHandle tells whether this action can handle the integration -func (action *waitForBindingsAction) CanHandle(integration *v1.Integration) bool { - return integration.Status.Phase == v1.IntegrationPhaseWaitingForBindings -} - -// Handle handles the integrations -func (action *waitForBindingsAction) Handle(ctx context.Context, integration *v1.Integration) (*v1.Integration, error) { - if _, err := trait.Apply(ctx, action.client, integration, nil); err != nil { - return nil, err - } - // TODO: add new binding types here e.g knative binding - bindingsCondTypes := []v1.IntegrationConditionType{v1.IntegrationConditionServiceBindingsCollectionReady} - // let's see if bindings are ready - for _, bindingType := range bindingsCondTypes { - cond := integration.Status.GetCondition(bindingType) - if cond != nil && cond.GetStatus() == corev1.ConditionFalse { - // let's wait some more - return integration, nil - } - } - // bindings are ready - integration.Status.Phase = v1.IntegrationPhaseInitialization - return integration, nil -} diff --git a/pkg/trait/service_binding.go b/pkg/trait/service_binding.go index 30fb969..2d6e87c 100644 --- a/pkg/trait/service_binding.go +++ b/pkg/trait/service_binding.go @@ -58,12 +58,7 @@ func (t *serviceBindingTrait) Configure(e *Environment) (bool, error) { return false, nil } - return e.IntegrationInPhase( - v1.IntegrationPhaseInitialization, - v1.IntegrationPhaseWaitingForBindings, - v1.IntegrationPhaseDeploying, - v1.IntegrationPhaseRunning, - ), nil + return e.IntegrationInPhase(v1.IntegrationPhaseInitialization) || e.IntegrationInRunningPhases(), nil } func (t *serviceBindingTrait) Apply(e *Environment) error { @@ -71,14 +66,13 @@ func (t *serviceBindingTrait) Apply(e *Environment) error { if err != nil { return err } - // let the retry policy be controlled by Camel-k + // let the SBO retry policy be controlled by Camel-k err = process(ctx, getHandlers()) if err != nil { return err } - // construct Secret - secret := getSecret(ctx, e.Integration.Namespace) + secret := createSecret(ctx, e.Integration.Namespace) if secret != nil { e.Resources.Add(secret) e.ApplicationProperties["quarkus.kubernetes-service-binding.enabled"] = "true" @@ -182,7 +176,7 @@ func getHandlers() []pipeline.Handler { } } -func getSecret(ctx pipeline.Context, ns string) *corev1.Secret { +func createSecret(ctx pipeline.Context, ns string) *corev1.Secret { name := ctx.BindingSecretName() items := ctx.BindingItems() data := items.AsMap()