github.com/kyma-project/kyma-environment-broker@v0.0.1/cmd/broker/upgrade_kyma.go (about) 1 package main 2 3 import ( 4 "context" 5 "time" 6 7 orchestrationExt "github.com/kyma-project/kyma-environment-broker/common/orchestration" 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/notification" 11 "github.com/kyma-project/kyma-environment-broker/internal/orchestration/manager" 12 "github.com/kyma-project/kyma-environment-broker/internal/process" 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/process/upgrade_kyma" 16 "github.com/kyma-project/kyma-environment-broker/internal/provisioner" 17 "github.com/kyma-project/kyma-environment-broker/internal/reconciler" 18 "github.com/kyma-project/kyma-environment-broker/internal/runtimeversion" 19 "github.com/kyma-project/kyma-environment-broker/internal/storage" 20 "github.com/sirupsen/logrus" 21 "sigs.k8s.io/controller-runtime/pkg/client" 22 ) 23 24 func NewKymaOrchestrationProcessingQueue(ctx context.Context, db storage.BrokerStorage, 25 runtimeOverrides upgrade_kyma.RuntimeOverridesAppender, provisionerClient provisioner.Client, pub event.Publisher, 26 inputFactory input.CreatorForPlan, icfg *upgrade_kyma.TimeSchedule, pollingInterval time.Duration, 27 runtimeVerConfigurator *runtimeversion.RuntimeVersionConfigurator, runtimeResolver orchestrationExt.RuntimeResolver, 28 upgradeEvalManager *avs.EvaluationManager, cfg *Config, internalEvalAssistant *avs.InternalEvalAssistant, 29 reconcilerClient reconciler.Client, notificationBuilder notification.BundleBuilder, logs logrus.FieldLogger, 30 cli client.Client, speedFactor int) *process.Queue { 31 32 upgradeKymaManager := upgrade_kyma.NewManager(db.Operations(), pub, logs.WithField("upgradeKyma", "manager")) 33 upgradeKymaInit := upgrade_kyma.NewInitialisationStep(db.Operations(), db.Orchestrations(), db.Instances(), 34 provisionerClient, inputFactory, upgradeEvalManager, icfg, runtimeVerConfigurator, notificationBuilder) 35 36 upgradeKymaManager.InitStep(upgradeKymaInit) 37 upgradeKymaSteps := []struct { 38 disabled bool 39 weight int 40 step upgrade_kyma.Step 41 cnd upgrade_kyma.StepCondition 42 }{ 43 // check cluster configuration is the first step - to not execute other steps, when cluster configuration was applied 44 // this should be moved to the end when we introduce stages like in the provisioning process 45 // (also return operation, 0, nil at the end of apply_cluster_configuration) 46 { 47 weight: 1, 48 disabled: cfg.ReconcilerIntegrationDisabled, 49 step: upgrade_kyma.NewCheckClusterConfigurationStep(db.Operations(), reconcilerClient, upgradeEvalManager, cfg.Reconciler.ProvisioningTimeout), 50 cnd: upgrade_kyma.SkipForPreviewPlan, 51 }, 52 { 53 weight: 1, 54 step: steps.InitKymaTemplateUpgradeKyma(db.Operations()), 55 }, 56 { 57 weight: 2, 58 step: upgrade_kyma.NewGetKubeconfigStep(db.Operations(), provisionerClient), 59 }, 60 { 61 weight: 2, 62 disabled: cfg.LifecycleManagerIntegrationDisabled, 63 step: steps.SyncKubeconfigUpgradeKyma(db.Operations(), cli), 64 }, 65 { 66 weight: 2, 67 disabled: cfg.LifecycleManagerIntegrationDisabled, 68 step: upgrade_kyma.NewApplyKymaStep(db.Operations(), cli), 69 }, 70 { 71 weight: 3, 72 cnd: upgrade_kyma.WhenBTPOperatorCredentialsProvided, 73 step: upgrade_kyma.NewBTPOperatorOverridesStep(db.Operations()), 74 }, 75 { 76 weight: 4, 77 step: upgrade_kyma.NewOverridesFromSecretsAndConfigStep(db.Operations(), runtimeOverrides, runtimeVerConfigurator), 78 }, 79 { 80 weight: 8, 81 step: upgrade_kyma.NewSendNotificationStep(db.Operations(), notificationBuilder), 82 }, 83 { 84 weight: 10, 85 disabled: cfg.ReconcilerIntegrationDisabled, 86 step: upgrade_kyma.NewApplyClusterConfigurationStep(db.Operations(), db.RuntimeStates(), reconcilerClient), 87 cnd: upgrade_kyma.SkipForPreviewPlan, 88 }, 89 } 90 for _, step := range upgradeKymaSteps { 91 if !step.disabled { 92 upgradeKymaManager.AddStep(step.weight, step.step, step.cnd) 93 } 94 } 95 96 orchestrateKymaManager := manager.NewUpgradeKymaManager(db.Orchestrations(), db.Operations(), db.Instances(), 97 upgradeKymaManager, runtimeResolver, pollingInterval, logs.WithField("upgradeKyma", "orchestration"), 98 cli, &cfg.OrchestrationConfig, notificationBuilder, speedFactor) 99 queue := process.NewQueue(orchestrateKymaManager, logs) 100 101 queue.Run(ctx.Done(), 3) 102 103 return queue 104 }