This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/master by this push: new 260f8dd Don't wait for initial kit to be ready to declare the platform ready #795 260f8dd is described below commit 260f8ddf0a1d33300269ac65b2fdbb1f937eb3a0 Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Tue Jul 2 15:24:01 2019 +0200 Don't wait for initial kit to be ready to declare the platform ready #795 --- .../camel/v1alpha1/integrationplatform_types.go | 2 - pkg/controller/integrationplatform/create.go | 2 +- .../integrationplatform_controller.go | 1 - pkg/controller/integrationplatform/start.go | 86 ---------------------- 4 files changed, 1 insertion(+), 90 deletions(-) diff --git a/pkg/apis/camel/v1alpha1/integrationplatform_types.go b/pkg/apis/camel/v1alpha1/integrationplatform_types.go index 1cf959d..fa52d43 100644 --- a/pkg/apis/camel/v1alpha1/integrationplatform_types.go +++ b/pkg/apis/camel/v1alpha1/integrationplatform_types.go @@ -143,8 +143,6 @@ const ( IntegrationPlatformPhaseCreating IntegrationPlatformPhase = "Creating" // IntegrationPlatformPhaseWarming -- IntegrationPlatformPhaseWarming IntegrationPlatformPhase = "Warming" - // IntegrationPlatformPhaseStarting -- - IntegrationPlatformPhaseStarting IntegrationPlatformPhase = "Starting" // IntegrationPlatformPhaseReady -- IntegrationPlatformPhaseReady IntegrationPlatformPhase = "Ready" // IntegrationPlatformPhaseError -- diff --git a/pkg/controller/integrationplatform/create.go b/pkg/controller/integrationplatform/create.go index 2e2bfa5..5fccaa7 100644 --- a/pkg/controller/integrationplatform/create.go +++ b/pkg/controller/integrationplatform/create.go @@ -80,7 +80,7 @@ func (action *createAction) Handle(ctx context.Context, platform *v1alpha1.Integ } } - platform.Status.Phase = v1alpha1.IntegrationPlatformPhaseStarting + platform.Status.Phase = v1alpha1.IntegrationPlatformPhaseReady return platform, nil } diff --git a/pkg/controller/integrationplatform/integrationplatform_controller.go b/pkg/controller/integrationplatform/integrationplatform_controller.go index cc3e1dd..49f5bb4 100644 --- a/pkg/controller/integrationplatform/integrationplatform_controller.go +++ b/pkg/controller/integrationplatform/integrationplatform_controller.go @@ -129,7 +129,6 @@ func (r *ReconcileIntegrationPlatform) Reconcile(request reconcile.Request) (rec NewInitializeAction(), NewWarmAction(), NewCreateAction(), - NewStartAction(), } var targetPhase camelv1alpha1.IntegrationPlatformPhase diff --git a/pkg/controller/integrationplatform/start.go b/pkg/controller/integrationplatform/start.go deleted file mode 100644 index 6d46126..0000000 --- a/pkg/controller/integrationplatform/start.go +++ /dev/null @@ -1,86 +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 integrationplatform - -import ( - "context" - - "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "k8s.io/apimachinery/pkg/labels" - k8sclient "sigs.k8s.io/controller-runtime/pkg/client" -) - -// NewStartAction returns a action that waits for all required platform resources to start -func NewStartAction() Action { - return &startAction{} -} - -type startAction struct { - baseAction -} - -func (action *startAction) Name() string { - return "start" -} - -func (action *startAction) CanHandle(platform *v1alpha1.IntegrationPlatform) bool { - return platform.Status.Phase == v1alpha1.IntegrationPlatformPhaseStarting || platform.Status.Phase == v1alpha1.IntegrationPlatformPhaseError -} - -func (action *startAction) Handle(ctx context.Context, platform *v1alpha1.IntegrationPlatform) (*v1alpha1.IntegrationPlatform, error) { - aggregatePhase, err := action.aggregatePlatformPhaseFromContexts(ctx, platform.Namespace) - if err != nil { - return nil, err - } - - if platform.Status.Phase != aggregatePhase { - platform.Status.Phase = aggregatePhase - return platform, nil - } - - // wait - return nil, nil -} - -func (action *startAction) aggregatePlatformPhaseFromContexts(ctx context.Context, namespace string) (v1alpha1.IntegrationPlatformPhase, error) { - ctxs := v1alpha1.NewIntegrationKitList() - options := k8sclient.ListOptions{ - LabelSelector: labels.SelectorFromSet(labels.Set{ - "camel.apache.org/kit.type": "platform", - }), - Namespace: namespace, - } - if err := action.client.List(ctx, &options, &ctxs); err != nil { - return "", err - } - - countReady := 0 - for _, ctx := range ctxs.Items { - if ctx.Status.Phase == v1alpha1.IntegrationKitPhaseError { - return v1alpha1.IntegrationPlatformPhaseError, nil - } else if ctx.Status.Phase == v1alpha1.IntegrationKitPhaseReady { - countReady++ - } - } - - if countReady < len(ctxs.Items) { - return v1alpha1.IntegrationPlatformPhaseStarting, nil - } - - return v1alpha1.IntegrationPlatformPhaseReady, nil -}