Skip to content

Commit

Permalink
Remove avs (#1182)
Browse files Browse the repository at this point in the history
* Remove AvS code

* wip

* wip

* wip

* wip

* wip

* wip
  • Loading branch information
piotrmiskiewicz authored Sep 25, 2024
1 parent 3763d44 commit fba6247
Show file tree
Hide file tree
Showing 33 changed files with 30 additions and 3,907 deletions.
28 changes: 2 additions & 26 deletions cmd/broker/broker_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/kyma-project/kyma-environment-broker/common/gardener"
"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/avs"
"github.com/kyma-project/kyma-environment-broker/internal/broker"
kebConfig "github.com/kyma-project/kyma-environment-broker/internal/config"
"github.com/kyma-project/kyma-environment-broker/internal/edp"
Expand All @@ -39,7 +38,6 @@ import (
orchestrate "github.com/kyma-project/kyma-environment-broker/internal/orchestration/handlers"
"github.com/kyma-project/kyma-environment-broker/internal/process"
"github.com/kyma-project/kyma-environment-broker/internal/process/input"
"github.com/kyma-project/kyma-environment-broker/internal/process/provisioning"
"github.com/kyma-project/kyma-environment-broker/internal/process/steps"
"github.com/kyma-project/kyma-environment-broker/internal/process/upgrade_cluster"
"github.com/kyma-project/kyma-environment-broker/internal/provisioner"
Expand Down Expand Up @@ -197,8 +195,6 @@ func NewBrokerSuiteTestWithConfig(t *testing.T, cfg *Config, version ...string)
provisionerClient := provisioner.NewFakeClientWithGardener(gardenerClient, "kcp-system")
eventBroker := event.NewPubSub(logs)

avsDel, externalEvalCreator, internalEvalAssistant, externalEvalAssistant := createFakeAvsDelegator(t, db, cfg)

edpClient := edp.NewFakeClient()
accountProvider := fixAccountProvider()
require.NoError(t, err)
Expand All @@ -207,7 +203,6 @@ func NewBrokerSuiteTestWithConfig(t *testing.T, cfg *Config, version ...string)
k8sClientProvider := kubeconfig.NewFakeK8sClientProvider(fakeK8sSKRClient)
provisionManager := process.NewStagedManager(db.Operations(), eventBroker, cfg.OperationTimeout, cfg.Provisioning, logs.WithField("provisioning", "manager"))
provisioningQueue := NewProvisioningProcessingQueue(context.Background(), provisionManager, workersAmount, cfg, db, provisionerClient, inputFactory,
avsDel, internalEvalAssistant, externalEvalCreator,
edpClient, accountProvider, k8sClientProvider, cli, defaultOIDCValues(), logs)

provisioningQueue.SpeedUp(10000)
Expand All @@ -221,8 +216,7 @@ func NewBrokerSuiteTestWithConfig(t *testing.T, cfg *Config, version ...string)

deprovisionManager := process.NewStagedManager(db.Operations(), eventBroker, time.Hour, cfg.Deprovisioning, logs.WithField("deprovisioning", "manager"))
deprovisioningQueue := NewDeprovisioningProcessingQueue(ctx, workersAmount, deprovisionManager, cfg, db, eventBroker,
provisionerClient, avsDel, internalEvalAssistant, externalEvalAssistant,
edpClient, accountProvider, k8sClientProvider, cli, configProvider, logs,
provisionerClient, edpClient, accountProvider, k8sClientProvider, cli, configProvider, logs,
)
deprovisionManager.SpeedUp(10000)

Expand All @@ -247,15 +241,14 @@ func NewBrokerSuiteTestWithConfig(t *testing.T, cfg *Config, version ...string)
notificationFakeClient := notification.NewFakeClient()
notificationBundleBuilder := notification.NewBundleBuilder(notificationFakeClient, cfg.Notification)

upgradeEvaluationManager := avs.NewEvaluationManager(avsDel, avs.Config{})
runtimeLister := kebOrchestration.NewRuntimeLister(db.Instances(), db.Operations(), kebRuntime.NewConverter(defaultRegion), logs)
runtimeResolver := orchestration.NewGardenerRuntimeResolver(gardenerClient, fixedGardenerNamespace, runtimeLister, logs)

clusterQueue := NewClusterOrchestrationProcessingQueue(ctx, db, provisionerClient, eventBroker, inputFactory, &upgrade_cluster.TimeSchedule{
Retry: 10 * time.Millisecond,
StatusCheck: 100 * time.Millisecond,
UpgradeClusterTimeout: 3 * time.Second,
}, 250*time.Millisecond, runtimeResolver, upgradeEvaluationManager, notificationBundleBuilder, logs, cli, *cfg, 1000)
}, 250*time.Millisecond, runtimeResolver, notificationBundleBuilder, logs, cli, *cfg, 1000)

