Skip to content

Commit d710318

Browse files
authored
Merge pull request kubernetes#75054 from leakingtapan/ebs-wait
Remove the condition for only wait for KMS key is used
2 parents 6f93f87 + ac6d32a commit d710318

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

pkg/cloudprovider/providers/aws/aws.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,19 +2327,17 @@ func (c *Cloud) CreateDisk(volumeOptions *VolumeOptions) (KubernetesVolumeID, er
23272327
}
23282328
volumeName := KubernetesVolumeID("aws://" + aws.StringValue(response.AvailabilityZone) + "/" + string(awsID))
23292329

2330-
// AWS has a bad habbit of reporting success when creating a volume with
2331-
// encryption keys that either don't exists or have wrong permissions.
2332-
// Such volume lives for couple of seconds and then it's silently deleted
2333-
// by AWS. There is no other check to ensure that given KMS key is correct,
2334-
// because Kubernetes may have limited permissions to the key.
2335-
if len(volumeOptions.KmsKeyID) > 0 {
2336-
err := c.waitUntilVolumeAvailable(volumeName)
2337-
if err != nil {
2338-
if isAWSErrorVolumeNotFound(err) {
2339-
err = fmt.Errorf("failed to create encrypted volume: the volume disappeared after creation, most likely due to inaccessible KMS encryption key")
2340-
}
2341-
return "", err
2330+
err = c.waitUntilVolumeAvailable(volumeName)
2331+
if err != nil {
2332+
// AWS has a bad habbit of reporting success when creating a volume with
2333+
// encryption keys that either don't exists or have wrong permissions.
2334+
// Such volume lives for couple of seconds and then it's silently deleted
2335+
// by AWS. There is no other check to ensure that given KMS key is correct,
2336+
// because Kubernetes may have limited permissions to the key.
2337+
if isAWSErrorVolumeNotFound(err) {
2338+
err = fmt.Errorf("failed to create encrypted volume: the volume disappeared after creation, most likely due to inaccessible KMS encryption key")
23422339
}
2340+
return "", err
23432341
}
23442342

23452343
return volumeName, nil

pkg/cloudprovider/providers/aws/aws_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,12 +1793,19 @@ func TestCreateDisk(t *testing.T) {
17931793
}},
17941794
},
17951795
}
1796+
17961797
volume := &ec2.Volume{
17971798
AvailabilityZone: aws.String("us-east-1a"),
17981799
VolumeId: aws.String("vol-volumeId0"),
1800+
State: aws.String("available"),
17991801
}
18001802
awsServices.ec2.(*MockedFakeEC2).On("CreateVolume", request).Return(volume, nil)
18011803

1804+
describeVolumesRequest := &ec2.DescribeVolumesInput{
1805+
VolumeIds: []*string{aws.String("vol-volumeId0")},
1806+
}
1807+
awsServices.ec2.(*MockedFakeEC2).On("DescribeVolumes", describeVolumesRequest).Return([]*ec2.Volume{volume}, nil)
1808+
18021809
volumeID, err := c.CreateDisk(volumeOptions)
18031810
assert.Nil(t, err, "Error creating disk: %v", err)
18041811
assert.Equal(t, volumeID, KubernetesVolumeID("aws://us-east-1a/vol-volumeId0"))

0 commit comments

Comments
 (0)