Skip to content

Commit 4d0af0e

Browse files
committed
Deprecate Snow Device Support
1 parent 635bfe6 commit 4d0af0e

File tree

11 files changed

+39
-210
lines changed

11 files changed

+39
-210
lines changed

docs/parameters.md

Lines changed: 17 additions & 17 deletions
Large diffs are not rendered by default.

pkg/cloud/cloud.go

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ const (
5656
VolumeTypeSC1 = "sc1"
5757
// VolumeTypeST1 represents a throughput-optimized HDD type of volume.
5858
VolumeTypeST1 = "st1"
59-
// VolumeTypeSBG1 represents a capacity-optimized HDD type of volume. Only for SBE devices.
60-
VolumeTypeSBG1 = "sbg1"
61-
// VolumeTypeSBP1 represents a performance-optimized SSD type of volume. Only for SBE devices.
62-
VolumeTypeSBP1 = "sbp1"
6359
// VolumeTypeStandard represents a previous type of volume.
6460
VolumeTypeStandard = "standard"
6561
)
@@ -547,7 +543,7 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions *
547543
}
548544

549545
switch createType {
550-
case VolumeTypeGP2, VolumeTypeSC1, VolumeTypeST1, VolumeTypeSBG1, VolumeTypeSBP1, VolumeTypeStandard:
546+
case VolumeTypeGP2, VolumeTypeSC1, VolumeTypeST1, VolumeTypeStandard:
551547
case VolumeTypeIO1:
552548
maxIops = io1MaxTotalIOPS
553549
minIops = io1MinTotalIOPS
@@ -624,10 +620,7 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions *
624620
VolumeType: types.VolumeType(createType),
625621
Encrypted: aws.Bool(diskOptions.Encrypted),
626622
MultiAttachEnabled: aws.Bool(diskOptions.MultiAttachEnabled),
627-
}
628-
629-
if !util.IsSBE(zone) {
630-
requestInput.TagSpecifications = []types.TagSpecification{tagSpec}
623+
TagSpecifications: []types.TagSpecification{tagSpec},
631624
}
632625

633626
// EBS doesn't handle empty outpost arn, so we have to include it only when it's non-empty
@@ -685,26 +678,7 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions *
685678
return nil, fmt.Errorf("timed out waiting for volume to create: %w", err)
686679
}
687680

688-
outpostArn := aws.ToString(response.OutpostArn)
689-
var resources []string
690-
if util.IsSBE(zone) {
691-
requestTagsInput := &ec2.CreateTagsInput{
692-
Resources: append(resources, volumeID),
693-
Tags: tags,
694-
}
695-
_, err := c.ec2.CreateTags(ctx, requestTagsInput)
696-
if err != nil {
697-
// To avoid leaking volume, we should delete the volume just created
698-
// TODO: Need to figure out how to handle DeleteDisk failed scenario instead of just log the error
699-
if _, deleteDiskErr := c.DeleteDisk(ctx, volumeID); deleteDiskErr != nil {
700-
klog.ErrorS(deleteDiskErr, "failed to be deleted, this may cause volume leak", "volumeID", volumeID)
701-
} else {
702-
klog.V(5).InfoS("volume is deleted because there was an error while attaching the tags", "volumeID", volumeID)
703-
}
704-
return nil, fmt.Errorf("could not attach tags to volume: %v. %w", volumeID, err)
705-
}
706-
}
707-
return &Disk{CapacityGiB: size, VolumeID: volumeID, AvailabilityZone: zone, SnapshotID: snapshotID, OutpostArn: outpostArn}, nil
681+
return &Disk{CapacityGiB: size, VolumeID: volumeID, AvailabilityZone: zone, SnapshotID: snapshotID, OutpostArn: aws.ToString(response.OutpostArn)}, nil
708682
}
709683

710684
// execBatchDescribeVolumesModifications executes a batched DescribeVolumesModifications API call.

