Bump ocp to 4.10.20, revert workarounds for BZ 2093044

Revert "Add name length validation on ARO clusters for non-zonal regions"
This reverts commit 13c3290ffc.

Revert "Typo in pipeline script"
This reverts commit 6e1acd4f13.

Revert "Truncate cluster names to 19 char in e2e pipelines"
This reverts commit b2273bdc6a.

Removed test cases in pkg/api/v20220904/openshiftcluster_validatestatic_test.go for cluster
name length validation, these tests are no longer needed as BZ 2093044 is fixed in 4.10.20
This commit is contained in:
tschneid 2022-07-07 11:00:56 -05:00
Родитель 6a5f514b68
Коммит bea9aec2d8
22 изменённых файлов: 60 добавлений и 490 удалений

Просмотреть файл

@ -48,16 +48,7 @@ stages:
- script: |
# Pass variables between tasks: https://medium.com/microsoftazure/how-to-pass-variables-in-azure-pipelines-yaml-tasks-5c81c5d31763
echo "##vso[task.setvariable variable=REGION]$LOCATION"
# TODO: Remove this hack after AvailabilitySet name too long bug is fixed.
NONZONAL_REGIONS="australiacentral australiacentral2 australiasoutheast brazilsoutheast canadaeast japanwest northcentralus norwaywest southindia switzerlandwest uaenorth ukwest westcentralus westus"
if echo $NONZONAL_REGIONS | grep -wq $LOCATION
then
CLUSTER=$(head -c 19 <<< "v4-e2e-V$BUILD_BUILDID-$LOCATION")
else
CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
fi
# TODO: Uncomment next line after above hack is removed.
# CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
echo "##vso[task.setvariable variable=CLUSTER]$CLUSTER"
CLUSTER_RESOURCEGROUP="v4-e2e-V$BUILD_BUILDID-$LOCATION"
echo "##vso[task.setvariable variable=CLUSTER_RESOURCEGROUP]$CLUSTER_RESOURCEGROUP"

Просмотреть файл

@ -87,17 +87,7 @@ jobs:
- script: |
# Pass variables between tasks: https://medium.com/microsoftazure/how-to-pass-variables-in-azure-pipelines-yaml-tasks-5c81c5d31763
echo "##vso[task.setvariable variable=REGION]${{ location }}"
# TODO: Remove this hack after AvailabilitySet name too long bug is fixed.
LOCATION=${{ location }}
NONZONAL_REGIONS="australiacentral australiacentral2 australiasoutheast brazilsoutheast canadaeast japanwest northcentralus norwaywest southindia switzerlandwest uaenorth ukwest westcentralus westus"
if echo $NONZONAL_REGIONS | grep -wq $LOCATION
then
CLUSTER=$(head -c 19 <<< "v4-e2e-V$BUILD_BUILDID-$LOCATION")
else
CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
fi
# TODO: Uncomment next line after above hack is removed.
# CLUSTER="v4-e2e-V$BUILD_BUILDID-${{ location }}"
CLUSTER="v4-e2e-V$BUILD_BUILDID-${{ location }}"
echo "##vso[task.setvariable variable=CLUSTER]$CLUSTER"
CLUSTER_RESOURCEGROUP="v4-e2e-V$BUILD_BUILDID-${{ location }}"
echo "##vso[task.setvariable variable=CLUSTER_RESOURCEGROUP]$CLUSTER_RESOURCEGROUP"

Просмотреть файл

@ -83,17 +83,7 @@ jobs:
- script: |
# Pass variables between tasks: https://medium.com/microsoftazure/how-to-pass-variables-in-azure-pipelines-yaml-tasks-5c81c5d31763
echo "##vso[task.setvariable variable=REGION]${{ location }}"
# TODO: Remove this hack after AvailabilitySet name too long bug is fixed.
LOCATION=${{ location }}
NONZONAL_REGIONS="australiacentral australiacentral2 australiasoutheast brazilsoutheast canadaeast japanwest northcentralus norwaywest southindia switzerlandwest uaenorth ukwest westcentralus westus"
if echo $NONZONAL_REGIONS | grep -wq $LOCATION
then
CLUSTER=$(head -c 19 <<< "v4-e2e-V$BUILD_BUILDID-$LOCATION")
else
CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
fi
# TODO: Uncomment next line after above hack is removed.
# CLUSTER="v4-e2e-V$BUILD_BUILDID-${{ location }}"
CLUSTER="v4-e2e-V$BUILD_BUILDID-${{ location }}"
echo "##vso[task.setvariable variable=CLUSTER]$CLUSTER"
CLUSTER_RESOURCEGROUP="v4-e2e-V$BUILD_BUILDID-${{ location }}"
echo "##vso[task.setvariable variable=CLUSTER_RESOURCEGROUP]$CLUSTER_RESOURCEGROUP"

