Skip to content

Commit

Permalink
Remove kyma upgrade capability (#896)
Browse files Browse the repository at this point in the history
* Remove kyma upgrade capability

* Remove kyma upgrade from swagger
  • Loading branch information
KsaweryZietara authored Jul 1, 2024
1 parent 0352ff1 commit 2613e6f
Show file tree
Hide file tree
Showing 17 changed files with 184 additions and 1,006 deletions.
9 changes: 1 addition & 8 deletions cmd/broker/broker_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"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/process/upgrade_kyma"
"github.com/kyma-project/kyma-environment-broker/internal/provisioner"
kebRuntime "github.com/kyma-project/kyma-environment-broker/internal/runtime"
"github.com/kyma-project/kyma-environment-broker/internal/storage"
Expand Down Expand Up @@ -250,23 +249,17 @@ func NewBrokerSuiteTestWithConfig(t *testing.T, cfg *Config, version ...string)
upgradeEvaluationManager := avs.NewEvaluationManager(avsDel, avs.Config{})
runtimeLister := kebOrchestration.NewRuntimeLister(db.Instances(), db.Operations(), kebRuntime.NewConverter(defaultRegion), logs)
runtimeResolver := orchestration.NewGardenerRuntimeResolver(gardenerClient, fixedGardenerNamespace, runtimeLister, logs)
kymaQueue := NewKymaOrchestrationProcessingQueue(ctx, db, provisionerClient, eventBroker, inputFactory, &upgrade_kyma.TimeSchedule{
Retry: 10 * time.Millisecond,
StatusCheck: 100 * time.Millisecond,
UpgradeKymaTimeout: 3 * time.Second,
}, 250*time.Millisecond, runtimeResolver, upgradeEvaluationManager, cfg, avs.NewInternalEvalAssistant(cfg.Avs), notificationBundleBuilder, logs, cli, 1000)

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)

kymaQueue.SpeedUp(1000)
clusterQueue.SpeedUp(1000)

// TODO: in case of cluster upgrade the same Azure Zones must be send to the Provisioner
orchestrationHandler := orchestrate.NewOrchestrationHandler(db, kymaQueue, clusterQueue, cfg.MaxPaginationPage, logs)
orchestrationHandler := orchestrate.NewOrchestrationHandler(db, clusterQueue, cfg.MaxPaginationPage, logs)
orchestrationHandler.AttachRoutes(ts.router)