pkg/cloud/cloud_test.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import (
4242
const (
4343
defaultZone = "test-az"
4444
expZone = "us-west-2b"
45-
snowZone = "snow"
4645
defaultVolumeID = "vol-test-1234"
4746
defaultNodeID = "node-1234"
4847
defaultPath = "/dev/xvdaa"
@@ -1263,41 +1262,6 @@ func TestCreateDisk(t *testing.T) {
12631262
},
12641263
expErr: nil,
12651264
},
1266-
{
1267-
name: "success: create volume when zone is snow and add tags",
1268-
volumeName: "vol-test-name",
1269-
diskOptions: &DiskOptions{
1270-
CapacityBytes: util.GiBToBytes(1),
1271-
Tags: map[string]string{VolumeNameTagKey: "vol-test", AwsEbsDriverTagKey: "true"},
1272-
AvailabilityZone: snowZone,
1273-
VolumeType: "sbp1",
1274-
},
1275-
expCreateVolumeInput: &ec2.CreateVolumeInput{},
1276-
expDisk: &Disk{
1277-
VolumeID: "vol-test",
1278-
CapacityGiB: 1,
1279-
AvailabilityZone: snowZone,
1280-
},
1281-
expErr: nil,
1282-
},
1283-
{
1284-
name: "fail: zone is snow and add tags throws error",
1285-
volumeName: "vol-test-name",
1286-
diskOptions: &DiskOptions{
1287-
CapacityBytes: util.GiBToBytes(1),
1288-
Tags: map[string]string{VolumeNameTagKey: "vol-test", AwsEbsDriverTagKey: "true"},
1289-
AvailabilityZone: snowZone,
1290-
VolumeType: "sbg1",
1291-
},
1292-
expCreateVolumeInput: &ec2.CreateVolumeInput{},
1293-
expCreateTagsErr: errors.New("CreateTags generic error"),
1294-
expDisk: &Disk{
1295-
VolumeID: "vol-test",
1296-
CapacityGiB: 1,
1297-
AvailabilityZone: snowZone,
1298-
},
1299-
expErr: errors.New("could not attach tags to volume: vol-test. CreateTags generic error"),
1300-
},
13011265
{
13021266
name: "success: create default volume with throughput",
13031267
volumeName: "vol-test-name",
@@ -1439,10 +1403,6 @@ func TestCreateDisk(t *testing.T) {
14391403
},
14401404
},
14411405
}, tc.expDescVolumeErr).AnyTimes()
1442-
if tc.diskOptions.AvailabilityZone == "snow" {
1443-
mockEC2.EXPECT().CreateTags(gomock.Any(), gomock.Any()).Return(&ec2.CreateTagsOutput{}, tc.expCreateTagsErr)
1444-
mockEC2.EXPECT().DeleteVolume(gomock.Any(), gomock.Any(), gomock.Any()).Return(&ec2.DeleteVolumeOutput{}, nil).AnyTimes()
1445-
}
14461406
if len(tc.diskOptions.SnapshotID) > 0 {
14471407
mockEC2.EXPECT().DescribeSnapshots(gomock.Any(), gomock.Any()).Return(&ec2.DescribeSnapshotsOutput{Snapshots: []types.Snapshot{snapshot}}, nil).AnyTimes()
14481408
}

pkg/cloud/metadata/ec2.go

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var DefaultEC2MetadataClient = func() (EC2Metadata, error) {
5050
return svc, nil
5151
}
5252