Просмотреть файл

@ -35,14 +35,6 @@ steps:
export AZURE_FP_CLIENT_ID=f1dd0a37-89c6-4e07-bcd1-ffd3d43d8875
export AZURE_FP_SERVICE_PRINCIPAL_ID=50c17c64-bc11-4fdd-a339-0ecd396bf911
fi
# TODO: Remove this after AvailabilitySet name too long bug is fixed.
NONZONAL_REGIONS="australiacentral australiacentral2 australiasoutheast brazilsoutheast canadaeast japanwest northcentralus norwaywest southindia switzerlandwest uaenorth ukwest westcentralus westus"
if echo $NONZONAL_REGIONS | grep -wq $LOCATION
then
CLUSTER=$(head -c 19 <<< "v4-e2e-V$BUILD_BUILDID-$LOCATION")
else
CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
fi
# TODO: remove --env RESOURCEGROUP after next RP deployment.
# TODO: e2e.test arguments need to move inside the container somehow. Maybe
@ -58,7 +50,7 @@ steps:
--env AZURE_SUBSCRIPTION_ID \
--env LOCATION \
--env RESOURCEGROUP="v4-e2e-V$BUILD_BUILDID-$LOCATION" \
--env CLUSTER="$CLUSTER" \
--env CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION" \
--entrypoint e2e.test \
"$IMAGE:$VERSION" \
-test.timeout 180m -test.v -ginkgo.v

Просмотреть файл

@ -43,18 +43,7 @@ stages:
- script: |
# Pass variables between tasks: https://medium.com/microsoftazure/how-to-pass-variables-in-azure-pipelines-yaml-tasks-5c81c5d31763
echo "##vso[task.setvariable variable=REGION]${{ parameters.location }}"
# TODO: Remove this hack after AvailabilitySet name too long bug is fixed.
LOCATION=${{ parameters.location }}
NONZONAL_REGIONS="australiacentral australiacentral2 australiasoutheast brazilsoutheast canadaeast japanwest northcentralus norwaywest southindia switzerlandwest uaenorth ukwest westcentralus westus"
if echo $NONZONAL_REGIONS | grep -wq $LOCATION
then
CLUSTER=$(head -c 19 <<< "v4-e2e-V$BUILD_BUILDID-$LOCATION")
else
CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
fi
# TODO: Uncomment next line after above hack is removed.
# CLUSTER="v4-e2e-V$BUILD_BUILDID-${{ parameters.location }}"
CLUSTER="v4-e2e-V$BUILD_BUILDID-${{ parameters.location }}"
echo "##vso[task.setvariable variable=CLUSTER]$CLUSTER"
CLUSTER_RESOURCEGROUP="v4-e2e-V$BUILD_BUILDID-${{ parameters.location }}"
echo "##vso[task.setvariable variable=CLUSTER_RESOURCEGROUP]$CLUSTER_RESOURCEGROUP"

Просмотреть файл

@ -72,19 +72,9 @@ clean_e2e_db(){
# if LOCAL_E2E is set, set the value with the local test names
# If it it not set, it defaults to the build ID
if [ -z "${LOCAL_E2E}" ] ; then
# TODO: Remove this hack after AvailabilitySet name too long bug is fixed.
NONZONAL_REGIONS="australiacentral australiacentral2 australiasoutheast brazilsoutheast canadaeast japanwest northcentralus norwaywest southindia switzerlandwest uaenorth ukwest westcentralus westus"
if echo $NONZONAL_REGIONS | grep -wq $LOCATION
then
export CLUSTER=$(head -c 19 <<< "v4-e2e-V$BUILD_BUILDID-$LOCATION")
else
export CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
fi
# TODO: uncomment after above hack is removed.
# export CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
# If it it not set, it defaults to the build ID
if [ -z "${LOCAL_E2E}" ] ; then
export CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
export DATABASE_NAME="v4-e2e-V$BUILD_BUILDID-$LOCATION"
fi

Просмотреть файл

@ -1,7 +1,4 @@
allowedImportNames:
github.com/Azure/ARO-RP/pkg/api/validate:
- ""
- apiValidate
github.com/Azure/ARO-RP/pkg/frontend/middleware:
- ""
- frontendmiddleware

Просмотреть файл

@ -71,13 +71,6 @@ func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCrea
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "location", "The provided location '%s' is invalid.", oc.Location)
}
// TODO: remove the VM name validation after https://bugzilla.redhat.com/show_bug.cgi?id=2093044 is resolved
if isCreate {
if !validate.OpenShiftClusterNameLength(oc.Name, oc.Location) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "name", "The provided cluster name '%s' exceeds the maximum cluster name length of '%d'.", oc.Name, validate.MaxClusterNameLength)
}
}
return sv.validateProperties("properties", &oc.Properties, isCreate)
}

