Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShootAndSeedSameRegion - Schema & Feature Flag #796

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/appinfo/runtime_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (h *RuntimeInfoHandler) planNameOrDefault(inst internal.InstanceWithOperati
if inst.ServicePlanName != "" {
return inst.ServicePlanName
}
return broker.Plans(h.plansConfig, "", false, false, false)[inst.ServicePlanID].Name
return broker.Plans(h.plansConfig, "", false, false, false, false)[inst.ServicePlanID].Name
}

func getIfNotZero(in time.Time) *time.Time {
Expand Down
1 change: 1 addition & 0 deletions internal/broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Config struct {
FreeExpirationPeriod time.Duration `envconfig:"default=720h"` // 30 days
SubaccountsIdsToShowTrialExpirationInfo string `envconfig:"default="`
TrialDocsURL string `envconfig:"default="`
EnableShootAndSeedSameRegion bool `envconfig:"default=false"`

Binding BindingConfig
UseSmallerMachineTypes bool `envconfig:"default=false"`
Expand Down
2 changes: 1 addition & 1 deletion internal/broker/instance_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func (b *ProvisionEndpoint) determineLicenceType(planId string) *string {

func (b *ProvisionEndpoint) validator(details *domain.ProvisionDetails, provider internal.CloudProvider, ctx context.Context) (JSONSchemaValidator, error) {
platformRegion, _ := middleware.RegionFromContext(ctx)
plans := Plans(b.plansConfig, provider, b.config.IncludeAdditionalParamsInSchema, euaccess.IsEURestrictedAccess(platformRegion), b.config.UseSmallerMachineTypes)
plans := Plans(b.plansConfig, provider, b.config.IncludeAdditionalParamsInSchema, euaccess.IsEURestrictedAccess(platformRegion), b.config.UseSmallerMachineTypes, b.config.EnableShootAndSeedSameRegion)
plan := plans[details.PlanID]
schema := string(Marshal(plan.Schemas.Instance.Create.Parameters))

Expand Down
3 changes: 2 additions & 1 deletion internal/broker/instance_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ func (b *UpdateEndpoint) isKyma2(instance *internal.Instance) (bool, string, err
}

func (b *UpdateEndpoint) getJsonSchemaValidator(provider internal.CloudProvider, planID string, platformRegion string) (JSONSchemaValidator, error) {
plans := Plans(b.plansConfig, provider, b.config.IncludeAdditionalParamsInSchema, euaccess.IsEURestrictedAccess(platformRegion), b.config.UseSmallerMachineTypes)
// shootAndSeedSameRegion is never enabled for update
plans := Plans(b.plansConfig, provider, b.config.IncludeAdditionalParamsInSchema, euaccess.IsEURestrictedAccess(platformRegion), b.config.UseSmallerMachineTypes, false)
plan := plans[planID]
schema := string(Marshal(plan.Schemas.Instance.Update.Parameters))

Expand Down
60 changes: 32 additions & 28 deletions internal/broker/plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,33 +316,33 @@ func requiredOwnClusterSchemaProperties() []string {
return []string{"name", "kubeconfig", "shootName", "shootDomain"}
}

func SapConvergedCloudSchema(machineTypesDisplay, regionsDisplay map[string]string, machineTypes []string, additionalParams, update bool) *map[string]interface{} {
func SapConvergedCloudSchema(machineTypesDisplay, regionsDisplay map[string]string, machineTypes []string, additionalParams, update bool, shootAndSeedFeatureFlag bool) *map[string]interface{} {
properties := NewProvisioningProperties(machineTypesDisplay, regionsDisplay, machineTypes, SapConvergedCloudRegions(), update)
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties())
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties(), true, shootAndSeedFeatureFlag)
}

func PreviewSchema(machineTypesDisplay, regionsDisplay map[string]string, machineTypes []string, additionalParams, update bool, euAccessRestricted bool) *map[string]interface{} {
properties := NewProvisioningProperties(machineTypesDisplay, regionsDisplay, machineTypes, AWSRegions(euAccessRestricted), update)
properties.Networking = NewNetworkingSchema()
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties())
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties(), false, false)
}

func GCPSchema(machineTypesDisplay, regionsDisplay map[string]string, machineTypes []string, additionalParams, update bool) *map[string]interface{} {
func GCPSchema(machineTypesDisplay, regionsDisplay map[string]string, machineTypes []string, additionalParams, update bool, shootAndSeedFeatureFlag bool) *map[string]interface{} {
properties := NewProvisioningProperties(machineTypesDisplay, regionsDisplay, machineTypes, GcpRegions(), update)
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties())
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties(), true, shootAndSeedFeatureFlag)
}

func AWSSchema(machineTypesDisplay, regionsDisplay map[string]string, machineTypes []string, additionalParams, update bool, euAccessRestricted bool) *map[string]interface{} {
func AWSSchema(machineTypesDisplay, regionsDisplay map[string]string, machineTypes []string, additionalParams, update bool, euAccessRestricted bool, shootAndSeedSameRegion bool) *map[string]interface{} {
properties := NewProvisioningProperties(machineTypesDisplay, regionsDisplay, machineTypes, AWSRegions(euAccessRestricted), update)
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties())
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties(), true, shootAndSeedSameRegion)
}