clusterQueue.SpeedUp(1000)

Expand Down Expand Up @@ -373,23 +366,6 @@ func (s *BrokerSuiteTest) CreateAPI(inputFactory broker.PlanValidator, cfg *Conf
s.httpServer = httptest.NewServer(s.router)
}

func createFakeAvsDelegator(t *testing.T, db storage.BrokerStorage, cfg *Config) (*avs.Delegator, *provisioning.ExternalEvalCreator, *avs.InternalEvalAssistant, *avs.ExternalEvalAssistant) {
server := avs.NewMockAvsServer(t)
mockServer := avs.FixMockAvsServer(server)
avsConfig := avs.Config{
OauthTokenEndpoint: fmt.Sprintf("%s/oauth/token", mockServer.URL),
ApiEndpoint: fmt.Sprintf("%s/api/v2/evaluationmetadata", mockServer.URL),
}
client, err := avs.NewClient(context.TODO(), avsConfig, logrus.New())
assert.NoError(t, err)
avsDel := avs.NewDelegator(client, avsConfig, db.Operations())
externalEvalAssistant := avs.NewExternalEvalAssistant(cfg.Avs)
internalEvalAssistant := avs.NewInternalEvalAssistant(cfg.Avs)
externalEvalCreator := provisioning.NewExternalEvalCreator(avsDel, cfg.Avs.Disabled, externalEvalAssistant)

return avsDel, externalEvalCreator, internalEvalAssistant, externalEvalAssistant
}

