Skip to content

Commit

Permalink
Merge pull request #583 from akutz/feature/efs-sg-warning
Browse files Browse the repository at this point in the history
EFS SecurityGroup Warning
  • Loading branch information
akutz authored Jun 26, 2017
2 parents 6939c3b + 32bf893 commit 99ac57e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
34 changes: 30 additions & 4 deletions drivers/storage/efs/storage/efs_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,18 +657,44 @@ func (d *driver) VolumeAttach(
// No mount targets were found
if ma == nil {

var iSecGrpIDs []string
secGrpIDs := d.secGroups
if v, ok := iid.Fields[efs.InstanceIDFieldSecurityGroups]; ok {
iSecGrpIDs := strings.Split(v, ";")
ctx.WithField("secGrpIDs", iSecGrpIDs).Debug(
"using instance security group IDs")
secGrpIDs = iSecGrpIDs
iSecGrpIDs = strings.Split(v, ";")
if len(iSecGrpIDs) == 1 {
ctx.WithField("secGrpIDs", iSecGrpIDs).Debug(
"using instance security group IDs")
secGrpIDs = iSecGrpIDs
}
}

if len(secGrpIDs) == 0 {
return nil, "", errInvalidSecGroups
}

// make sure all of the request security groups
// are available on the instance
var missingSecGrpIDs []string
for _, csg := range secGrpIDs {
var found bool
for _, isg := range iSecGrpIDs {
if csg == isg {
found = true
break
}
}
if !found {
missingSecGrpIDs = append(missingSecGrpIDs, csg)
}
}

// log a warning if any of the server-side defined SGs
// are not present in the list sent by the client instance
if len(missingSecGrpIDs) > 0 {
log.WithField("missingStorageGroups", missingSecGrpIDs).Warn(
"configured sec grps not present on instance")
}

request := &awsefs.CreateMountTargetInput{
FileSystemId: aws.String(vol.ID),
SubnetId: aws.String(iid.ID),
Expand Down
2 changes: 1 addition & 1 deletion drivers/storage/efs/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func InstanceID(ctx types.Context) (*types.InstanceID, error) {
efs.InstanceIDFieldAvailabilityZone: iid.AvailabilityZone,
}

if len(secGroups) == 1 {
if len(secGroups) > 0 {
iidFields[efs.InstanceIDFieldSecurityGroups] = strings.Join(
secGroups, ";")
}
Expand Down

0 comments on commit 99ac57e

Please sign in to comment.