Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Fargate support in the EFS CSI Controller #1195

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cloud/k8s_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (k kubernetesApiMetadataProvider) getMetadata() (MetadataService, error) {
return nil, fmt.Errorf("node providerID empty, cannot parse")
}

re := regexp.MustCompile("i-[a-z0-9]+$")
re := regexp.MustCompile("i-[a-z0-9]+$|[a-z0-9]{32}")
instanceID := re.FindString(providerId)
if instanceID == "" {
return nil, fmt.Errorf("did not find aws instance ID in node providerID string")
Expand Down
18 changes: 18 additions & 0 deletions pkg/cloud/k8s_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ func TestInstanceIdParsedFromProviderIdCorrectly(t *testing.T) {
}
}

func TestTaskIdParsedFromProviderIdCorrectly(t *testing.T) {
clientSet := setupKubernetesClient(t, nodeName, createFargateNode())
k8sMp := kubernetesApiMetadataProvider{api: clientSet}

metadata, err := k8sMp.getMetadata()

if err != nil {
t.Fatalf("Error occurred when parsing instance ID, %v", err)
}
if metadata.GetInstanceID() != taskId {
t.Fatalf("Instance ID not extracted correctly, expected %s, got %s", taskId, metadata.GetInstanceID())
}
}

func TestRegionAndZoneExtractedCorrectlyFromLabels(t *testing.T) {
clientSet := setupKubernetesClient(t, nodeName, createDefaultNode())
k8sMp := kubernetesApiMetadataProvider{api: clientSet}
Expand Down Expand Up @@ -123,3 +137,7 @@ func createNode(nodeName string, nodeRegion string, nodeZone string, providerId
func createDefaultNode() *v1.Node {
return createNode(nodeName, nodeRegion, nodeZone, fmt.Sprintf("aws:///%s/%s", nodeZone, instanceId))
}

func createFargateNode() *v1.Node {
return createNode(nodeName, nodeRegion, nodeZone, fmt.Sprintf("aws:///%s/1234567890-%s/%s", nodeZone, taskId, nodeName))
}