func (s *BrokerSuiteTest) CreateProvisionedRuntime(options RuntimeOptions) string {
randomInstanceId := uuid.New().String()

Expand Down
7 changes: 1 addition & 6 deletions cmd/broker/deprovisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"time"

"github.com/kyma-project/kyma-environment-broker/common/hyperscaler"
"github.com/kyma-project/kyma-environment-broker/internal/avs"
"github.com/kyma-project/kyma-environment-broker/internal/event"
"github.com/kyma-project/kyma-environment-broker/internal/process"
"github.com/kyma-project/kyma-environment-broker/internal/process/deprovisioning"
Expand All @@ -19,8 +18,7 @@ import (

func NewDeprovisioningProcessingQueue(ctx context.Context, workersAmount int, deprovisionManager *process.StagedManager,
cfg *Config, db storage.BrokerStorage, pub event.Publisher,
provisionerClient provisioner.Client, avsDel *avs.Delegator, internalEvalAssistant *avs.InternalEvalAssistant,
externalEvalAssistant *avs.ExternalEvalAssistant,
provisionerClient provisioner.Client,
edpClient deprovisioning.EDPClient, accountProvider hyperscaler.AccountProvider,
k8sClientProvider K8sClientProvider, cli client.Client, configProvider input.ConfigurationProvider, logs logrus.FieldLogger) *process.Queue {

Expand All @@ -34,9 +32,6 @@ func NewDeprovisioningProcessingQueue(ctx context.Context, workersAmount int, de
{
step: deprovisioning.NewBTPOperatorCleanupStep(db.Operations(), k8sClientProvider),
},
{
step: deprovisioning.NewAvsEvaluationsRemovalStep(avsDel, db.Operations(), externalEvalAssistant, internalEvalAssistant),
},
{
step: deprovisioning.NewEDPDeregistrationStep(db.Operations(), db.Instances(), edpClient, cfg.EDP),
disabled: cfg.EDP.Disabled,
Expand Down
19 changes: 1 addition & 18 deletions cmd/broker/deprovisioning_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/google/uuid"
"github.com/kyma-project/control-plane/components/provisioner/pkg/gqlschema"
"github.com/kyma-project/kyma-environment-broker/internal"
"github.com/kyma-project/kyma-environment-broker/internal/avs"
"github.com/kyma-project/kyma-environment-broker/internal/edp"
"github.com/kyma-project/kyma-environment-broker/internal/event"
"github.com/kyma-project/kyma-environment-broker/internal/fixture"
Expand Down Expand Up @@ -86,22 +85,6 @@ func NewDeprovisioningSuite(t *testing.T) *DeprovisioningSuite {
eventBroker := event.NewPubSub(logs)
provisionerClient := provisioner.NewFakeClient()

server := avs.NewMockAvsServer(t)
mockServer := avs.FixMockAvsServer(server)
avsConfig := avs.Config{
OauthTokenEndpoint: fmt.Sprintf("%s/oauth/token", mockServer.URL),
ApiEndpoint: fmt.Sprintf("%s/api/v2/evaluationmetadata", mockServer.URL),
}
client, err := avs.NewClient(context.TODO(), avsConfig, logrus.New())
assert.NoError(t, err)
_, err = client.CreateEvaluation(&avs.BasicEvaluationCreateRequest{
Name: "fake-evaluation",
})
assert.NoError(t, err)
avsDel := avs.NewDelegator(client, avsConfig, db.Operations())
externalEvalAssistant := avs.NewExternalEvalAssistant(cfg.Avs)
internalEvalAssistant := avs.NewInternalEvalAssistant(cfg.Avs)

edpClient := fixEDPClient(t)

accountProvider := fixAccountProvider()
Expand All @@ -126,7 +109,7 @@ func NewDeprovisioningSuite(t *testing.T) *DeprovisioningSuite {
kebConfig.NewConfigMapConverter())

deprovisioningQueue := NewDeprovisioningProcessingQueue(ctx, workersAmount, deprovisionManager, cfg, db, eventBroker,
provisionerClient, avsDel, internalEvalAssistant, externalEvalAssistant,
provisionerClient,
edpClient, accountProvider, kubeconfig.NewFakeK8sClientProvider(fakeK8sSKRClient), fakeK8sSKRClient, configProvider, logs,
)

Expand Down
19 changes: 2 additions & 17 deletions cmd/broker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
orchestrationExt "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/appinfo"
"github.com/kyma-project/kyma-environment-broker/internal/avs"
"github.com/kyma-project/kyma-environment-broker/internal/broker"
kebConfig "github.com/kyma-project/kyma-environment-broker/internal/config"
"github.com/kyma-project/kyma-environment-broker/internal/dashboard"
Expand All @@ -44,7 +43,6 @@ import (
orchestrate "github.com/kyma-project/kyma-environment-broker/internal/orchestration/handlers"
"github.com/kyma-project/kyma-environment-broker/internal/process"
"github.com/kyma-project/kyma-environment-broker/internal/process/input"
"github.com/kyma-project/kyma-environment-broker/internal/process/provisioning"
"github.com/kyma-project/kyma-environment-broker/internal/provider"
"github.com/kyma-project/kyma-environment-broker/internal/provisioner"
"github.com/kyma-project/kyma-environment-broker/internal/runtime"
Expand Down Expand Up @@ -113,7 +111,6 @@ type Config struct {
Broker broker.Config
CatalogFilePath string

Avs avs.Config
EDP edp.Config

Notification notification.Config
Expand Down Expand Up @@ -311,16 +308,6 @@ func main() {

edpClient := edp.NewClient(cfg.EDP)

panicOnError(cfg.Avs.ReadMaintenanceModeDuringUpgradeAlwaysDisabledGAIDsFromYaml(
cfg.AvsMaintenanceModeDuringUpgradeAlwaysDisabledGlobalAccountsFilePath))
avsClient, err := avs.NewClient(ctx, cfg.Avs, logs)
fatalOnError(err, logs)
avsDel := avs.NewDelegator(avsClient, cfg.Avs, db.Operations())
externalEvalAssistant := avs.NewExternalEvalAssistant(cfg.Avs)
internalEvalAssistant := avs.NewInternalEvalAssistant(cfg.Avs)
externalEvalCreator := provisioning.NewExternalEvalCreator(avsDel, cfg.Avs.ExternalTesterDisabled, externalEvalAssistant)
upgradeEvalManager := avs.NewEvaluationManager(avsDel, cfg.Avs)

// application event broker
eventBroker := event.NewPubSub(logs)

Expand All @@ -330,12 +317,10 @@ func main() {
// run queues
provisionManager := process.NewStagedManager(db.Operations(), eventBroker, cfg.OperationTimeout, cfg.Provisioning, logs.WithField("provisioning", "manager"))
provisionQueue := NewProvisioningProcessingQueue(ctx, provisionManager, cfg.Provisioning.WorkersAmount, &cfg, db, provisionerClient, inputFactory,
avsDel, internalEvalAssistant, externalEvalCreator,
edpClient, accountProvider, skrK8sClientProvider, cli, oidcDefaultValues, logs)

deprovisionManager := process.NewStagedManager(db.Operations(), eventBroker, cfg.OperationTimeout, cfg.Deprovisioning, logs.WithField("deprovisioning", "manager"))
deprovisionQueue := NewDeprovisioningProcessingQueue(ctx, cfg.Deprovisioning.WorkersAmount, deprovisionManager, &cfg, db, eventBroker, provisionerClient,
avsDel, internalEvalAssistant, externalEvalAssistant, edpClient, accountProvider,
deprovisionQueue := NewDeprovisioningProcessingQueue(ctx, cfg.Deprovisioning.WorkersAmount, deprovisionManager, &cfg, db, eventBroker, provisionerClient, edpClient, accountProvider,
skrK8sClientProvider, cli, configProvider, logs)

updateManager := process.NewStagedManager(db.Operations(), eventBroker, cfg.OperationTimeout, cfg.Update, logs.WithField("update", "manager"))
Expand Down Expand Up @@ -363,7 +348,7 @@ func main() {
runtimeResolver := orchestrationExt.NewGardenerRuntimeResolver(dynamicGardener, gardenerNamespace, runtimeLister, logs)

clusterQueue := NewClusterOrchestrationProcessingQueue(ctx, db, provisionerClient, eventBroker, inputFactory,
nil, time.Minute, runtimeResolver, upgradeEvalManager, notificationBuilder, logs, cli, cfg, 1)
nil, time.Minute, runtimeResolver, notificationBuilder, logs, cli, cfg, 1)

// TODO: in case of cluster upgrade the same Azure Zones must be send to the Provisioner
orchestrationHandler := orchestrate.NewOrchestrationHandler(db, clusterQueue, cfg.MaxPaginationPage, logs)
Expand Down
22 changes: 2 additions & 20 deletions cmd/broker/provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/kyma-project/kyma-environment-broker/internal/provider"

"github.com/kyma-project/kyma-environment-broker/common/hyperscaler"
"github.com/kyma-project/kyma-environment-broker/internal/avs"
"github.com/kyma-project/kyma-environment-broker/internal/process"
"github.com/kyma-project/kyma-environment-broker/internal/process/input"
"github.com/kyma-project/kyma-environment-broker/internal/process/provisioning"
Expand All @@ -19,8 +18,7 @@ import (
)

func NewProvisioningProcessingQueue(ctx context.Context, provisionManager *process.StagedManager, workersAmount int, cfg *Config,
db storage.BrokerStorage, provisionerClient provisioner.Client, inputFactory input.CreatorForPlan, avsDel *avs.Delegator,
internalEvalAssistant *avs.InternalEvalAssistant, externalEvalCreator *provisioning.ExternalEvalCreator,
db storage.BrokerStorage, provisionerClient provisioner.Client, inputFactory input.CreatorForPlan,
edpClient provisioning.EDPClient, accountProvider hyperscaler.AccountProvider,
k8sClientProvider provisioning.K8sClientProvider, cli client.Client, defaultOIDC internal.OIDCConfigDTO, logs logrus.FieldLogger) *process.Queue {

Expand All @@ -31,7 +29,7 @@ func NewProvisioningProcessingQueue(ctx context.Context, provisionManager *proce

const postActionsStageName = "post_actions"
provisionManager.DefineStages([]string{startStageName, createRuntimeStageName,
checkKymaStageName, createKymaResourceStageName, postActionsStageName})
checkKymaStageName, createKymaResourceStageName})
/*
The provisioning process contains the following stages:
1. "start" - changes the state from pending to in progress if no deprovisioning is ongoing.
Expand Down Expand Up @@ -73,11 +71,6 @@ func NewProvisioningProcessingQueue(ctx context.Context, provisionManager *proce
step: provisioning.NewResolveCredentialsStep(db.Operations(), accountProvider),
condition: provisioning.SkipForOwnClusterPlan,
},
{
stage: createRuntimeStageName,
step: provisioning.NewInternalEvaluationStep(avsDel, internalEvalAssistant),
disabled: cfg.Avs.Disabled,
},
{
stage: createRuntimeStageName,
step: provisioning.NewEDPRegistrationStep(db.Operations(), edpClient, cfg.EDP),
Expand Down Expand Up @@ -144,17 +137,6 @@ func NewProvisioningProcessingQueue(ctx context.Context, provisionManager *proce
stage: createKymaResourceStageName,
step: provisioning.NewApplyKymaStep(db.Operations(), cli),
},
// post actions
{
stage: postActionsStageName,
step: provisioning.NewExternalEvalStep(externalEvalCreator),
disabled: cfg.Avs.Disabled,
},
{
stage: postActionsStageName,
step: provisioning.NewInternalEvaluationStep(avsDel, internalEvalAssistant),
disabled: cfg.Avs.Disabled,
},
}
for _, step := range provisioningSteps {
if !step.disabled {
Expand Down
25 changes: 2 additions & 23 deletions cmd/broker/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ import (
hyperscalerautomock "github.com/kyma-project/kyma-environment-broker/common/hyperscaler/automock"
"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/avs"
"github.com/kyma-project/kyma-environment-broker/internal/broker"
"github.com/kyma-project/kyma-environment-broker/internal/edp"
"github.com/kyma-project/kyma-environment-broker/internal/event"
"github.com/kyma-project/kyma-environment-broker/internal/notification"
kebOrchestration "github.com/kyma-project/kyma-environment-broker/internal/orchestration"
"github.com/kyma-project/kyma-environment-broker/internal/process"
"github.com/kyma-project/kyma-environment-broker/internal/process/input"
"github.com/kyma-project/kyma-environment-broker/internal/process/provisioning"
"github.com/kyma-project/kyma-environment-broker/internal/process/upgrade_cluster"
"github.com/kyma-project/kyma-environment-broker/internal/provisioner"
kebRuntime "github.com/kyma-project/kyma-environment-broker/internal/runtime"
Expand Down Expand Up @@ -149,9 +147,6 @@ func NewOrchestrationSuite(t *testing.T, additionalKymaVersions []string) *Orche

eventBroker := event.NewPubSub(logs)

avsClient, _ := avs.NewClient(ctx, avs.Config{}, logs)
avsDel := avs.NewDelegator(avsClient, avs.Config{}, db.Operations())
upgradeEvaluationManager := avs.NewEvaluationManager(avsDel, avs.Config{})
runtimeLister := kebOrchestration.NewRuntimeLister(db.Instances(), db.Operations(), kebRuntime.NewConverter(defaultRegion), logs)
runtimeResolver := orchestration.NewGardenerRuntimeResolver(gardenerClient, gardenerNamespace, runtimeLister, logs)

Expand All @@ -162,7 +157,7 @@ func NewOrchestrationSuite(t *testing.T, additionalKymaVersions []string) *Orche
Retry: 2 * time.Millisecond,
StatusCheck: 20 * time.Millisecond,
UpgradeClusterTimeout: 4 * time.Second,
}, 250*time.Millisecond, runtimeResolver, upgradeEvaluationManager, notificationBundleBuilder, logs, cli, cfg, 1000)
}, 250*time.Millisecond, runtimeResolver, notificationBundleBuilder, logs, cli, cfg, 1000)

clusterQueue.SpeedUp(1000)

Expand Down Expand Up @@ -519,7 +514,6 @@ type ProvisioningSuite struct {
storage storage.BrokerStorage

t *testing.T
avsServer *avs.MockAvsServer
k8sKcpCli client.Client
}

Expand Down Expand Up @@ -577,19 +571,7 @@ func NewProvisioningSuite(t *testing.T, multiZoneCluster bool, controlPlaneFailu
}, map[string]string{"cf-eu10": "europe"}, cfg.FreemiumProviders, oidcDefaults, useSmallerMachineTypes)
require.NoError(t, err)

server := avs.NewMockAvsServer(t)
mockServer := avs.FixMockAvsServer(server)
avsConfig := avs.Config{
OauthTokenEndpoint: fmt.Sprintf("%s/oauth/token", mockServer.URL),
ApiEndpoint: fmt.Sprintf("%s/api/v2/evaluationmetadata", mockServer.URL),
}

client, err := avs.NewClient(context.TODO(), avsConfig, logrus.New())
assert.NoError(t, err)
avsDel := avs.NewDelegator(client, avsConfig, db.Operations())
externalEvalAssistant := avs.NewExternalEvalAssistant(cfg.Avs)
internalEvalAssistant := avs.NewInternalEvalAssistant(cfg.Avs)
externalEvalCreator := provisioning.NewExternalEvalCreator(avsDel, cfg.Avs.Disabled, externalEvalAssistant)

edpClient := edp.NewFakeClient()

Expand All @@ -598,8 +580,7 @@ func NewProvisioningSuite(t *testing.T, multiZoneCluster bool, controlPlaneFailu
eventBroker := event.NewPubSub(logs)

provisionManager := process.NewStagedManager(db.Operations(), eventBroker, cfg.OperationTimeout, cfg.Provisioning, logs.WithField("provisioning", "manager"))
provisioningQueue := NewProvisioningProcessingQueue(ctx, provisionManager, workersAmount, cfg, db, provisionerClient, inputFactory, avsDel,
internalEvalAssistant, externalEvalCreator, edpClient, accountProvider,
provisioningQueue := NewProvisioningProcessingQueue(ctx, provisionManager, workersAmount, cfg, db, provisionerClient, inputFactory, edpClient, accountProvider,
kubeconfig.NewFakeK8sClientProvider(cli), cli, defaultOIDCValues(), logs)

provisioningQueue.SpeedUp(10000)
Expand All @@ -610,7 +591,6 @@ func NewProvisioningSuite(t *testing.T, multiZoneCluster bool, controlPlaneFailu
provisioningManager: provisionManager,
provisioningQueue: provisioningQueue,
storage: db,
avsServer: server,
k8sKcpCli: cli,

t: t,
Expand Down Expand Up @@ -957,7 +937,6 @@ func fixConfig() *Config {
},
TrialRegionMappingFilePath: "testdata/trial-regions.yaml",

Avs: avs.Config{},
Notification: notification.Config{
Url: "http://host:8080/",
},
Expand Down
Loading

0 comments on commit fba6247

Please sign in to comment.