Skip to content

Commit

Permalink
Fix issue error in minimal privileged account in AliCloud (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
jia-jerry authored and MartinWeindel committed May 22, 2019
1 parent aa2545c commit c49aea9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/controller/provider/alicloud/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package alicloud

import (
"fmt"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
"github.com/aliyun/alibaba-cloud-sdk-go/services/alidns"
"github.com/gardener/controller-manager-library/pkg/logger"
"github.com/gardener/external-dns-management/pkg/dns"
Expand Down Expand Up @@ -88,6 +89,11 @@ func (this *Handler) GetZones() (provider.DNSHostedZones, error) {
}
err := this.access.ListRecords(z.DomainName, f)
if err != nil {
if checkAccessForbiddern(err) {
// It is reasonable for some RAM user, it is only allowed to access certain domain's records detail
// As a result, this domain should not appended to the host zones
continue
}
return nil, err
}
hostedZone := provider.NewDNSHostedZone(
Expand Down Expand Up @@ -128,3 +134,17 @@ func (this *Handler) ExecuteRequests(logger logger.LogContext, zone provider.DNS
}
return exec.submitChanges()
}

func checkAccessForbiddern(err error) bool {
if err != nil {
switch err.(type) {
case *errors.ServerError:
serverErr := err.(*errors.ServerError)
if serverErr.ErrorCode() == "Forbidden.RAM" {
return true
}
}
}

return false
}

0 comments on commit c49aea9

Please sign in to comment.