func AzureSchema(machineTypesDisplay, regionsDisplay map[string]string, machineTypes []string, additionalParams, update bool, euAccessRestricted bool) *map[string]interface{} {
func AzureSchema(machineTypesDisplay, regionsDisplay map[string]string, machineTypes []string, additionalParams, update bool, euAccessRestricted bool, shootAndSeedFeatureFlag bool) *map[string]interface{} {
properties := NewProvisioningProperties(machineTypesDisplay, regionsDisplay, machineTypes, AzureRegions(euAccessRestricted), update)
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties())
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties(), true, shootAndSeedFeatureFlag)
}

func AzureLiteSchema(machineTypesDisplay, regionsDisplay map[string]string, machineTypes []string, additionalParams, update bool, euAccessRestricted bool) *map[string]interface{} {
func AzureLiteSchema(machineTypesDisplay, regionsDisplay map[string]string, machineTypes []string, additionalParams, update bool, euAccessRestricted bool, shootAndSeedFeatureFlag bool) *map[string]interface{} {
properties := NewProvisioningProperties(machineTypesDisplay, regionsDisplay, machineTypes, AzureRegions(euAccessRestricted), update)

properties.AutoScalerMax.Minimum = 2
Expand All @@ -354,7 +354,7 @@ func AzureLiteSchema(machineTypesDisplay, regionsDisplay map[string]string, mach
properties.AutoScalerMin.Default = 2
}

return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties())
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties(), true, shootAndSeedFeatureFlag)
}

func FreemiumSchema(provider internal.CloudProvider, regionsDisplay map[string]string, additionalParams, update bool, euAccessRestricted bool) *map[string]interface{} {
Expand Down Expand Up @@ -385,7 +385,7 @@ func FreemiumSchema(provider internal.CloudProvider, regionsDisplay map[string]s
properties.Modules = NewModulesSchema()
}

return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties())
return createSchemaWithProperties(properties, additionalParams, update, requiredSchemaProperties(), false, false)
}

func TrialSchema(additionalParams, update bool) *map[string]interface{} {
Expand All @@ -401,7 +401,7 @@ func TrialSchema(additionalParams, update bool) *map[string]interface{} {
return empty()
}

return createSchemaWithProperties(properties, additionalParams, update, requiredTrialSchemaProperties())
return createSchemaWithProperties(properties, additionalParams, update, requiredTrialSchemaProperties(), false, false)
}

