Skip to content

Commit

Permalink
KIM Integration - Skipping Get_Kubeconfig step for KIM driven plans (
Browse files Browse the repository at this point in the history
…#1053)

* Skipping get kubeconfig step for KIM driven plans

* go imports

* timeout increased
  • Loading branch information
jaroslaw-pieszka authored Aug 22, 2024
1 parent eda7925 commit a6a27b2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GOLINT_VER = v1.55.2
ifeq (,$(GOLINT_TIMEOUT))
GOLINT_TIMEOUT=1m
GOLINT_TIMEOUT=2m
endif

## The headers are represented by '##@' like 'General' and the descriptions of given command is text after '##''.
Expand Down
2 changes: 1 addition & 1 deletion cmd/broker/provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 11 additions & 1 deletion internal/process/provisioning/get_kubeconfig_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package provisioning
import (
"time"

"github.com/kyma-project/kyma-environment-broker/internal/kim"

"github.com/kyma-project/kyma-environment-broker/internal/broker"
"github.com/sirupsen/logrus"

Expand All @@ -16,13 +18,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,
}
}

Expand All @@ -34,6 +39,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
Expand Down
15 changes: 11 additions & 4 deletions internal/process/provisioning/get_kubeconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package provisioning
import (
"testing"

"github.com/kyma-project/kyma-environment-broker/internal/kim"

"github.com/kyma-project/kyma-environment-broker/internal"
"github.com/kyma-project/kyma-environment-broker/internal/broker"
"github.com/kyma-project/kyma-environment-broker/internal/fixture"
Expand All @@ -21,6 +23,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()
Expand All @@ -29,7 +36,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)
Expand All @@ -56,7 +63,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
Expand All @@ -79,7 +86,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 = ""
Expand All @@ -102,7 +109,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 = ""
Expand Down

0 comments on commit a6a27b2

Please sign in to comment.