expirationHandler := expiration.NewHandler(db.Instances(), db.Operations(), deprovisioningQueue, logs)
Expand Down
5 changes: 1 addition & 4 deletions cmd/broker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,11 @@ func main() {
runtimeLister := orchestration.NewRuntimeLister(db.Instances(), db.Operations(), runtime.NewConverter(cfg.DefaultRequestRegion), logs)
runtimeResolver := orchestrationExt.NewGardenerRuntimeResolver(dynamicGardener, gardenerNamespace, runtimeLister, logs)

kymaQueue := NewKymaOrchestrationProcessingQueue(ctx, db, provisionerClient, eventBroker, inputFactory, nil, time.Minute, runtimeResolver, upgradeEvalManager, &cfg, internalEvalAssistant, notificationBuilder, logs, cli, 1)
clusterQueue := NewClusterOrchestrationProcessingQueue(ctx, db, provisionerClient, eventBroker, inputFactory,
nil, time.Minute, runtimeResolver, upgradeEvalManager, 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, kymaQueue, clusterQueue, cfg.MaxPaginationPage, logs)
orchestrationHandler := orchestrate.NewOrchestrationHandler(db, clusterQueue, cfg.MaxPaginationPage, logs)

if !cfg.DisableProcessOperationsInProgress {
err = processOperationsInProgressByType(internal.OperationTypeProvision, db.Operations(), provisionQueue, logs)
Expand All @@ -373,8 +372,6 @@ func main() {
fatalOnError(err, logs)
err = processOperationsInProgressByType(internal.OperationTypeUpdate, db.Operations(), updateQueue, logs)
fatalOnError(err, logs)
err = reprocessOrchestrations(orchestrationExt.UpgradeKymaOrchestration, db.Orchestrations(), db.Operations(), kymaQueue, logs)
fatalOnError(err, logs)
err = reprocessOrchestrations(orchestrationExt.UpgradeClusterOrchestration, db.Orchestrations(), db.Operations(), clusterQueue, logs)
fatalOnError(err, logs)
} else {
Expand Down
10 changes: 0 additions & 10 deletions cmd/broker/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"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/process/upgrade_kyma"
"github.com/kyma-project/kyma-environment-broker/internal/provisioner"
kebRuntime "github.com/kyma-project/kyma-environment-broker/internal/runtime"
"github.com/kyma-project/kyma-environment-broker/internal/storage"
Expand Down Expand Up @@ -78,7 +77,6 @@ var (
type OrchestrationSuite struct {
gardenerNamespace string
provisionerClient *provisioner.FakeClient
kymaQueue *process.Queue
clusterQueue *process.Queue
storage storage.BrokerStorage
gardenerClient dynamic.Interface
Expand Down Expand Up @@ -161,25 +159,17 @@ func NewOrchestrationSuite(t *testing.T, additionalKymaVersions []string) *Orche
notificationFakeClient := notification.NewFakeClient()
notificationBundleBuilder := notification.NewBundleBuilder(notificationFakeClient, cfg.Notification)

kymaQueue := NewKymaOrchestrationProcessingQueue(ctx, db, provisionerClient, eventBroker, inputFactory, &upgrade_kyma.TimeSchedule{
Retry: 2 * time.Millisecond,
StatusCheck: 20 * time.Millisecond,
UpgradeKymaTimeout: 4 * time.Second,
}, 250*time.Millisecond, runtimeResolver, upgradeEvaluationManager, &cfg, avs.NewInternalEvalAssistant(cfg.Avs), notificationBundleBuilder, logs, cli, 1000)

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

kymaQueue.SpeedUp(1000)
clusterQueue.SpeedUp(1000)

return &OrchestrationSuite{
gardenerNamespace: gardenerNamespace,
provisionerClient: provisionerClient,
kymaQueue: kymaQueue,
clusterQueue: clusterQueue,
storage: db,
gardenerClient: gardenerClient,
Expand Down
114 changes: 114 additions & 0 deletions cmd/broker/upgrade_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import (
"fmt"
"net/http"
"testing"
"time"

"github.com/google/uuid"
"github.com/kyma-project/control-plane/components/provisioner/pkg/gqlschema"
"github.com/kyma-project/kyma-environment-broker/internal/ptr"
"k8s.io/apimachinery/pkg/util/wait"

"github.com/pivotal-cf/brokerapi/v8/domain"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -154,3 +160,111 @@ func TestClusterUpgrade_UpgradeAfterUpdateWithNetworkPolicy(t *testing.T) {
"kyma-project.io/platform-region": "cf-eu10",
})
}

func TestClusterUpgradeUsesUpdatedAutoscalerParams(t *testing.T) {
// given
suite := NewBrokerSuiteTest(t)
defer suite.TearDown()
iid := uuid.New().String()

// Create an SKR with a default autoscaler params
resp := suite.CallAPI("PUT", fmt.Sprintf("oauth/cf-eu10/v2/service_instances/%s?accepts_incomplete=true", iid),
`{
"service_id": "47c9dcbf-ff30-448e-ab36-d3bad66ba281",
"plan_id": "4deee563-e5ec-4731-b9b1-53b42d855f0c",
"context": {
"globalaccount_id": "g-account-id",
"subaccount_id": "sub-id",
"user_id": "[email protected]",
"sm_platform_credentials": {
"url": "https://sm.url",
"credentials": {}
}
},
"parameters": {
"name": "testing-cluster",
"region": "eastus"
}
}`)
opID := suite.DecodeOperationID(resp)
suite.processProvisioningByOperationID(opID)
suite.WaitForOperationState(opID, domain.Succeeded)

// perform an update with custom autoscaler params
resp = suite.CallAPI("PATCH", fmt.Sprintf("oauth/cf-eu10/v2/service_instances/%s?accepts_incomplete=true", iid), `
{
"service_id": "47c9dcbf-ff30-448e-ab36-d3bad66ba281",
"plan_id": "4deee563-e5ec-4731-b9b1-53b42d855f0c",
"context": {
"globalaccount_id": "g-account-id",
"user_id": "[email protected]"
},
"parameters": {
"autoScalerMin":50,
"autoScalerMax":80,
"maxSurge":13,
"maxUnavailable":9
}
}`)
// then
assert.Equal(t, http.StatusAccepted, resp.StatusCode)
upgradeOperationID := suite.DecodeOperationID(resp)
suite.FinishUpdatingOperationByProvisioner(upgradeOperationID)

// when
orchestrationResp := suite.CallAPI("POST", "upgrade/cluster",
`{
"strategy": {
"type": "parallel",
"schedule": "immediate",
"parallel": {
"workers": 1
}
},
"dryRun": false,
"targets": {
"include": [
{
"subAccount": "sub-id"
}
]
}
}`)
oID := suite.DecodeOrchestrationID(orchestrationResp)

var upgradeKymaOperationID string
err := wait.PollImmediate(5*time.Millisecond, 400*time.Millisecond, func() (bool, error) {
var err error
opResponse := suite.CallAPI("GET", fmt.Sprintf("orchestrations/%s/operations", oID), "")
upgradeKymaOperationID, err = suite.DecodeLastUpgradeKymaOperationIDFromOrchestration(opResponse)
return err == nil, nil
})

require.NoError(t, err)

// then
disabled := false
suite.AssertShootUpgrade(upgradeKymaOperationID, gqlschema.UpgradeShootInput{
GardenerConfig: &gqlschema.GardenerUpgradeInput{
KubernetesVersion: ptr.String("1.18"),
MachineImage: ptr.String("coreos"),
MachineImageVersion: ptr.String("253"),

MaxSurge: ptr.Integer(13),
MaxUnavailable: ptr.Integer(9),

EnableKubernetesVersionAutoUpdate: ptr.Bool(false),
EnableMachineImageVersionAutoUpdate: ptr.Bool(false),

OidcConfig: defaultOIDCConfig(),
ShootNetworkingFilterDisabled: &disabled,
},
Administrators: []string{"[email protected]"},
})

suite.AssertKymaResourceExists(upgradeOperationID)
suite.AssertKymaLabelsExist(upgradeOperationID, map[string]string{
"kyma-project.io/region": "eastus",
"kyma-project.io/platform-region": "cf-eu10",
})
}
Loading

0 comments on commit 2613e6f

Please sign in to comment.