зеркало из https://github.com/Azure/ARO-RP.git
disallow duplicate operator identity resource IDs
This adds a step to static validation that checks to see if operator identities use the same resource ID as any other operator identities and causes the cluster installation to fail if so. Each operator should have its own identity.
This commit is contained in:
Родитель
25eef93d02
Коммит
517da1163f
|
@ -469,7 +469,14 @@ func (sv openShiftClusterStaticValidator) validatePlatformWorkloadIdentityProfil
|
|||
}
|
||||
|
||||
// Validate the PlatformWorkloadIdentities
|
||||
foundIdentityResourceIDs := map[string]string{}
|
||||
|
||||
for name, p := range pwip.PlatformWorkloadIdentities {
|
||||
if _, present := foundIdentityResourceIDs[strings.ToLower(p.ResourceID)]; present {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, fmt.Sprintf("%s.PlatformWorkloadIdentities", path), "ResourceID %s used by multiple identities.", p.ResourceID)
|
||||
}
|
||||
foundIdentityResourceIDs[strings.ToLower(p.ResourceID)] = ""
|
||||
|
||||
resource, err := azcorearm.ParseResourceID(p.ResourceID)
|
||||
if err != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, fmt.Sprintf("%s.PlatformWorkloadIdentities[%s].resourceID", path, name), "ResourceID %s formatted incorrectly.", p.ResourceID)
|
||||
|
|
|
@ -1379,6 +1379,44 @@ func TestOpenShiftClusterStaticValidatePlatformWorkloadIdentityProfile(t *testin
|
|||
},
|
||||
wantErr: "400: InvalidParameter: properties.servicePrincipalProfile: Must provide either an identity or service principal credentials.",
|
||||
},
|
||||
{
|
||||
name: "duplicate operator identities",
|
||||
modify: func(oc *OpenShiftCluster) {
|
||||
oc.Identity = &ManagedServiceIdentity{
|
||||
UserAssignedIdentities: map[string]UserAssignedIdentity{
|
||||
"first": clusterIdentity1,
|
||||
},
|
||||
}
|
||||
oc.Properties.PlatformWorkloadIdentityProfile = &PlatformWorkloadIdentityProfile{
|
||||
PlatformWorkloadIdentities: map[string]PlatformWorkloadIdentity{
|
||||
"FAKE-OPERATOR": platformIdentity1,
|
||||
"ANOTHER-FAKE-OPERATOR": platformIdentity1,
|
||||
},
|
||||
}
|
||||
oc.Properties.ServicePrincipalProfile = nil
|
||||
},
|
||||
wantErr: "400: InvalidParameter: properties.platformWorkloadIdentityProfile.PlatformWorkloadIdentities: ResourceID /subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/a-fake-group/providers/Microsoft.RedHatOpenShift/userAssignedIdentities/fake-cluster-name used by multiple identities.",
|
||||
},
|
||||
{
|
||||
name: "duplicate operator identities, different cases",
|
||||
modify: func(oc *OpenShiftCluster) {
|
||||
oc.Identity = &ManagedServiceIdentity{
|
||||
UserAssignedIdentities: map[string]UserAssignedIdentity{
|
||||
"first": clusterIdentity1,
|
||||
},
|
||||
}
|
||||
oc.Properties.PlatformWorkloadIdentityProfile = &PlatformWorkloadIdentityProfile{
|
||||
PlatformWorkloadIdentities: map[string]PlatformWorkloadIdentity{
|
||||
"FAKE-OPERATOR": platformIdentity1,
|
||||
"ANOTHER-FAKE-OPERATOR": {
|
||||
ResourceID: "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/a-fake-group/providers/Microsoft.RedHatOpenShift/userAssignedIdentities/FAKE-CLUSTER-NAME",
|
||||
},
|
||||
},
|
||||
}
|
||||
oc.Properties.ServicePrincipalProfile = nil
|
||||
},
|
||||
wantErr: "400: InvalidParameter: properties.platformWorkloadIdentityProfile.PlatformWorkloadIdentities: ResourceID /subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/a-fake-group/providers/Microsoft.RedHatOpenShift/userAssignedIdentities/fake-cluster-name used by multiple identities.",
|
||||
},
|
||||
{
|
||||
name: "valid UpgradeableTo value",
|
||||
modify: func(oc *OpenShiftCluster) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче