From 9f593eb9e08a81dabebc035d4e69735a58e341df Mon Sep 17 00:00:00 2001 From: ukff <110393214+ukff@users.noreply.github.com> Date: Tue, 3 Dec 2024 08:50:48 +0100 Subject: [PATCH] wip --- .../deprovisioning/btp_operator_cleanup.go | 5 +++-- .../check_gardenercluster_deleted_step.go | 9 ++++++--- .../check_kyma_resource_deleted_step.go | 7 +++++-- .../deprovisioning/check_runtime_removal_step.go | 7 +++++-- .../check_runtime_resource_deletion_step.go | 7 +++++-- .../deprovisioning/delete_gardener_cluster.go | 11 +++++++---- .../deprovisioning/delete_kyma_resource_step.go | 13 ++++++++----- .../delete_runtime_resource_step.go | 9 ++++++--- .../process/deprovisioning/edp_deregistration.go | 13 +++++++------ internal/process/deprovisioning/init.go | 7 +++++-- .../deprovisioning/release_subscription_step.go | 11 +++++++---- .../deprovisioning/remove_instance_step.go | 7 +++++-- .../process/deprovisioning/remove_runtime.go | 7 +++++-- internal/process/operation_manager.go | 6 +----- internal/process/operation_manager_test.go | 14 +++++++------- internal/process/provisioning/apply_kyma_step.go | 2 +- .../process/provisioning/check_runtime_step.go | 2 +- .../provisioning/create_resource_names_step.go | 8 +++++--- .../provisioning/create_runtime_resource_step.go | 7 +++++-- .../create_runtime_without_kyma_step.go | 2 +- .../process/provisioning/edp_registration.go | 2 +- .../provisioning/generate_runtime_id_step.go | 9 ++++++--- .../process/provisioning/get_kubeconfig_step.go | 7 +++++-- internal/process/provisioning/initialisation.go | 9 +++++---- .../inject_btp_operator_credentials_step.go | 5 +++-- .../provisioning/override_kyma_modules.go | 6 +++++- internal/process/provisioning/resolve_creds.go | 11 +++++++---- internal/process/provisioning/start_step.go | 5 +++-- internal/process/staged_manager.go | 2 +- internal/process/steps/gardener_cluster.go | 16 ++++++++++------ internal/process/steps/kyma_template.go | 6 +++++- .../steps/lifecycle_manager_kubeconfig.go | 10 ++++++++-- internal/process/steps/runtime_resource.go | 7 +++++-- internal/process/update/check_step.go | 7 +++++-- internal/process/update/initialisation_step.go | 5 +++-- internal/process/update/update_runtime_step.go | 11 +++++++---- internal/process/update/upgrade_shoot_step.go | 7 +++++-- 37 files changed, 179 insertions(+), 100 deletions(-) diff --git a/internal/process/deprovisioning/btp_operator_cleanup.go b/internal/process/deprovisioning/btp_operator_cleanup.go index 88ad45e07e..5a66e08e73 100644 --- a/internal/process/deprovisioning/btp_operator_cleanup.go +++ b/internal/process/deprovisioning/btp_operator_cleanup.go @@ -41,10 +41,11 @@ type BTPOperatorCleanupStep struct { } func NewBTPOperatorCleanupStep(os storage.Operations, k8sClientProvider K8sClientProvider) *BTPOperatorCleanupStep { - return &BTPOperatorCleanupStep{ - operationManager: process.NewOperationManager(os), + step := &BTPOperatorCleanupStep{ k8sClientProvider: k8sClientProvider, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *BTPOperatorCleanupStep) Name() string { diff --git a/internal/process/deprovisioning/check_gardenercluster_deleted_step.go b/internal/process/deprovisioning/check_gardenercluster_deleted_step.go index 253accf1e1..28502c4478 100644 --- a/internal/process/deprovisioning/check_gardenercluster_deleted_step.go +++ b/internal/process/deprovisioning/check_gardenercluster_deleted_step.go @@ -4,6 +4,8 @@ import ( "context" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "k8s.io/apimachinery/pkg/api/meta" "github.com/kyma-project/kyma-environment-broker/internal/process/steps" @@ -25,10 +27,11 @@ type CheckGardenerClusterDeletedStep struct { } func NewCheckGardenerClusterDeletedStep(operations storage.Operations, kcpClient client.Client) *CheckGardenerClusterDeletedStep { - return &CheckGardenerClusterDeletedStep{ - operationManager: process.NewOperationManager(operations), - kcpClient: kcpClient, + step := &CheckGardenerClusterDeletedStep{ + kcpClient: kcpClient, } + step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet) + return step } func (step *CheckGardenerClusterDeletedStep) Name() string { diff --git a/internal/process/deprovisioning/check_kyma_resource_deleted_step.go b/internal/process/deprovisioning/check_kyma_resource_deleted_step.go index 66a9aff907..ad2633ba3a 100644 --- a/internal/process/deprovisioning/check_kyma_resource_deleted_step.go +++ b/internal/process/deprovisioning/check_kyma_resource_deleted_step.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/process/steps" "k8s.io/apimachinery/pkg/api/errors" @@ -25,11 +27,12 @@ type CheckKymaResourceDeletedStep struct { } func NewCheckKymaResourceDeletedStep(operations storage.Operations, kcpClient client.Client, kymaResourceDeletionTimeout time.Duration) *CheckKymaResourceDeletedStep { - return &CheckKymaResourceDeletedStep{ - operationManager: process.NewOperationManager(operations), + step := &CheckKymaResourceDeletedStep{ kcpClient: kcpClient, kymaResourceDeletionTimeout: kymaResourceDeletionTimeout, } + step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet) + return step } func (step *CheckKymaResourceDeletedStep) Name() string { diff --git a/internal/process/deprovisioning/check_runtime_removal_step.go b/internal/process/deprovisioning/check_runtime_removal_step.go index c992531970..6a3d0bf689 100644 --- a/internal/process/deprovisioning/check_runtime_removal_step.go +++ b/internal/process/deprovisioning/check_runtime_removal_step.go @@ -4,6 +4,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/storage/dberr" "github.com/kyma-project/control-plane/components/provisioner/pkg/gqlschema" @@ -25,12 +27,13 @@ var _ process.Step = &CheckRuntimeRemovalStep{} func NewCheckRuntimeRemovalStep(operations storage.Operations, instances storage.Instances, provisionerClient provisioner.Client, timeout time.Duration) *CheckRuntimeRemovalStep { - return &CheckRuntimeRemovalStep{ - operationManager: process.NewOperationManager(operations), + step := &CheckRuntimeRemovalStep{ provisionerClient: provisionerClient, instanceStorage: instances, timeout: timeout, } + step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet) + return step } func (s *CheckRuntimeRemovalStep) Name() string { diff --git a/internal/process/deprovisioning/check_runtime_resource_deletion_step.go b/internal/process/deprovisioning/check_runtime_resource_deletion_step.go index 6689095675..0d6aa693ee 100644 --- a/internal/process/deprovisioning/check_runtime_resource_deletion_step.go +++ b/internal/process/deprovisioning/check_runtime_resource_deletion_step.go @@ -4,6 +4,8 @@ import ( "context" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + imv1 "github.com/kyma-project/infrastructure-manager/api/v1" "github.com/kyma-project/kyma-environment-broker/internal" "github.com/kyma-project/kyma-environment-broker/internal/process" @@ -22,11 +24,12 @@ type CheckRuntimeResourceDeletionStep struct { } func NewCheckRuntimeResourceDeletionStep(operations storage.Operations, kcpClient client.Client, checkRuntimeResourceDeletionStepTimeout time.Duration) *CheckRuntimeResourceDeletionStep { - return &CheckRuntimeResourceDeletionStep{ - operationManager: process.NewOperationManager(operations), + step := &CheckRuntimeResourceDeletionStep{ kcpClient: kcpClient, checkRuntimeResourceDeletionStepTimeout: checkRuntimeResourceDeletionStepTimeout, } + step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet) + return step } func (step *CheckRuntimeResourceDeletionStep) Name() string { diff --git a/internal/process/deprovisioning/delete_gardener_cluster.go b/internal/process/deprovisioning/delete_gardener_cluster.go index 890e3497bb..3b15acc3b4 100644 --- a/internal/process/deprovisioning/delete_gardener_cluster.go +++ b/internal/process/deprovisioning/delete_gardener_cluster.go @@ -4,6 +4,8 @@ import ( "context" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "k8s.io/apimachinery/pkg/api/meta" "github.com/kyma-project/kyma-environment-broker/internal/process/steps" @@ -24,11 +26,12 @@ type DeleteGardenerClusterStep struct { } func NewDeleteGardenerClusterStep(operations storage.Operations, kcpClient client.Client, instances storage.Instances) *DeleteGardenerClusterStep { - return &DeleteGardenerClusterStep{ - operationManager: process.NewOperationManager(operations), - kcpClient: kcpClient, - instances: instances, + step := &DeleteGardenerClusterStep{ + kcpClient: kcpClient, + instances: instances, } + step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.KEBDependency) + return step } func (step *DeleteGardenerClusterStep) Name() string { diff --git a/internal/process/deprovisioning/delete_kyma_resource_step.go b/internal/process/deprovisioning/delete_kyma_resource_step.go index 78191f4f8d..71ac74781d 100644 --- a/internal/process/deprovisioning/delete_kyma_resource_step.go +++ b/internal/process/deprovisioning/delete_kyma_resource_step.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/broker" "github.com/kyma-project/kyma-environment-broker/internal/process/input" @@ -34,12 +36,13 @@ type DeleteKymaResourceStep struct { } func NewDeleteKymaResourceStep(operations storage.Operations, instances storage.Instances, kcpClient client.Client, configProvider input.ConfigurationProvider) *DeleteKymaResourceStep { - return &DeleteKymaResourceStep{ - operationManager: process.NewOperationManager(operations), - kcpClient: kcpClient, - configProvider: configProvider, - instances: instances, + step := &DeleteKymaResourceStep{ + kcpClient: kcpClient, + configProvider: configProvider, + instances: instances, } + step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet) + return step } func (step *DeleteKymaResourceStep) Name() string { diff --git a/internal/process/deprovisioning/delete_runtime_resource_step.go b/internal/process/deprovisioning/delete_runtime_resource_step.go index 3569befd5f..25450f5693 100644 --- a/internal/process/deprovisioning/delete_runtime_resource_step.go +++ b/internal/process/deprovisioning/delete_runtime_resource_step.go @@ -4,6 +4,8 @@ import ( "context" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/ptr" "github.com/kyma-project/kyma-environment-broker/internal/process/steps" @@ -29,10 +31,11 @@ type DeleteRuntimeResourceStep struct { } func NewDeleteRuntimeResourceStep(operations storage.Operations, kcpClient client.Client) *DeleteRuntimeResourceStep { - return &DeleteRuntimeResourceStep{ - operationManager: process.NewOperationManager(operations), - kcpClient: kcpClient, + step := &DeleteRuntimeResourceStep{ + kcpClient: kcpClient, } + step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet) + return step } func (step *DeleteRuntimeResourceStep) Name() string { diff --git a/internal/process/deprovisioning/edp_deregistration.go b/internal/process/deprovisioning/edp_deregistration.go index 7fbfb90d90..80e711765a 100644 --- a/internal/process/deprovisioning/edp_deregistration.go +++ b/internal/process/deprovisioning/edp_deregistration.go @@ -34,13 +34,14 @@ type InstanceOperationStorage interface { } func NewEDPDeregistrationStep(os storage.Operations, is storage.Instances, client EDPClient, config edp.Config) *EDPDeregistrationStep { - return &EDPDeregistrationStep{ - operationManager: process.NewOperationManager(os), - client: client, - config: config, - dbOperations: os, - dbInstances: is, + step := &EDPDeregistrationStep{ + client: client, + config: config, + dbOperations: os, + dbInstances: is, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.EDPDependency) + return step } func (s *EDPDeregistrationStep) Name() string { diff --git a/internal/process/deprovisioning/init.go b/internal/process/deprovisioning/init.go index 563c433b5a..7bb75658ac 100644 --- a/internal/process/deprovisioning/init.go +++ b/internal/process/deprovisioning/init.go @@ -4,6 +4,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/common/orchestration" "github.com/kyma-project/kyma-environment-broker/internal" "github.com/kyma-project/kyma-environment-broker/internal/process" @@ -21,12 +23,13 @@ type InitStep struct { } func NewInitStep(operations storage.Operations, instances storage.Instances, operationTimeout time.Duration) *InitStep { - return &InitStep{ - operationManager: process.NewOperationManager(operations), + step := &InitStep{ operationTimeout: operationTimeout, operationStorage: operations, instanceStorage: instances, } + step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet) + return step } func (s *InitStep) Name() string { diff --git a/internal/process/deprovisioning/release_subscription_step.go b/internal/process/deprovisioning/release_subscription_step.go index 601329842f..1282e35cab 100644 --- a/internal/process/deprovisioning/release_subscription_step.go +++ b/internal/process/deprovisioning/release_subscription_step.go @@ -4,6 +4,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/euaccess" "github.com/kyma-project/kyma-environment-broker/common/hyperscaler" @@ -25,11 +27,12 @@ type ReleaseSubscriptionStep struct { var _ process.Step = &ReleaseSubscriptionStep{} func NewReleaseSubscriptionStep(os storage.Operations, instanceStorage storage.Instances, accountProvider hyperscaler.AccountProvider) ReleaseSubscriptionStep { - return ReleaseSubscriptionStep{ - operationManager: process.NewOperationManager(os), - instanceStorage: instanceStorage, - accountProvider: accountProvider, + step := ReleaseSubscriptionStep{ + instanceStorage: instanceStorage, + accountProvider: accountProvider, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s ReleaseSubscriptionStep) Name() string { diff --git a/internal/process/deprovisioning/remove_instance_step.go b/internal/process/deprovisioning/remove_instance_step.go index 89e11ae9ea..86eaefc482 100644 --- a/internal/process/deprovisioning/remove_instance_step.go +++ b/internal/process/deprovisioning/remove_instance_step.go @@ -4,6 +4,8 @@ import ( "strings" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/storage/dberr" "github.com/kyma-project/kyma-environment-broker/internal/process" @@ -23,11 +25,12 @@ type RemoveInstanceStep struct { var _ process.Step = &RemoveInstanceStep{} func NewRemoveInstanceStep(instanceStorage storage.Instances, operationStorage storage.Operations) *RemoveInstanceStep { - return &RemoveInstanceStep{ - operationManager: process.NewOperationManager(operationStorage), + step := &RemoveInstanceStep{ instanceStorage: instanceStorage, operationStorage: operationStorage, } + step.operationManager = process.NewOperationManager(operationStorage, step.Name(), kebError.NotSet) + return step } func (s *RemoveInstanceStep) Name() string { diff --git a/internal/process/deprovisioning/remove_runtime.go b/internal/process/deprovisioning/remove_runtime.go index b20a5c928b..e03c456e07 100644 --- a/internal/process/deprovisioning/remove_runtime.go +++ b/internal/process/deprovisioning/remove_runtime.go @@ -4,6 +4,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/storage/dberr" "github.com/kyma-project/kyma-environment-broker/internal/broker" @@ -24,12 +26,13 @@ type RemoveRuntimeStep struct { } func NewRemoveRuntimeStep(os storage.Operations, is storage.Instances, cli provisioner.Client, provisionerTimeout time.Duration) *RemoveRuntimeStep { - return &RemoveRuntimeStep{ - operationManager: process.NewOperationManager(os), + step := &RemoveRuntimeStep{ instanceStorage: is, provisionerClient: cli, provisionerTimeout: provisionerTimeout, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *RemoveRuntimeStep) Name() string { diff --git a/internal/process/operation_manager.go b/internal/process/operation_manager.go index 4272912241..a6a5496f3a 100644 --- a/internal/process/operation_manager.go +++ b/internal/process/operation_manager.go @@ -19,11 +19,7 @@ type OperationManager struct { step string } -func NewOperationManager(storage storage.Operations) *OperationManager { - return &OperationManager{storage: storage} -} - -func NewOperationManagerWithMetadata(storage storage.Operations, step string, component kebErr.Component) *OperationManager { +func NewOperationManager(storage storage.Operations, step string, component kebErr.Component) *OperationManager { return &OperationManager{storage: storage, component: component, step: step} } diff --git a/internal/process/operation_manager_test.go b/internal/process/operation_manager_test.go index b9c9dec777..2e99f25b0d 100644 --- a/internal/process/operation_manager_test.go +++ b/internal/process/operation_manager_test.go @@ -18,7 +18,7 @@ func Test_OperationManager_RetryOperationOnce(t *testing.T) { // given memory := storage.NewMemoryStorage() operations := memory.Operations() - opManager := NewOperationManager(operations) + opManager := NewOperationManager(operations, "some_step", kebErr.ProvisionerDependency) op := internal.Operation{} op.UpdatedAt = time.Now() retryInterval := time.Hour @@ -50,7 +50,7 @@ func Test_OperationManager_RetryOperation(t *testing.T) { // given memory := storage.NewMemoryStorage() operations := memory.Operations() - opManager := NewOperationManager(operations) + opManager := NewOperationManager(operations, "some_step", kebErr.NotSet) op := internal.Operation{} op.UpdatedAt = time.Now() retryInterval := time.Hour @@ -84,7 +84,7 @@ func Test_OperationManager_LastError(t *testing.T) { t.Run("when all last error field set with 1 component v1", func(t *testing.T) { memory := storage.NewMemoryStorage() operations := memory.Operations() - opManager := NewOperationManagerWithMetadata(operations, "some_step", kebErr.ProvisionerDependency) + opManager := NewOperationManager(operations, "some_step", kebErr.ProvisionerDependency) op := internal.Operation{} err := operations.InsertOperation(op) require.NoError(t, err) @@ -98,7 +98,7 @@ func Test_OperationManager_LastError(t *testing.T) { t.Run("when all last error field set with 1 components v2", func(t *testing.T) { memory := storage.NewMemoryStorage() operations := memory.Operations() - opManager := NewOperationManagerWithMetadata(operations, "some_step", kebErr.KebDbDependency) + opManager := NewOperationManager(operations, "some_step", kebErr.KebDbDependency) op := internal.Operation{} err := operations.InsertOperation(op) require.NoError(t, err) @@ -112,7 +112,7 @@ func Test_OperationManager_LastError(t *testing.T) { t.Run("when no error passed", func(t *testing.T) { memory := storage.NewMemoryStorage() operations := memory.Operations() - opManager := NewOperationManagerWithMetadata(operations, "some_step", kebErr.ProvisionerDependency) + opManager := NewOperationManager(operations, "some_step", kebErr.ProvisionerDependency) op := internal.Operation{} err := operations.InsertOperation(op) require.NoError(t, err) @@ -126,7 +126,7 @@ func Test_OperationManager_LastError(t *testing.T) { t.Run("when no description passed", func(t *testing.T) { memory := storage.NewMemoryStorage() operations := memory.Operations() - opManager := NewOperationManagerWithMetadata(operations, "some_step", kebErr.ProvisionerDependency) + opManager := NewOperationManager(operations, "some_step", kebErr.ProvisionerDependency) op := internal.Operation{} err := operations.InsertOperation(op) require.NoError(t, err) @@ -140,7 +140,7 @@ func Test_OperationManager_LastError(t *testing.T) { t.Run("when no description and no err passed", func(t *testing.T) { memory := storage.NewMemoryStorage() operations := memory.Operations() - opManager := NewOperationManagerWithMetadata(operations, "some_step", kebErr.ReconcileDependency) + opManager := NewOperationManager(operations, "some_step", kebErr.ReconcileDependency) op := internal.Operation{} err := operations.InsertOperation(op) require.NoError(t, err) diff --git a/internal/process/provisioning/apply_kyma_step.go b/internal/process/provisioning/apply_kyma_step.go index eb81b89786..0047d7d874 100644 --- a/internal/process/provisioning/apply_kyma_step.go +++ b/internal/process/provisioning/apply_kyma_step.go @@ -31,7 +31,7 @@ var _ process.Step = &ApplyKymaStep{} func NewApplyKymaStep(os storage.Operations, cli client.Client) *ApplyKymaStep { step := &ApplyKymaStep{k8sClient: cli} - step.operationManager = process.NewOperationManagerWithMetadata(os, step.Name(), kebErr.LifeCycleManagerDependency) + step.operationManager = process.NewOperationManager(os, step.Name(), kebErr.LifeCycleManagerDependency) return step } diff --git a/internal/process/provisioning/check_runtime_step.go b/internal/process/provisioning/check_runtime_step.go index 494306471b..e62ac18f6d 100644 --- a/internal/process/provisioning/check_runtime_step.go +++ b/internal/process/provisioning/check_runtime_step.go @@ -34,7 +34,7 @@ func NewCheckRuntimeStep(os storage.Operations, provisioningTimeout: provisioningTimeout, kimConfig: kimConfig, } - step.operationManager = process.NewOperationManagerWithMetadata(os, step.Name(), kebError.ProvisionerDependency) + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.ProvisionerDependency) return step } diff --git a/internal/process/provisioning/create_resource_names_step.go b/internal/process/provisioning/create_resource_names_step.go index d63594964a..8e036ad380 100644 --- a/internal/process/provisioning/create_resource_names_step.go +++ b/internal/process/provisioning/create_resource_names_step.go @@ -4,6 +4,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/process/steps" "github.com/kyma-project/kyma-environment-broker/internal" @@ -17,9 +19,9 @@ type CreateResourceNamesStep struct { } func NewCreateResourceNamesStep(os storage.Operations) *CreateResourceNamesStep { - return &CreateResourceNamesStep{ - operationManager: process.NewOperationManager(os), - } + step := &CreateResourceNamesStep{} + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *CreateResourceNamesStep) Name() string { diff --git a/internal/process/provisioning/create_runtime_resource_step.go b/internal/process/provisioning/create_runtime_resource_step.go index e2a63d0e43..f8024ec9d7 100644 --- a/internal/process/provisioning/create_runtime_resource_step.go +++ b/internal/process/provisioning/create_runtime_resource_step.go @@ -6,6 +6,8 @@ import ( "strconv" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/storage/dberr" "github.com/kyma-project/kyma-environment-broker/internal/customresources" @@ -50,8 +52,7 @@ type CreateRuntimeResourceStep struct { func NewCreateRuntimeResourceStep(os storage.Operations, is storage.Instances, k8sClient client.Client, kimConfig broker.KimConfig, cfg input.Config, trialPlatformRegionMapping map[string]string, useSmallerMachines bool, oidcDefaultValues pkg.OIDCConfigDTO) *CreateRuntimeResourceStep { - return &CreateRuntimeResourceStep{ - operationManager: process.NewOperationManager(os), + step := &CreateRuntimeResourceStep{ instanceStorage: is, kimConfig: kimConfig, k8sClient: k8sClient, @@ -60,6 +61,8 @@ func NewCreateRuntimeResourceStep(os storage.Operations, is storage.Instances, k useSmallerMachineTypes: useSmallerMachines, oidcDefaultValues: oidcDefaultValues, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *CreateRuntimeResourceStep) Name() string { diff --git a/internal/process/provisioning/create_runtime_without_kyma_step.go b/internal/process/provisioning/create_runtime_without_kyma_step.go index 17163f1ffe..e9390ec7f9 100644 --- a/internal/process/provisioning/create_runtime_without_kyma_step.go +++ b/internal/process/provisioning/create_runtime_without_kyma_step.go @@ -38,7 +38,7 @@ func NewCreateRuntimeWithoutKymaStep(os storage.Operations, runtimeStorage stora runtimeStateStorage: runtimeStorage, kimConfig: kimConfig, } - step.operationManager = process.NewOperationManagerWithMetadata(os, step.Name(), kebError.ProvisionerDependency) + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.ProvisionerDependency) return step } diff --git a/internal/process/provisioning/edp_registration.go b/internal/process/provisioning/edp_registration.go index 90e7588b73..d8cb148109 100644 --- a/internal/process/provisioning/edp_registration.go +++ b/internal/process/provisioning/edp_registration.go @@ -36,7 +36,7 @@ func NewEDPRegistrationStep(os storage.Operations, client EDPClient, config edp. client: client, config: config, } - step.operationManager = process.NewOperationManagerWithMetadata(os, step.Name(), kebError.EDPDependency) + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.EDPDependency) return step } diff --git a/internal/process/provisioning/generate_runtime_id_step.go b/internal/process/provisioning/generate_runtime_id_step.go index fa6669fa6b..ed700e4c2b 100644 --- a/internal/process/provisioning/generate_runtime_id_step.go +++ b/internal/process/provisioning/generate_runtime_id_step.go @@ -3,6 +3,8 @@ package provisioning import ( "fmt" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/google/uuid" "time" @@ -20,10 +22,11 @@ type GenerateRuntimeIDStep struct { } func NewGenerateRuntimeIDStep(os storage.Operations, is storage.Instances) *GenerateRuntimeIDStep { - return &GenerateRuntimeIDStep{ - operationManager: process.NewOperationManager(os), - instanceStorage: is, + step := &GenerateRuntimeIDStep{ + instanceStorage: is, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *GenerateRuntimeIDStep) Name() string { diff --git a/internal/process/provisioning/get_kubeconfig_step.go b/internal/process/provisioning/get_kubeconfig_step.go index a8e7a8ff81..a62ecda740 100644 --- a/internal/process/provisioning/get_kubeconfig_step.go +++ b/internal/process/provisioning/get_kubeconfig_step.go @@ -3,6 +3,8 @@ package provisioning import ( "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/broker" "github.com/sirupsen/logrus" @@ -22,11 +24,12 @@ type GetKubeconfigStep struct { func NewGetKubeconfigStep(os storage.Operations, provisionerClient provisioner.Client, kimConfig broker.KimConfig) *GetKubeconfigStep { - return &GetKubeconfigStep{ + step := &GetKubeconfigStep{ provisionerClient: provisionerClient, - operationManager: process.NewOperationManager(os), kimConfig: kimConfig, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } var _ process.Step = (*GetKubeconfigStep)(nil) diff --git a/internal/process/provisioning/initialisation.go b/internal/process/provisioning/initialisation.go index f6c06996c8..2209c1dbe9 100644 --- a/internal/process/provisioning/initialisation.go +++ b/internal/process/provisioning/initialisation.go @@ -36,11 +36,12 @@ type InitialisationStep struct { } func NewInitialisationStep(os storage.Operations, is storage.Instances, b input.CreatorForPlan) *InitialisationStep { - return &InitialisationStep{ - operationManager: process.NewOperationManager(os), - inputBuilder: b, - instanceStorage: is, + step := &InitialisationStep{ + inputBuilder: b, + instanceStorage: is, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *InitialisationStep) Name() string { diff --git a/internal/process/provisioning/inject_btp_operator_credentials_step.go b/internal/process/provisioning/inject_btp_operator_credentials_step.go index e523119197..ef316cebe0 100644 --- a/internal/process/provisioning/inject_btp_operator_credentials_step.go +++ b/internal/process/provisioning/inject_btp_operator_credentials_step.go @@ -30,10 +30,11 @@ type InjectBTPOperatorCredentialsStep struct { } func NewInjectBTPOperatorCredentialsStep(os storage.Operations, k8sClientProvider K8sClientProvider) *InjectBTPOperatorCredentialsStep { - return &InjectBTPOperatorCredentialsStep{ - operationManager: process.NewOperationManager(os), + step := &InjectBTPOperatorCredentialsStep{ k8sClientProvider: k8sClientProvider, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *InjectBTPOperatorCredentialsStep) Name() string { diff --git a/internal/process/provisioning/override_kyma_modules.go b/internal/process/provisioning/override_kyma_modules.go index 07673d7dda..fafce6a8b2 100644 --- a/internal/process/provisioning/override_kyma_modules.go +++ b/internal/process/provisioning/override_kyma_modules.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + pkg "github.com/kyma-project/kyma-environment-broker/common/runtime" "github.com/kyma-project/kyma-environment-broker/internal" "github.com/kyma-project/kyma-environment-broker/internal/process" @@ -26,7 +28,9 @@ func (k *OverrideKymaModules) Name() string { } func NewOverrideKymaModules(os storage.Operations) *OverrideKymaModules { - return &OverrideKymaModules{operationManager: process.NewOperationManager(os)} + step := &OverrideKymaModules{} + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } // Cases: diff --git a/internal/process/provisioning/resolve_creds.go b/internal/process/provisioning/resolve_creds.go index a9a1b42772..a526e5a6da 100644 --- a/internal/process/provisioning/resolve_creds.go +++ b/internal/process/provisioning/resolve_creds.go @@ -4,6 +4,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/euaccess" "github.com/kyma-project/kyma-environment-broker/internal/provider" @@ -25,11 +27,12 @@ type ResolveCredentialsStep struct { } func NewResolveCredentialsStep(os storage.Operations, accountProvider hyperscaler.AccountProvider) *ResolveCredentialsStep { - return &ResolveCredentialsStep{ - operationManager: process.NewOperationManager(os), - opStorage: os, - accountProvider: accountProvider, + step := &ResolveCredentialsStep{ + opStorage: os, + accountProvider: accountProvider, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *ResolveCredentialsStep) Name() string { diff --git a/internal/process/provisioning/start_step.go b/internal/process/provisioning/start_step.go index a2c0341617..5bbc4d1374 100644 --- a/internal/process/provisioning/start_step.go +++ b/internal/process/provisioning/start_step.go @@ -21,11 +21,12 @@ type StartStep struct { } func NewStartStep(os storage.Operations, is storage.Instances) *StartStep { - return &StartStep{ - operationManager: process.NewOperationManager(os), + step := &StartStep{ operationStorage: os, instanceStorage: is, } + step.operationManager = process.NewOperationManager(os, step.Name(), orchestration.Pending) + return step } func (s *StartStep) Name() string { diff --git a/internal/process/staged_manager.go b/internal/process/staged_manager.go index 6b0d3b5585..aae3704a6e 100644 --- a/internal/process/staged_manager.go +++ b/internal/process/staged_manager.go @@ -219,7 +219,7 @@ func (m *StagedManager) runStep(step Step, operation internal.Operation, logger if pErr := recover(); pErr != nil { logger.Println("panic in RunStep in staged manager: ", pErr) err = errors.New(fmt.Sprintf("%v", pErr)) - om := NewOperationManager(m.operationStorage) + om := NewOperationManager(m.operationStorage, step.Name(), kebError.NotSet) processedOperation, _, _ = om.OperationFailed(operation, "recovered from panic", err, m.log) } }() diff --git a/internal/process/steps/gardener_cluster.go b/internal/process/steps/gardener_cluster.go index 53d5c1bd5a..e38ea0d6fd 100644 --- a/internal/process/steps/gardener_cluster.go +++ b/internal/process/steps/gardener_cluster.go @@ -7,6 +7,8 @@ import ( "strings" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "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/process" @@ -22,20 +24,22 @@ import ( const GardenerClusterStateReady = "Ready" func NewSyncGardenerCluster(os storage.Operations, k8sClient client.Client, kimConfig broker.KimConfig) *syncGardenerCluster { - return &syncGardenerCluster{ - k8sClient: k8sClient, - kimConfig: kimConfig, - operationManager: process.NewOperationManager(os), + step := &syncGardenerCluster{ + k8sClient: k8sClient, + kimConfig: kimConfig, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func NewCheckGardenerCluster(os storage.Operations, k8sClient client.Client, kimConfig broker.KimConfig, gardenerClusterStepTimeout time.Duration) *checkGardenerCluster { - return &checkGardenerCluster{ + step := &checkGardenerCluster{ k8sClient: k8sClient, kimConfig: kimConfig, - operationManager: process.NewOperationManager(os), gardenerClusterStepTimeout: gardenerClusterStepTimeout, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } type checkGardenerCluster struct { diff --git a/internal/process/steps/kyma_template.go b/internal/process/steps/kyma_template.go index 469eb04e3c..500a1a501b 100644 --- a/internal/process/steps/kyma_template.go +++ b/internal/process/steps/kyma_template.go @@ -3,6 +3,8 @@ package steps import ( "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/sirupsen/logrus" "github.com/kyma-project/kyma-environment-broker/internal" @@ -17,7 +19,9 @@ type InitKymaTemplate struct { var _ process.Step = &InitKymaTemplate{} func NewInitKymaTemplate(os storage.Operations) *InitKymaTemplate { - return &InitKymaTemplate{operationManager: process.NewOperationManager(os)} + step := &InitKymaTemplate{} + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *InitKymaTemplate) Name() string { diff --git a/internal/process/steps/lifecycle_manager_kubeconfig.go b/internal/process/steps/lifecycle_manager_kubeconfig.go index a99e7c4f56..c4b545a2cf 100644 --- a/internal/process/steps/lifecycle_manager_kubeconfig.go +++ b/internal/process/steps/lifecycle_manager_kubeconfig.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal" "github.com/kyma-project/kyma-environment-broker/internal/process" "github.com/kyma-project/kyma-environment-broker/internal/storage" @@ -28,11 +30,15 @@ type deleteKubeconfig struct { } func SyncKubeconfig(os storage.Operations, k8sClient client.Client) syncKubeconfig { - return syncKubeconfig{k8sClient: k8sClient, operationManager: process.NewOperationManager(os)} + step := syncKubeconfig{k8sClient: k8sClient} + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func DeleteKubeconfig(os storage.Operations, k8sClient client.Client) deleteKubeconfig { - return deleteKubeconfig{k8sClient: k8sClient, operationManager: process.NewOperationManager(os)} + step := deleteKubeconfig{k8sClient: k8sClient} + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (_ syncKubeconfig) Name() string { diff --git a/internal/process/steps/runtime_resource.go b/internal/process/steps/runtime_resource.go index c9f6519e26..cd49b863d0 100644 --- a/internal/process/steps/runtime_resource.go +++ b/internal/process/steps/runtime_resource.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + imv1 "github.com/kyma-project/infrastructure-manager/api/v1" "github.com/kyma-project/kyma-environment-broker/internal/broker" @@ -16,12 +18,13 @@ import ( ) func NewCheckRuntimeResourceStep(os storage.Operations, k8sClient client.Client, kimConfig broker.KimConfig, runtimeResourceStepTimeout time.Duration) *checkRuntimeResource { - return &checkRuntimeResource{ + step := &checkRuntimeResource{ k8sClient: k8sClient, - operationManager: process.NewOperationManager(os), kimConfig: kimConfig, runtimeResourceStepTimeout: runtimeResourceStepTimeout, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } type checkRuntimeResource struct { diff --git a/internal/process/update/check_step.go b/internal/process/update/check_step.go index 4ebf359732..9d08e087a3 100644 --- a/internal/process/update/check_step.go +++ b/internal/process/update/check_step.go @@ -4,6 +4,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/sirupsen/logrus" "github.com/kyma-project/control-plane/components/provisioner/pkg/gqlschema" @@ -23,11 +25,12 @@ type CheckStep struct { func NewCheckStep(os storage.Operations, provisionerClient provisioner.Client, provisioningTimeout time.Duration) *CheckStep { - return &CheckStep{ + step := &CheckStep{ provisionerClient: provisionerClient, - operationManager: process.NewOperationManager(os), provisioningTimeout: provisioningTimeout, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } var _ process.Step = (*CheckStep)(nil) diff --git a/internal/process/update/initialisation_step.go b/internal/process/update/initialisation_step.go index 3d41173af3..4ef0047e57 100644 --- a/internal/process/update/initialisation_step.go +++ b/internal/process/update/initialisation_step.go @@ -24,12 +24,13 @@ type InitialisationStep struct { } func NewInitialisationStep(is storage.Instances, os storage.Operations, b input.CreatorForPlan) *InitialisationStep { - return &InitialisationStep{ - operationManager: process.NewOperationManager(os), + step := &InitialisationStep{ operationStorage: os, instanceStorage: is, inputBuilder: b, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *InitialisationStep) Name() string { diff --git a/internal/process/update/update_runtime_step.go b/internal/process/update/update_runtime_step.go index 773db629f1..acd9809724 100644 --- a/internal/process/update/update_runtime_step.go +++ b/internal/process/update/update_runtime_step.go @@ -4,6 +4,8 @@ import ( "context" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + "github.com/kyma-project/kyma-environment-broker/internal/process/provisioning" imv1 "github.com/kyma-project/infrastructure-manager/api/v1" @@ -23,11 +25,12 @@ type UpdateRuntimeStep struct { } func NewUpdateRuntimeStep(os storage.Operations, k8sClient client.Client, delay time.Duration) *UpdateRuntimeStep { - return &UpdateRuntimeStep{ - operationManager: process.NewOperationManager(os), - k8sClient: k8sClient, - delay: delay, + step := &UpdateRuntimeStep{ + k8sClient: k8sClient, + delay: delay, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *UpdateRuntimeStep) Name() string { diff --git a/internal/process/update/upgrade_shoot_step.go b/internal/process/update/upgrade_shoot_step.go index 124a169541..1d5d287fd0 100644 --- a/internal/process/update/upgrade_shoot_step.go +++ b/internal/process/update/upgrade_shoot_step.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + kebError "github.com/kyma-project/kyma-environment-broker/internal/error" + imv1 "github.com/kyma-project/infrastructure-manager/api/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -34,12 +36,13 @@ func NewUpgradeShootStep( runtimeStorage storage.RuntimeStates, cli provisioner.Client, k8sClient client.Client) *UpgradeShootStep { - return &UpgradeShootStep{ - operationManager: process.NewOperationManager(os), + step := &UpgradeShootStep{ provisionerClient: cli, runtimeStateStorage: runtimeStorage, k8sClient: k8sClient, } + step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet) + return step } func (s *UpgradeShootStep) Name() string {