github.com/kyma-project/kyma-environment-broker@v0.0.1/cmd/broker/upgrade_cluster.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/provisioning" 15 "github.com/kyma-project/kyma-environment-broker/internal/process/upgrade_cluster" 16 "github.com/kyma-project/kyma-environment-broker/internal/provisioner" 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 NewClusterOrchestrationProcessingQueue(ctx context.Context, db storage.BrokerStorage, provisionerClient provisioner.Client, 23 pub event.Publisher, inputFactory input.CreatorForPlan, icfg *upgrade_cluster.TimeSchedule, pollingInterval time.Duration, 24 runtimeResolver orchestrationExt.RuntimeResolver, upgradeEvalManager *avs.EvaluationManager, notificationBuilder notification.BundleBuilder, logs logrus.FieldLogger, 25 cli client.Client, cfg Config, speedFactor int) *process.Queue { 26 27 upgradeClusterManager := upgrade_cluster.NewManager(db.Operations(), pub, logs.WithField("upgradeCluster", "manager")) 28 upgradeClusterInit := upgrade_cluster.NewInitialisationStep(db.Operations(), db.Orchestrations(), provisionerClient, inputFactory, upgradeEvalManager, icfg, notificationBuilder) 29 upgradeClusterManager.InitStep(upgradeClusterInit) 30 31 upgradeClusterSteps := []struct { 32 disabled bool 33 weight int 34 step upgrade_cluster.Step 35 condition upgrade_cluster.StepCondition 36 }{ 37 { 38 weight: 1, 39 step: upgrade_cluster.NewLogSkippingUpgradeStep(db.Operations()), 40 condition: provisioning.DoForOwnClusterPlanOnly, 41 }, 42 { 43 weight: 10, 44 step: upgrade_cluster.NewSendNotificationStep(db.Operations(), notificationBuilder), 45 condition: provisioning.SkipForOwnClusterPlan, 46 }, 47 { 48 weight: 10, 49 step: upgrade_cluster.NewUpgradeClusterStep(db.Operations(), db.RuntimeStates(), provisionerClient, icfg), 50 condition: provisioning.SkipForOwnClusterPlan, 51 }, 52 } 53 54 for _, step := range upgradeClusterSteps { 55 if !step.disabled { 56 upgradeClusterManager.AddStep(step.weight, step.step, step.condition) 57 } 58 } 59 60 orchestrateClusterManager := manager.NewUpgradeClusterManager(db.Orchestrations(), db.Operations(), db.Instances(), 61 upgradeClusterManager, runtimeResolver, pollingInterval, logs.WithField("upgradeCluster", "orchestration"), 62 cli, cfg.OrchestrationConfig, notificationBuilder, speedFactor) 63 queue := process.NewQueue(orchestrateClusterManager, logs) 64 65 queue.Run(ctx.Done(), 3) 66 67 return queue 68 }