Просмотреть файл

@ -10,19 +10,15 @@ import (
"testing"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
"github.com/gofrs/uuid"
"github.com/Azure/ARO-RP/pkg/api"
apiValidate "github.com/Azure/ARO-RP/pkg/api/validate"
"github.com/Azure/ARO-RP/pkg/util/version"
"github.com/Azure/ARO-RP/test/validate"
)
type validateTest struct {
name string
clusterName *string
location *string
current func(oc *OpenShiftCluster)
modify func(oc *OpenShiftCluster)
requireD2sV3Workers bool
@ -38,18 +34,15 @@ const (
var (
subscriptionID = "00000000-0000-0000-0000-000000000000"
id = fmt.Sprintf("/subscriptions/%s/resourcegroups/resourceGroup/providers/microsoft.redhatopenshift/openshiftclusters/resourceName", subscriptionID)
)
func getResourceID(clusterName string) string {
return fmt.Sprintf("/subscriptions/%s/resourcegroups/resourceGroup/providers/microsoft.redhatopenshift/openshiftclusters/%s", subscriptionID, clusterName)
}
func validOpenShiftCluster(name, location string) *OpenShiftCluster {
func validOpenShiftCluster() *OpenShiftCluster {
oc := &OpenShiftCluster{
ID: getResourceID(name),
Name: name,
ID: id,
Name: "resourceName",
Type: "Microsoft.RedHatOpenShift/OpenShiftClusters",
Location: location,
Location: "location",
Tags: Tags{
"key": "value",
},
@ -107,31 +100,22 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
t.Run(string(mode), func(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// default values if not set
if tt.location == nil {
tt.location = to.StringPtr("location")
}
if tt.clusterName == nil {
tt.clusterName = to.StringPtr("resourceName")
}
v := &openShiftClusterStaticValidator{
location: *tt.location,
location: "location",
domain: "location.aroapp.io",
requireD2sV3Workers: tt.requireD2sV3Workers,
resourceID: getResourceID(*tt.clusterName),
resourceID: id,
r: azure.Resource{
SubscriptionID: subscriptionID,
ResourceGroup: "resourceGroup",
Provider: "Microsoft.RedHatOpenShift",
ResourceType: "openshiftClusters",
ResourceName: *tt.clusterName,
ResourceName: "resourceName",
},
}
validOCForTest := func() *OpenShiftCluster {
oc := validOpenShiftCluster(*tt.clusterName, *tt.location)
oc := validOpenShiftCluster()
if tt.current != nil {
tt.current(oc)
}
@ -176,11 +160,7 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
}
func TestOpenShiftClusterStaticValidate(t *testing.T) {
clusterName19 := "19characters-aaaaaa"
clusterName30 := "thisis30characterslong-aaaaaa"
nonZonalRegion := "australiasoutheast"
commonTests := []*validateTest{
tests := []*validateTest{
{
name: "valid",
},
@ -212,38 +192,10 @@ func TestOpenShiftClusterStaticValidate(t *testing.T) {
},
wantErr: "400: InvalidParameter: location: The provided location 'invalid' is invalid.",
},
{
name: "valid - zonal regions can exceed max cluster name length",
clusterName: &clusterName30,
},
}
createTests := []*validateTest{
{
name: "invalid - non-zonal regions cannot exceed max cluster name length on cluster create",
clusterName: &clusterName30,
location: &nonZonalRegion,
wantErr: fmt.Sprintf("400: InvalidParameter: name: The provided cluster name '%s' exceeds the maximum cluster name length of '%d'.", clusterName30, apiValidate.MaxClusterNameLength),
},
{
name: "valid - non-zonal region less than max cluster name length",
clusterName: &clusterName19,
location: &nonZonalRegion,
},
}
updateTests := []*validateTest{
{
name: "valid - existing cluster names > max cluster name length still work on cluster update",
clusterName: &clusterName30,
location: &nonZonalRegion,
},
}
runTests(t, testModeCreate, commonTests)
runTests(t, testModeUpdate, commonTests)
runTests(t, testModeCreate, createTests)
runTests(t, testModeUpdate, updateTests)
runTests(t, testModeCreate, tests)
runTests(t, testModeUpdate, tests)
}
func TestOpenShiftClusterStaticValidateProperties(t *testing.T) {

Просмотреть файл

@ -71,13 +71,6 @@ func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCrea
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "location", "The provided location '%s' is invalid.", oc.Location)
}
// TODO: remove the VM name validation after https://bugzilla.redhat.com/show_bug.cgi?id=2093044 is resolved
if isCreate {
if !validate.OpenShiftClusterNameLength(oc.Name, oc.Location) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "name", "The provided cluster name '%s' exceeds the maximum cluster name length of '%d'.", oc.Name, validate.MaxClusterNameLength)
}
}
return sv.validateProperties("properties", &oc.Properties, isCreate)
}

Просмотреть файл

@ -10,19 +10,15 @@ import (
"testing"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
"github.com/gofrs/uuid"
"github.com/Azure/ARO-RP/pkg/api"
apiValidate "github.com/Azure/ARO-RP/pkg/api/validate"
"github.com/Azure/ARO-RP/pkg/util/version"
"github.com/Azure/ARO-RP/test/validate"
)
type validateTest struct {
name string
clusterName *string
location *string
current func(oc *OpenShiftCluster)
modify func(oc *OpenShiftCluster)
requireD2sV3Workers bool
@ -38,18 +34,15 @@ const (
var (
subscriptionID = "00000000-0000-0000-0000-000000000000"
id = fmt.Sprintf("/subscriptions/%s/resourcegroups/resourceGroup/providers/microsoft.redhatopenshift/openshiftclusters/resourceName", subscriptionID)
)
func getResourceID(clusterName string) string {
return fmt.Sprintf("/subscriptions/%s/resourcegroups/resourceGroup/providers/microsoft.redhatopenshift/openshiftclusters/%s", subscriptionID, clusterName)
}
func validOpenShiftCluster(name, location string) *OpenShiftCluster {
func validOpenShiftCluster() *OpenShiftCluster {
oc := &OpenShiftCluster{
ID: getResourceID(name),
Name: name,
ID: id,
Name: "resourceName",
Type: "Microsoft.RedHatOpenShift/OpenShiftClusters",
Location: location,
Location: "location",
Tags: Tags{
"key": "value",
},
@ -107,31 +100,22 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
t.Run(string(mode), func(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// default values if not set
if tt.location == nil {
tt.location = to.StringPtr("location")
}
if tt.clusterName == nil {
tt.clusterName = to.StringPtr("resourceName")
}
v := &openShiftClusterStaticValidator{
location: *tt.location,
location: "location",
domain: "location.aroapp.io",
requireD2sV3Workers: tt.requireD2sV3Workers,
resourceID: getResourceID(*tt.clusterName),
resourceID: id,
r: azure.Resource{
SubscriptionID: subscriptionID,
ResourceGroup: "resourceGroup",
Provider: "Microsoft.RedHatOpenShift",
ResourceType: "openshiftClusters",
ResourceName: *tt.clusterName,
ResourceName: "resourceName",
},
}
validOCForTest := func() *OpenShiftCluster {
oc := validOpenShiftCluster(*tt.clusterName, *tt.location)
oc := validOpenShiftCluster()
if tt.current != nil {
tt.current(oc)
}
@ -176,11 +160,7 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
}
func TestOpenShiftClusterStaticValidate(t *testing.T) {
clusterName19 := "19characters-aaaaaa"
clusterName30 := "thisis30characterslong-aaaaaa"
nonZonalRegion := "australiasoutheast"
commonTests := []*validateTest{
tests := []*validateTest{
{
name: "valid",
},
@ -212,38 +192,10 @@ func TestOpenShiftClusterStaticValidate(t *testing.T) {
},
wantErr: "400: InvalidParameter: location: The provided location 'invalid' is invalid.",
},
{
name: "valid - zonal regions can exceed max cluster name length",
clusterName: &clusterName30,
},
}
createTests := []*validateTest{
{
name: "invalid - non-zonal regions cannot exceed max cluster name length on cluster create",
clusterName: &clusterName30,
location: &nonZonalRegion,
wantErr: fmt.Sprintf("400: InvalidParameter: name: The provided cluster name '%s' exceeds the maximum cluster name length of '%d'.", clusterName30, apiValidate.MaxClusterNameLength),
},
{
name: "valid - non-zonal region less than max cluster name length",
clusterName: &clusterName19,
location: &nonZonalRegion,
},
}
updateTests := []*validateTest{
{
name: "valid - existing cluster names > max cluster name length still work on cluster update",
clusterName: &clusterName30,
location: &nonZonalRegion,
},
}
runTests(t, testModeCreate, commonTests)
runTests(t, testModeUpdate, commonTests)
runTests(t, testModeCreate, createTests)
runTests(t, testModeUpdate, updateTests)
runTests(t, testModeCreate, tests)
runTests(t, testModeUpdate, tests)
}
func TestOpenShiftClusterStaticValidateProperties(t *testing.T) {

Просмотреть файл

@ -71,13 +71,6 @@ func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCrea
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "location", "The provided location '%s' is invalid.", oc.Location)
}
// TODO: remove the VM name validation after https://bugzilla.redhat.com/show_bug.cgi?id=2093044 is resolved
if isCreate {
if !validate.OpenShiftClusterNameLength(oc.Name, oc.Location) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "name", "The provided cluster name '%s' exceeds the maximum cluster name length of '%d'.", oc.Name, validate.MaxClusterNameLength)
}
}
return sv.validateProperties("properties", &oc.Properties, isCreate)
}

Просмотреть файл

@ -11,19 +11,15 @@ import (
"time"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
"github.com/gofrs/uuid"
"github.com/Azure/ARO-RP/pkg/api"
apiValidate "github.com/Azure/ARO-RP/pkg/api/validate"
"github.com/Azure/ARO-RP/pkg/util/version"
"github.com/Azure/ARO-RP/test/validate"
)
type validateTest struct {
name string
clusterName *string
location *string
current func(oc *OpenShiftCluster)
modify func(oc *OpenShiftCluster)
requireD2sV3Workers bool
@ -39,23 +35,20 @@ const (
var (
subscriptionID = "00000000-0000-0000-0000-000000000000"
id = fmt.Sprintf("/subscriptions/%s/resourcegroups/resourceGroup/providers/microsoft.redhatopenshift/openshiftclusters/resourceName", subscriptionID)
)
func getResourceID(clusterName string) string {
return fmt.Sprintf("/subscriptions/%s/resourcegroups/resourceGroup/providers/microsoft.redhatopenshift/openshiftclusters/%s", subscriptionID, clusterName)
}
func validOpenShiftCluster(name, location string) *OpenShiftCluster {
func validOpenShiftCluster() *OpenShiftCluster {
timestamp, err := time.Parse(time.RFC3339, "2021-01-23T12:34:54.0000000Z")
if err != nil {
panic(err)
}
oc := &OpenShiftCluster{
ID: getResourceID(name),
Name: name,
ID: id,
Name: "resourceName",
Type: "Microsoft.RedHatOpenShift/OpenShiftClusters",
Location: location,
Location: "location",
Tags: Tags{
"key": "value",
},
@ -124,31 +117,22 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
t.Run(string(mode), func(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// default values if not set
if tt.location == nil {
tt.location = to.StringPtr("location")
}
if tt.clusterName == nil {
tt.clusterName = to.StringPtr("resourceName")
}
v := &openShiftClusterStaticValidator{
location: *tt.location,
location: "location",
domain: "location.aroapp.io",
requireD2sV3Workers: tt.requireD2sV3Workers,
resourceID: getResourceID(*tt.clusterName),
resourceID: id,
r: azure.Resource{
SubscriptionID: subscriptionID,
ResourceGroup: "resourceGroup",
Provider: "Microsoft.RedHatOpenShift",
ResourceType: "openshiftClusters",
ResourceName: *tt.clusterName,
ResourceName: "resourceName",
},
}
validOCForTest := func() *OpenShiftCluster {
oc := validOpenShiftCluster(*tt.clusterName, *tt.location)
oc := validOpenShiftCluster()
if tt.current != nil {
tt.current(oc)
}
@ -193,11 +177,7 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
}
func TestOpenShiftClusterStaticValidate(t *testing.T) {
clusterName19 := "19characters-aaaaaa"
clusterName30 := "thisis30characterslong-aaaaaa"
nonZonalRegion := "australiasoutheast"
commonTests := []*validateTest{
tests := []*validateTest{
{
name: "valid",
},
@ -229,38 +209,10 @@ func TestOpenShiftClusterStaticValidate(t *testing.T) {
},
wantErr: "400: InvalidParameter: location: The provided location 'invalid' is invalid.",
},
{
name: "valid - zonal regions can exceed max cluster name length",
clusterName: &clusterName30,
},
}
createTests := []*validateTest{
{
name: "invalid - non-zonal regions cannot exceed max cluster name length on cluster create",
clusterName: &clusterName30,
location: &nonZonalRegion,
wantErr: fmt.Sprintf("400: InvalidParameter: name: The provided cluster name '%s' exceeds the maximum cluster name length of '%d'.", clusterName30, apiValidate.MaxClusterNameLength),
},
{
name: "valid - non-zonal region less than max cluster name length",
clusterName: &clusterName19,
location: &nonZonalRegion,
},
}
updateTests := []*validateTest{
{
name: "valid - existing cluster names > max cluster name length still work on cluster update",
clusterName: &clusterName30,
location: &nonZonalRegion,
},
}
runTests(t, testModeCreate, commonTests)
runTests(t, testModeUpdate, commonTests)
runTests(t, testModeCreate, createTests)
runTests(t, testModeUpdate, updateTests)
runTests(t, testModeCreate, tests)
runTests(t, testModeUpdate, tests)
}
func TestOpenShiftClusterStaticValidateProperties(t *testing.T) {

Просмотреть файл

@ -71,13 +71,6 @@ func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCrea
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "location", "The provided location '%s' is invalid.", oc.Location)
}
// TODO: remove the VM name validation after https://bugzilla.redhat.com/show_bug.cgi?id=2093044 is resolved
if isCreate {
if !validate.OpenShiftClusterNameLength(oc.Name, oc.Location) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "name", "The provided cluster name '%s' exceeds the maximum cluster name length of '%d'.", oc.Name, validate.MaxClusterNameLength)
}
}
return sv.validateProperties("properties", &oc.Properties, isCreate)
}

Просмотреть файл

@ -11,19 +11,15 @@ import (
"time"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
"github.com/gofrs/uuid"
"github.com/Azure/ARO-RP/pkg/api"
apiValidate "github.com/Azure/ARO-RP/pkg/api/validate"
"github.com/Azure/ARO-RP/pkg/util/version"
"github.com/Azure/ARO-RP/test/validate"
)
type validateTest struct {
name string
clusterName *string
location *string
current func(oc *OpenShiftCluster)
modify func(oc *OpenShiftCluster)
requireD2sV3Workers bool
@ -39,23 +35,20 @@ const (
var (
subscriptionID = "00000000-0000-0000-0000-000000000000"
id = fmt.Sprintf("/subscriptions/%s/resourcegroups/resourceGroup/providers/microsoft.redhatopenshift/openshiftclusters/resourceName", subscriptionID)
)
func getResourceID(clusterName string) string {
return fmt.Sprintf("/subscriptions/%s/resourcegroups/resourceGroup/providers/microsoft.redhatopenshift/openshiftclusters/%s", subscriptionID, clusterName)
}
func validOpenShiftCluster(name, location string) *OpenShiftCluster {
func validOpenShiftCluster() *OpenShiftCluster {
timestamp, err := time.Parse(time.RFC3339, "2021-01-23T12:34:54.0000000Z")
if err != nil {
panic(err)
}
oc := &OpenShiftCluster{
ID: getResourceID(name),
Name: name,
ID: id,
Name: "resourceName",
Type: "Microsoft.RedHatOpenShift/OpenShiftClusters",
Location: location,
Location: "location",
Tags: Tags{
"key": "value",
},
@ -124,31 +117,22 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
t.Run(string(mode), func(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// default values if not set
if tt.location == nil {
tt.location = to.StringPtr("location")
}
if tt.clusterName == nil {
tt.clusterName = to.StringPtr("resourceName")
}
v := &openShiftClusterStaticValidator{
location: *tt.location,
location: "location",
domain: "location.aroapp.io",
requireD2sV3Workers: tt.requireD2sV3Workers,
resourceID: getResourceID(*tt.clusterName),
resourceID: id,
r: azure.Resource{
SubscriptionID: subscriptionID,
ResourceGroup: "resourceGroup",
Provider: "Microsoft.RedHatOpenShift",
ResourceType: "openshiftClusters",
ResourceName: *tt.clusterName,
ResourceName: "resourceName",
},
}
validOCForTest := func() *OpenShiftCluster {
oc := validOpenShiftCluster(*tt.clusterName, *tt.location)
oc := validOpenShiftCluster()
if tt.current != nil {
tt.current(oc)
}
@ -193,11 +177,7 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
}
func TestOpenShiftClusterStaticValidate(t *testing.T) {
clusterName19 := "19characters-aaaaaa"
clusterName30 := "thisis30characterslong-aaaaaa"
nonZonalRegion := "australiasoutheast"
commonTests := []*validateTest{
tests := []*validateTest{
{
name: "valid",
},
@ -229,38 +209,10 @@ func TestOpenShiftClusterStaticValidate(t *testing.T) {
},
wantErr: "400: InvalidParameter: location: The provided location 'invalid' is invalid.",
},
{
name: "valid - zonal regions can exceed max cluster name length",
clusterName: &clusterName30,
},
}
createTests := []*validateTest{
{
name: "invalid - non-zonal regions cannot exceed max cluster name length on cluster create",
clusterName: &clusterName30,
location: &nonZonalRegion,
wantErr: fmt.Sprintf("400: InvalidParameter: name: The provided cluster name '%s' exceeds the maximum cluster name length of '%d'.", clusterName30, apiValidate.MaxClusterNameLength),
},
{
name: "valid - non-zonal region less than max cluster name length",
clusterName: &clusterName19,
location: &nonZonalRegion,
},
}
updateTests := []*validateTest{
{
name: "valid - existing cluster names > max cluster name length still work on cluster update",
clusterName: &clusterName30,
location: &nonZonalRegion,
},
}
runTests(t, testModeCreate, commonTests)
runTests(t, testModeUpdate, commonTests)
runTests(t, testModeCreate, createTests)
runTests(t, testModeUpdate, updateTests)
runTests(t, testModeCreate, tests)
runTests(t, testModeUpdate, tests)
}
func TestOpenShiftClusterStaticValidateProperties(t *testing.T) {

Просмотреть файл

@ -71,13 +71,6 @@ func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCrea
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "location", "The provided location '%s' is invalid.", oc.Location)
}
// TODO: remove the VM name validation after https://bugzilla.redhat.com/show_bug.cgi?id=2093044 is resolved
if isCreate {
if !validate.OpenShiftClusterNameLength(oc.Name, oc.Location) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "name", "The provided cluster name '%s' exceeds the maximum cluster name length of '%d'.", oc.Name, validate.MaxClusterNameLength)
}
}
return sv.validateProperties("properties", &oc.Properties, isCreate)
}

Просмотреть файл

@ -15,7 +15,6 @@ import (
"github.com/gofrs/uuid"
"github.com/Azure/ARO-RP/pkg/api"
apiValidate "github.com/Azure/ARO-RP/pkg/api/validate"
"github.com/Azure/ARO-RP/pkg/util/version"
"github.com/Azure/ARO-RP/test/validate"
)
@ -193,10 +192,6 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
}
func TestOpenShiftClusterStaticValidate(t *testing.T) {
clusterName19 := "19characters-aaaaaa"
clusterName30 := "thisis30characterslong-aaaaaa"
nonZonalRegion := "australiasoutheast"
commonTests := []*validateTest{
{
name: "valid",
@ -229,38 +224,10 @@ func TestOpenShiftClusterStaticValidate(t *testing.T) {
},
wantErr: "400: InvalidParameter: location: The provided location 'invalid' is invalid.",
},
{
name: "valid - zonal regions can exceed max cluster name length",
clusterName: &clusterName30,
},
}
createTests := []*validateTest{
{
name: "invalid - non-zonal regions cannot exceed max cluster name length on cluster create",
clusterName: &clusterName30,
location: &nonZonalRegion,
wantErr: fmt.Sprintf("400: InvalidParameter: name: The provided cluster name '%s' exceeds the maximum cluster name length of '%d'.", clusterName30, apiValidate.MaxClusterNameLength),
},
{
name: "valid - non-zonal region less than max cluster name length",
clusterName: &clusterName19,
location: &nonZonalRegion,
},
}
updateTests := []*validateTest{
{
name: "valid - existing cluster names > max cluster name length still work on cluster update",
clusterName: &clusterName30,
location: &nonZonalRegion,
},
}
runTests(t, testModeCreate, commonTests)
runTests(t, testModeUpdate, commonTests)
runTests(t, testModeCreate, createTests)
runTests(t, testModeUpdate, updateTests)
}
func TestOpenShiftClusterStaticValidateProperties(t *testing.T) {

Просмотреть файл

@ -1,53 +0,0 @@
package validate
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
import (
"strings"
)
// TODO: remove the VM name validation after https://bugzilla.redhat.com/show_bug.cgi?id=2093044 is resolved
// Max length of a ARO cluster name is determined by the length of the generated availability set
// in the machine-api provider. It varies per region, but to remain consistent across non-zonal regions
// we hardcode this to 19, which is the max for all non-zonal regions.
//
// the generated availability set must be <= 80 characters and can be calculated below
// <cluster-name>-XXXXX_<cluster-name>-XXXXX-worker-<region>-as
// XXXXX: represents the 5 digit cluster infraID
// <cluster-name>: the name of the cluster
// <region>: the short-name of the region
const MaxClusterNameLength = 19
// nonZonalRegions are defined by the Compute List SKUs API not returning zones within the VM objects
//
// This can be queried for a location by running `az vm list-skus -l <region> --all --zone`
// If the object is empty that means the location does not support VMs deployed into
// availability zones
var nonZonalRegions = map[string]bool{
"australiacentral": true,
"australiacentral2": true,
"australiasoutheast": true,
"brazilsoutheast": true,
"canadaeast": true,
"japanwest": true,
"northcentralus": true,
"norwaywest": true,
"southindia": true,
"switzerlandwest": true,
"uaenorth": true,
"ukwest": true,
"westcentralus": true,
"westus": true,
}
// OpenShiftClusterNameLength validates that the name does not exceed the maximumLength
// which is in place for non-zonal regions due to https://bugzilla.redhat.com/show_bug.cgi?id=2093044
func OpenShiftClusterNameLength(name, location string) bool {
if nonZonalRegions[strings.ToLower(location)] && len(name) > MaxClusterNameLength {
return false
}
return true
}

Просмотреть файл

@ -1,56 +0,0 @@
package validate
import (
"testing"
)
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
func TestOpenShiftClusterName(t *testing.T) {
clusterName19 := "19characters-aaaaaa"
clusterName30 := "thisis30characterslong-aaaaaa"
for _, tt := range []struct {
name string
clusterName string
location string
desiredResult bool
}{
{
name: "valid - zoned region > maxLength",
clusterName: clusterName30,
location: "eastus",
desiredResult: true,
},
{
name: "valid - zoned region <= maxLength",
clusterName: clusterName19,
location: "eastus",
desiredResult: true,
},
{
name: "valid - non-zoned region <= maxLength",
clusterName: clusterName19,
location: "australiasoutheast",
desiredResult: true,
},
{
name: "invalid - non-zoned region > maxLength",
clusterName: clusterName30,
location: "australiasoutheast",
},
{
name: "invalid - non-zoned region > maxLength",
clusterName: clusterName30,
location: "WESTCENTRALUS",
},
} {
t.Run(tt.name, func(t *testing.T) {
isValid := OpenShiftClusterNameLength(tt.clusterName, tt.location)
if isValid != tt.desiredResult {
t.Errorf("Got %v, wanted %v, for cluster name '%s' in region '%s'", isValid, tt.desiredResult, tt.clusterName, tt.location)
}
})
}
}

Просмотреть файл

@ -297,7 +297,7 @@ func aroOpenshiftIoV1alpha1ServerresourcesJson() (*asset, error) {
return a, nil
}
var _assets_version = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x32\xd1\x33\x34\xd0\x33\x34\xe5\x02\x04\x00\x00\xff\xff\xa3\xd0\x80\xb2\x08\x00\x00\x00")
var _assets_version = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x32\xd1\x33\x34\xd0\x33\x32\xe0\x02\x04\x00\x00\xff\xff\xbf\x9a\xb1\xcd\x08\x00\x00\x00")
func assets_versionBytes() ([]byte, error) {
return bindataRead(

Просмотреть файл

@ -1 +1 @@
4.10.15
4.10.20

Просмотреть файл

@ -27,8 +27,8 @@ var GitCommit = "unknown"
// InstallStream describes stream we are defaulting to for all new clusters
var InstallStream = &Stream{
Version: NewVersion(4, 10, 15),
PullSpec: "quay.io/openshift-release-dev/ocp-release@sha256:ddcb70ce04a01ce487c0f4ad769e9e36a10c8c832a34307c1b1eb8e03a5b7ddb",
Version: NewVersion(4, 10, 20),
PullSpec: "quay.io/openshift-release-dev/ocp-release@sha256:b89ada9261a1b257012469e90d7d4839d0d2f99654f5ce76394fa3f06522b600",
}
// UpgradeStreams describes list of streams we support for upgrades