func OwnClusterSchema(update bool) *map[string]interface{} {
Expand All @@ -427,15 +427,19 @@ func empty() *map[string]interface{} {
return &empty
}

func createSchemaWithProperties(properties ProvisioningProperties, additionalParams, update bool, requiered []string) *map[string]interface{} {
func createSchemaWithProperties(properties ProvisioningProperties, additionalParams, update bool, required []string, shootAndSeedSameRegion bool, shootAndSeedFeatureFlag bool) *map[string]interface{} {
if additionalParams {
properties.IncludeAdditional()
}

if shootAndSeedFeatureFlag && additionalParams && shootAndSeedSameRegion {
jaroslaw-pieszka marked this conversation as resolved.
Show resolved Hide resolved
properties.ShootAndSeedSameRegion = ShootAndSeedSameRegionProperty()
}

if update {
return createSchemaWith(properties.UpdateProperties, update, requiered)
return createSchemaWith(properties.UpdateProperties, update, required)
} else {
return createSchemaWith(properties, update, requiered)
return createSchemaWith(properties, update, required)
}
}

Expand All @@ -461,7 +465,7 @@ func unmarshalSchema(schema *RootSchema) *map[string]interface{} {

// Plans is designed to hold plan defaulting logic
// keep internal/hyperscaler/azure/config.go in sync with any changes to available zones
func Plans(plans PlansConfig, provider internal.CloudProvider, includeAdditionalParamsInSchema bool, euAccessRestricted bool, useSmallerMachineTypes bool) map[string]domain.ServicePlan {
func Plans(plans PlansConfig, provider internal.CloudProvider, includeAdditionalParamsInSchema bool, euAccessRestricted bool, useSmallerMachineTypes bool, shootAndSeedFeatureFlag bool) map[string]domain.ServicePlan {
awsMachineNames := AwsMachinesNames()
awsMachinesDisplay := AwsMachinesDisplay()
awsRegionsDisplay := AWSRegionsDisplay()
Expand All @@ -482,27 +486,27 @@ func Plans(plans PlansConfig, provider internal.CloudProvider, includeAdditional
delete(azureLiteMachinesDisplay, "Standard_D2s_v5")
}

awsSchema := AWSSchema(awsMachinesDisplay, awsRegionsDisplay, awsMachineNames, includeAdditionalParamsInSchema, false, euAccessRestricted)
awsSchema := AWSSchema(awsMachinesDisplay, awsRegionsDisplay, awsMachineNames, includeAdditionalParamsInSchema, false, euAccessRestricted, shootAndSeedFeatureFlag)
// awsHASchema := AWSHASchema(awsMachinesDisplay, awsMachines, includeAdditionalParamsInSchema, false)
azureSchema := AzureSchema(azureMachinesDisplay, azureRegionsDisplay, azureMachinesNames, includeAdditionalParamsInSchema, false, euAccessRestricted)
azureLiteSchema := AzureLiteSchema(azureLiteMachinesDisplay, azureRegionsDisplay, azureLiteMachinesNames, includeAdditionalParamsInSchema, false, euAccessRestricted)
azureSchema := AzureSchema(azureMachinesDisplay, azureRegionsDisplay, azureMachinesNames, includeAdditionalParamsInSchema, false, euAccessRestricted, shootAndSeedFeatureFlag)
azureLiteSchema := AzureLiteSchema(azureLiteMachinesDisplay, azureRegionsDisplay, azureLiteMachinesNames, includeAdditionalParamsInSchema, false, euAccessRestricted, shootAndSeedFeatureFlag)
freemiumSchema := FreemiumSchema(provider, azureRegionsDisplay, includeAdditionalParamsInSchema, false, euAccessRestricted)
gcpSchema := GCPSchema(gcpMachinesDisplay, gcpRegionsDisplay, gcpMachinesNames, includeAdditionalParamsInSchema, false)
gcpSchema := GCPSchema(gcpMachinesDisplay, gcpRegionsDisplay, gcpMachinesNames, includeAdditionalParamsInSchema, false, shootAndSeedFeatureFlag)
ownClusterSchema := OwnClusterSchema(false)
previewCatalogSchema := PreviewSchema(awsMachinesDisplay, awsRegionsDisplay, awsMachineNames, includeAdditionalParamsInSchema, false, euAccessRestricted)
sapConvergedCloudSchema := SapConvergedCloudSchema(sapConvergedCloudMachinesDisplay, sapConvergedCloudRegionsDisplay, sapConvergedCloudMachinesNames, includeAdditionalParamsInSchema, false)
sapConvergedCloudSchema := SapConvergedCloudSchema(sapConvergedCloudMachinesDisplay, sapConvergedCloudRegionsDisplay, sapConvergedCloudMachinesNames, includeAdditionalParamsInSchema, false, shootAndSeedFeatureFlag)
trialSchema := TrialSchema(includeAdditionalParamsInSchema, false)

outputPlans := map[string]domain.ServicePlan{
AWSPlanID: defaultServicePlan(AWSPlanID, AWSPlanName, plans, awsSchema, AWSSchema(awsMachinesDisplay, awsRegionsDisplay, awsMachineNames, includeAdditionalParamsInSchema, true, euAccessRestricted)),
GCPPlanID: defaultServicePlan(GCPPlanID, GCPPlanName, plans, gcpSchema, GCPSchema(gcpMachinesDisplay, gcpRegionsDisplay, gcpMachinesNames, includeAdditionalParamsInSchema, true)),
SapConvergedCloudPlanID: defaultServicePlan(SapConvergedCloudPlanID, SapConvergedCloudPlanName, plans, sapConvergedCloudSchema, SapConvergedCloudSchema(sapConvergedCloudMachinesDisplay, sapConvergedCloudRegionsDisplay, sapConvergedCloudMachinesNames, includeAdditionalParamsInSchema, true)),
AzurePlanID: defaultServicePlan(AzurePlanID, AzurePlanName, plans, azureSchema, AzureSchema(azureMachinesDisplay, azureRegionsDisplay, azureMachinesNames, includeAdditionalParamsInSchema, true, euAccessRestricted)),
AzureLitePlanID: defaultServicePlan(AzureLitePlanID, AzureLitePlanName, plans, azureLiteSchema, AzureLiteSchema(azureLiteMachinesDisplay, azureRegionsDisplay, azureLiteMachinesNames, includeAdditionalParamsInSchema, true, euAccessRestricted)),
AWSPlanID: defaultServicePlan(AWSPlanID, AWSPlanName, plans, awsSchema, AWSSchema(awsMachinesDisplay, awsRegionsDisplay, awsMachineNames, includeAdditionalParamsInSchema, true, euAccessRestricted, shootAndSeedFeatureFlag)),
GCPPlanID: defaultServicePlan(GCPPlanID, GCPPlanName, plans, gcpSchema, GCPSchema(gcpMachinesDisplay, gcpRegionsDisplay, gcpMachinesNames, includeAdditionalParamsInSchema, true, shootAndSeedFeatureFlag)),
SapConvergedCloudPlanID: defaultServicePlan(SapConvergedCloudPlanID, SapConvergedCloudPlanName, plans, sapConvergedCloudSchema, SapConvergedCloudSchema(sapConvergedCloudMachinesDisplay, sapConvergedCloudRegionsDisplay, sapConvergedCloudMachinesNames, includeAdditionalParamsInSchema, true, shootAndSeedFeatureFlag)),
AzurePlanID: defaultServicePlan(AzurePlanID, AzurePlanName, plans, azureSchema, AzureSchema(azureMachinesDisplay, azureRegionsDisplay, azureMachinesNames, includeAdditionalParamsInSchema, true, euAccessRestricted, shootAndSeedFeatureFlag)),
AzureLitePlanID: defaultServicePlan(AzureLitePlanID, AzureLitePlanName, plans, azureLiteSchema, AzureLiteSchema(azureLiteMachinesDisplay, azureRegionsDisplay, azureLiteMachinesNames, includeAdditionalParamsInSchema, true, euAccessRestricted, shootAndSeedFeatureFlag)),
FreemiumPlanID: defaultServicePlan(FreemiumPlanID, FreemiumPlanName, plans, freemiumSchema, FreemiumSchema(provider, azureRegionsDisplay, includeAdditionalParamsInSchema, true, euAccessRestricted)),
TrialPlanID: defaultServicePlan(TrialPlanID, TrialPlanName, plans, trialSchema, TrialSchema(includeAdditionalParamsInSchema, true)),
OwnClusterPlanID: defaultServicePlan(OwnClusterPlanID, OwnClusterPlanName, plans, ownClusterSchema, OwnClusterSchema(true)),
PreviewPlanID: defaultServicePlan(PreviewPlanID, PreviewPlanName, plans, previewCatalogSchema, AWSSchema(awsMachinesDisplay, awsRegionsDisplay, awsMachineNames, includeAdditionalParamsInSchema, true, euAccessRestricted)),
PreviewPlanID: defaultServicePlan(PreviewPlanID, PreviewPlanName, plans, previewCatalogSchema, AWSSchema(awsMachinesDisplay, awsRegionsDisplay, awsMachineNames, includeAdditionalParamsInSchema, true, euAccessRestricted, false)),
}

return outputPlans
Expand Down
24 changes: 17 additions & 7 deletions internal/broker/plans_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ type RootSchema struct {
type ProvisioningProperties struct {
UpdateProperties

Name NameType `json:"name"`
ShootName *Type `json:"shootName,omitempty"`
ShootDomain *Type `json:"shootDomain,omitempty"`
Region *Type `json:"region,omitempty"`
Networking *NetworkingType `json:"networking,omitempty"`
Modules *Modules `json:"modules,omitempty"`
Name NameType `json:"name"`
ShootName *Type `json:"shootName,omitempty"`
ShootDomain *Type `json:"shootDomain,omitempty"`
Region *Type `json:"region,omitempty"`
Networking *NetworkingType `json:"networking,omitempty"`
Modules *Modules `json:"modules,omitempty"`
ShootAndSeedSameRegion *Type `json:"shootAndSeedSameRegion,omitempty"`
}

type UpdateProperties struct {
Expand Down Expand Up @@ -263,6 +264,15 @@ func ShootDomainProperty() *Type {
}
}

func ShootAndSeedSameRegionProperty() *Type {
return &Type{
Type: "boolean",
Title: "Enforce Same Location for Seed and Shoot",
Default: false,
Description: "If set to true a Gardener seed will be placed in the same region as the selected region from the Region field. Provisioning process will fail if no seed is availabie in the region.",
}
}

// NewProvisioningProperties creates a new properties for different plans
// Note that the order of properties will be the same in the form on the website
func NewProvisioningProperties(machineTypesDisplay, regionsDisplay map[string]string, machineTypes, regions []string, update bool) ProvisioningProperties {
Expand Down Expand Up @@ -370,7 +380,7 @@ func unmarshalOrPanic(from, to interface{}) interface{} {
}

func DefaultControlsOrder() []string {
return []string{"name", "kubeconfig", "shootName", "shootDomain", "region", "machineType", "autoScalerMin", "autoScalerMax", "zonesCount", "modules", "networking", "oidc", "administrators"}
return []string{"name", "kubeconfig", "shootName", "shootDomain", "region", "shootAndSeedSameRegion", "machineType", "autoScalerMin", "autoScalerMax", "zonesCount", "modules", "networking", "oidc", "administrators"}
}

func ToInterfaceSlice(input []string) []interface{} {
Expand Down
Loading
Loading