diff --git a/cmd/broker/provisioning.go b/cmd/broker/provisioning.go index e5af15364f..8f094b461a 100644 --- a/cmd/broker/provisioning.go +++ b/cmd/broker/provisioning.go @@ -126,7 +126,7 @@ func NewProvisioningProcessingQueue(ctx context.Context, provisionManager *proce }, { // TODO: this step must be removed when kubeconfig is created by IM only stage: createRuntimeStageName, - step: provisioning.NewGetKubeconfigStep(db.Operations(), provisionerClient), + step: provisioning.NewGetKubeconfigStep(db.Operations(), provisionerClient, cfg.Broker.KimConfig), }, { // TODO: this step must be removed when kubeconfig is created by IM and own_cluster plan is permanently removed disabled: cfg.LifecycleManagerIntegrationDisabled, diff --git a/internal/process/provisioning/get_kubeconfig_step.go b/internal/process/provisioning/get_kubeconfig_step.go index 080afa1712..d6a9017fc0 100644 --- a/internal/process/provisioning/get_kubeconfig_step.go +++ b/internal/process/provisioning/get_kubeconfig_step.go @@ -1,6 +1,7 @@ package provisioning import ( + "github.com/kyma-project/kyma-environment-broker/internal/kim" "time" "github.com/kyma-project/kyma-environment-broker/internal/broker" @@ -16,13 +17,16 @@ type GetKubeconfigStep struct { provisionerClient provisioner.Client operationManager *process.OperationManager provisioningTimeout time.Duration + kimConfig kim.Config } func NewGetKubeconfigStep(os storage.Operations, - provisionerClient provisioner.Client) *GetKubeconfigStep { + provisionerClient provisioner.Client, + kimConfig kim.Config) *GetKubeconfigStep { return &GetKubeconfigStep{ provisionerClient: provisionerClient, operationManager: process.NewOperationManager(os), + kimConfig: kimConfig, } } @@ -34,6 +38,11 @@ func (s *GetKubeconfigStep) Name() string { func (s *GetKubeconfigStep) Run(operation internal.Operation, log logrus.FieldLogger) (internal.Operation, time.Duration, error) { + if s.kimConfig.IsDrivenByKimOnly(broker.PlanNamesMapping[operation.ProvisioningParameters.PlanID]) { + log.Infof("KIM is driving the process for plan %s, skipping", broker.PlanNamesMapping[operation.ProvisioningParameters.PlanID]) + return operation, 0, nil + } + if operation.Kubeconfig == "" { if broker.IsOwnClusterPlan(operation.ProvisioningParameters.PlanID) { operation.Kubeconfig = operation.ProvisioningParameters.Parameters.Kubeconfig diff --git a/internal/process/provisioning/get_kubeconfig_test.go b/internal/process/provisioning/get_kubeconfig_test.go index 36a7c8a5a9..7bc90dca75 100644 --- a/internal/process/provisioning/get_kubeconfig_test.go +++ b/internal/process/provisioning/get_kubeconfig_test.go @@ -1,6 +1,7 @@ package provisioning import ( + "github.com/kyma-project/kyma-environment-broker/internal/kim" "testing" "github.com/kyma-project/kyma-environment-broker/internal" @@ -21,6 +22,11 @@ const ( ) func TestGetKubeconfigStep(t *testing.T) { + + kimConfig := kim.Config{ + Enabled: false, + } + t.Run("should create k8s client using kubeconfig from RuntimeStatus", func(t *testing.T) { // given st := storage.NewMemoryStorage() @@ -29,7 +35,7 @@ func TestGetKubeconfigStep(t *testing.T) { scheme := internal.NewSchemeForTests(t) err := apiextensionsv1.AddToScheme(scheme) - step := NewGetKubeconfigStep(st.Operations(), provisionerClient) + step := NewGetKubeconfigStep(st.Operations(), provisionerClient, kimConfig) operation := fixture.FixProvisioningOperation("operation-id", "inst-id") operation.Kubeconfig = "" err = st.Operations().InsertOperation(operation) @@ -56,7 +62,7 @@ func TestGetKubeconfigStep(t *testing.T) { scheme := internal.NewSchemeForTests(t) err := apiextensionsv1.AddToScheme(scheme) - step := NewGetKubeconfigStep(st.Operations(), nil) + step := NewGetKubeconfigStep(st.Operations(), nil, kimConfig) operation := fixture.FixProvisioningOperation("operation-id", "inst-id") operation.Kubeconfig = "" operation.ProvisioningParameters.Parameters.Kubeconfig = kubeconfigContentsFromParameters @@ -79,7 +85,7 @@ func TestGetKubeconfigStep(t *testing.T) { scheme := internal.NewSchemeForTests(t) err := apiextensionsv1.AddToScheme(scheme) - step := NewGetKubeconfigStep(st.Operations(), nil) + step := NewGetKubeconfigStep(st.Operations(), nil, kimConfig) operation := fixture.FixProvisioningOperation("operation-id", "inst-id") operation.Kubeconfig = kubeconfigFromPreviousOperation operation.ProvisioningParameters.Parameters.Kubeconfig = "" @@ -102,7 +108,7 @@ func TestGetKubeconfigStep(t *testing.T) { scheme := internal.NewSchemeForTests(t) err := apiextensionsv1.AddToScheme(scheme) - step := NewGetKubeconfigStep(st.Operations(), provisionerClient) + step := NewGetKubeconfigStep(st.Operations(), provisionerClient, kimConfig) operation := fixture.FixProvisioningOperation("operation-id", "inst-id") operation.Kubeconfig = "" operation.RuntimeID = ""