github.com/kyma-project/kyma-environment-broker@v0.0.1/cmd/broker/deprovisioning.go (about) 1 package main 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/kyma-project/kyma-environment-broker/common/hyperscaler" 8 "github.com/kyma-project/kyma-environment-broker/internal/avs" 9 "github.com/kyma-project/kyma-environment-broker/internal/event" 10 "github.com/kyma-project/kyma-environment-broker/internal/ias" 11 "github.com/kyma-project/kyma-environment-broker/internal/process" 12 "github.com/kyma-project/kyma-environment-broker/internal/process/deprovisioning" 13 "github.com/kyma-project/kyma-environment-broker/internal/process/input" 14 "github.com/kyma-project/kyma-environment-broker/internal/process/steps" 15 "github.com/kyma-project/kyma-environment-broker/internal/provisioner" 16 "github.com/kyma-project/kyma-environment-broker/internal/reconciler" 17 "github.com/kyma-project/kyma-environment-broker/internal/storage" 18 "github.com/sirupsen/logrus" 19 "sigs.k8s.io/controller-runtime/pkg/client" 20 ) 21 22 func NewDeprovisioningProcessingQueue(ctx context.Context, workersAmount int, deprovisionManager *process.StagedManager, 23 cfg *Config, db storage.BrokerStorage, pub event.Publisher, 24 provisionerClient provisioner.Client, avsDel *avs.Delegator, internalEvalAssistant *avs.InternalEvalAssistant, 25 externalEvalAssistant *avs.ExternalEvalAssistant, bundleBuilder ias.BundleBuilder, 26 edpClient deprovisioning.EDPClient, accountProvider hyperscaler.AccountProvider, reconcilerClient reconciler.Client, 27 k8sClientProvider func(kcfg string) (client.Client, error), cli client.Client, configProvider input.ConfigurationProvider, logs logrus.FieldLogger) *process.Queue { 28 29 deprovisioningSteps := []struct { 30 disabled bool 31 step process.Step 32 }{ 33 { 34 step: deprovisioning.NewInitStep(db.Operations(), db.Instances(), 12*time.Hour), 35 }, 36 { 37 step: deprovisioning.NewBTPOperatorCleanupStep(db.Operations(), provisionerClient, k8sClientProvider), 38 }, 39 { 40 step: deprovisioning.NewAvsEvaluationsRemovalStep(avsDel, db.Operations(), externalEvalAssistant, internalEvalAssistant), 41 }, 42 { 43 step: deprovisioning.NewEDPDeregistrationStep(db.Operations(), edpClient, cfg.EDP), 44 disabled: cfg.EDP.Disabled, 45 }, 46 { 47 step: deprovisioning.NewIASDeregistrationStep(db.Operations(), bundleBuilder), 48 disabled: cfg.IAS.Disabled, 49 }, 50 { 51 disabled: cfg.LifecycleManagerIntegrationDisabled, 52 step: deprovisioning.NewDeleteKymaResourceStep(db.Operations(), cli, configProvider, cfg.KymaVersion), 53 }, 54 { 55 disabled: cfg.LifecycleManagerIntegrationDisabled, 56 step: deprovisioning.NewCheckKymaResourceDeletedStep(db.Operations(), cli), 57 }, 58 { 59 disabled: cfg.ReconcilerIntegrationDisabled, 60 step: deprovisioning.NewDeregisterClusterStep(db.Operations(), reconcilerClient), 61 }, 62 { 63 disabled: cfg.ReconcilerIntegrationDisabled, 64 step: deprovisioning.NewCheckClusterDeregistrationStep(db.Operations(), reconcilerClient, 90*time.Minute), 65 }, 66 { 67 step: deprovisioning.NewRemoveRuntimeStep(db.Operations(), db.Instances(), provisionerClient, cfg.Provisioner.DeprovisioningTimeout), 68 }, 69 { 70 step: deprovisioning.NewCheckRuntimeRemovalStep(db.Operations(), db.Instances(), provisionerClient, cfg.Provisioner.DeprovisioningTimeout), 71 }, 72 { 73 step: deprovisioning.NewReleaseSubscriptionStep(db.Operations(), db.Instances(), accountProvider), 74 }, 75 { 76 disabled: cfg.LifecycleManagerIntegrationDisabled, 77 step: steps.DeleteKubeconfig(db.Operations(), cli), 78 }, 79 { 80 step: deprovisioning.NewRemoveInstanceStep(db.Instances(), db.Operations()), 81 }, 82 } 83 var stages []string 84 for _, step := range deprovisioningSteps { 85 if !step.disabled { 86 stages = append(stages, step.step.Name()) 87 } 88 } 89 deprovisionManager.DefineStages(stages) 90 for _, step := range deprovisioningSteps { 91 if !step.disabled { 92 deprovisionManager.AddStep(step.step.Name(), step.step, nil) 93 } 94 } 95 96 queue := process.NewQueue(deprovisionManager, logs) 97 queue.Run(ctx.Done(), workersAmount) 98 99 return queue 100 }