зеркало из https://github.com/Azure/ARO-RP.git
fix corner case deletion bug
This commit is contained in:
Родитель
3cbe2f1219
Коммит
8e3acc2a0a
|
@ -22,11 +22,14 @@ func (c *Cluster) getServicePrincipal(ctx context.Context, appID string) (string
|
|||
return "", err
|
||||
}
|
||||
|
||||
if len(sps) != 1 {
|
||||
switch len(sps) {
|
||||
case 0:
|
||||
return "", nil
|
||||
case 1:
|
||||
return *sps[0].ObjectID, nil
|
||||
default:
|
||||
return "", fmt.Errorf("%d service principals found for appId %s", len(sps), appID)
|
||||
}
|
||||
|
||||
return *sps[0].ObjectID, nil
|
||||
}
|
||||
|
||||
func (c *Cluster) createApplication(ctx context.Context, displayName string) (string, string, error) {
|
||||
|
|
|
@ -118,6 +118,9 @@ func (c *Cluster) Create(ctx context.Context, clusterName string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if fpSPID == "" {
|
||||
return fmt.Errorf("service principal not found for appId %s", fpClientID)
|
||||
}
|
||||
|
||||
c.log.Infof("creating AAD application")
|
||||
appID, appSecret, err := c.createApplication(ctx, "aro-"+clusterName)
|
||||
|
@ -378,6 +381,9 @@ func (c *Cluster) deleteRoleAssignments(ctx context.Context, appID string) error
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if spObjID == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
roleAssignments, err := c.roleassignments.ListForResourceGroup(ctx, c.ResourceGroup(), fmt.Sprintf("principalId eq '%s'", spObjID))
|
||||
if err != nil {
|
||||
|
|
Загрузка…
Ссылка в новой задаче