53-
func EC2MetadataInstanceInfo(svc EC2Metadata, regionFromSession string) (*Metadata, error) {
53+
func EC2MetadataInstanceInfo(svc EC2Metadata) (*Metadata, error) {
5454
docOutput, err := svc.GetInstanceIdentityDocument(context.Background(), &imds.GetInstanceIdentityDocumentInput{})
5555
if err != nil {
5656
return nil, fmt.Errorf("could not get EC2 instance identity metadata: %w", err)
@@ -66,38 +66,27 @@ func EC2MetadataInstanceInfo(svc EC2Metadata, regionFromSession string) (*Metada
6666
}
6767

6868
if len(doc.Region) == 0 {
69-
if len(regionFromSession) != 0 && util.IsSBE(regionFromSession) {
70-
doc.Region = regionFromSession
71-
} else {
72-
return nil, errors.New("could not get valid EC2 region")
73-
}
69+
return nil, errors.New("could not get valid EC2 region")
7470
}
7571

7672
if len(doc.AvailabilityZone) == 0 {
77-
if len(regionFromSession) != 0 && util.IsSBE(regionFromSession) {
78-
doc.AvailabilityZone = regionFromSession
79-
} else {
80-
return nil, errors.New("could not get valid EC2 availability zone")
81-
}
73+
return nil, errors.New("could not get valid EC2 availability zone")
8274
}
8375

8476
attachedENIs, err := getAttachedENIs(svc)
8577
if err != nil {
8678
return nil, err
8779
}
8880

89-
blockDevMappings := 0
90-
if !util.IsSBE(doc.Region) {
91-
mappingsOutput, mappingsOutputErr := svc.GetMetadata(context.Background(), &imds.GetMetadataInput{Path: BlockDevicesEndpoint})
92-
if mappingsOutputErr != nil {
93-
return nil, fmt.Errorf("could not get metadata for block device mappings: %w", mappingsOutputErr)
94-
}
95-
mappings, mappingsErr := io.ReadAll(mappingsOutput.Content)
96-
if mappingsErr != nil {
97-
return nil, fmt.Errorf("could not read block device mappings metadata content: %w", mappingsErr)
98-
}
99-
blockDevMappings = strings.Count(string(mappings), "ebs")
81+
mappingsOutput, mappingsOutputErr := svc.GetMetadata(context.Background(), &imds.GetMetadataInput{Path: BlockDevicesEndpoint})
82+
if mappingsOutputErr != nil {
83+
return nil, fmt.Errorf("could not get metadata for block device mappings: %w", mappingsOutputErr)
84+
}
85+
mappings, mappingsErr := io.ReadAll(mappingsOutput.Content)
86+
if mappingsErr != nil {
87+
return nil, fmt.Errorf("could not read block device mappings metadata content: %w", mappingsErr)
10088
}
89+
blockDevMappings := strings.Count(string(mappings), "ebs")
10190

10291
instanceInfo := Metadata{
10392
InstanceID: doc.InstanceID,

pkg/cloud/metadata/metadata.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func NewMetadataService(cfg MetadataServiceConfig, region string) (MetadataServi
5252
klog.V(2).InfoS("Environment variable AWS_EC2_METADATA_DISABLED set to 'true'. Will not rely on IMDS for instance metadata")
5353
} else {
5454
klog.V(2).InfoS("Attempting to retrieve instance metadata from IMDS")
55-
metadata, err := retrieveEC2Metadata(cfg.EC2MetadataClient, region)
55+
metadata, err := retrieveEC2Metadata(cfg.EC2MetadataClient)
5656
if err == nil {
5757
klog.V(2).InfoS("Retrieved metadata from IMDS")
5858
return metadata.overrideRegion(region), nil
@@ -88,13 +88,13 @@ func (m *Metadata) UpdateMetadata() error {
8888
return nil
8989
}
9090

91-
func retrieveEC2Metadata(ec2MetadataClient EC2MetadataClient, region string) (*Metadata, error) {
91+
func retrieveEC2Metadata(ec2MetadataClient EC2MetadataClient) (*Metadata, error) {
9292
svc, err := ec2MetadataClient()
9393
if err != nil {
9494
klog.ErrorS(err, "failed to initialize EC2 Metadata client")
9595
return nil, err
9696
}
97-
return EC2MetadataInstanceInfo(svc, region)
97+
return EC2MetadataInstanceInfo(svc)
9898
}
9999

100100
func retrieveK8sMetadata(k8sAPIClient KubernetesAPIClient) (*Metadata, error) {

pkg/cloud/metadata/metadata_test.go

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,10 @@ func TestEC2MetadataInstanceInfo(t *testing.T) {
169169
defer ctrl.Finish()
170170

171171
testCases := []struct {
172-
name string
173-
regionFromSession string
174-
mockEC2Metadata func(m *MockEC2Metadata)
175-
expectedMetadata *Metadata
176-
expectedError error
172+
name string
173+
mockEC2Metadata func(m *MockEC2Metadata)
174+
expectedMetadata *Metadata
175+
expectedError error
177176
}{
178177
{
179178
name: "TestEC2MetadataInstanceInfo: Error getting instance identity document",
@@ -368,33 +367,6 @@ func TestEC2MetadataInstanceInfo(t *testing.T) {
368367
OutpostArn: arn.ARN{},
369368
},
370369
},
371-
{
372-
name: "TestEC2MetadataInstanceInfo: Valid metadata retrieving snow region/AZ from session",
373-
regionFromSession: "snow",
374-
mockEC2Metadata: func(m *MockEC2Metadata) {
375-
m.EXPECT().GetInstanceIdentityDocument(gomock.Any(), &imds.GetInstanceIdentityDocumentInput{}).Return(&imds.GetInstanceIdentityDocumentOutput{
376-
InstanceIdentityDocument: imds.InstanceIdentityDocument{
377-
InstanceID: "i-1234567890abcdef0",
378-
InstanceType: "c5.xlarge",
379-
Region: "",
380-
AvailabilityZone: "",
381-
},
382-
}, nil)
383-
m.EXPECT().GetMetadata(gomock.Any(), &imds.GetMetadataInput{Path: EnisEndpoint}).Return(&imds.GetMetadataOutput{
384-
Content: io.NopCloser(strings.NewReader("01:23:45:67:89:ab\n02:23:45:67:89:ab")),
385-
}, nil)
386-
m.EXPECT().GetMetadata(gomock.Any(), &imds.GetMetadataInput{Path: OutpostArnEndpoint}).Return(nil, errors.New("404 - Not Found"))
387-
},
388-
expectedMetadata: &Metadata{
389-
InstanceID: "i-1234567890abcdef0",
390-
InstanceType: "c5.xlarge",
391-
Region: "snow",
392-
AvailabilityZone: "snow",
393-
NumAttachedENIs: 2,
394-
NumBlockDeviceMappings: 0,
395-
OutpostArn: arn.ARN{},
396-
},
397-
},
398370
}
399371

400372
for _, tc := range testCases {
@@ -405,7 +377,7 @@ func TestEC2MetadataInstanceInfo(t *testing.T) {
405377
mockEC2Metadata := NewMockEC2Metadata(mockCtrl)
406378
tc.mockEC2Metadata(mockEC2Metadata)
407379

408-
metadata, err := EC2MetadataInstanceInfo(mockEC2Metadata, tc.regionFromSession)
380+
metadata, err := EC2MetadataInstanceInfo(mockEC2Metadata)
409381

410382
if tc.expectedError != nil {
411383
require.EqualError(t, err, tc.expectedError.Error())

pkg/driver/node.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ const (
4949

5050
// VolumeOperationAlreadyExists is message fmt returned to CO when there is another in-flight call on the given volumeID.
5151
VolumeOperationAlreadyExists = "An operation with the given volume=%q is already in progress"
52-
53-
// sbeDeviceVolumeAttachmentLimit refers to the maximum number of volumes that can be attached to an instance on snow.
54-
sbeDeviceVolumeAttachmentLimit = 10
5552
)
5653

5754
var (
@@ -773,9 +770,6 @@ func (d *NodeService) getVolumesLimit() int64 {
773770
klog.V(4).InfoS("getVolumesLimit: VolumeAttachLimit manually set to", d.options.VolumeAttachLimit, "overriding the default value")
774771
return d.options.VolumeAttachLimit
775772
}
776-
if util.IsSBE(d.metadata.GetRegion()) {
777-
return sbeDeviceVolumeAttachmentLimit
778-
}
779773

780774
instanceType := d.metadata.GetInstanceType()
781775
klog.V(4).InfoS("getVolumesLimit:", "instanceType", instanceType)

0 commit comments

Comments
 (0)