From b8b08fb32d4518c23f97f52f8fb06603338ce8bf Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Thu, 3 Mar 2022 17:00:00 -0500 Subject: [PATCH] e2e: use UUID for CSI idempotency token (#12183) The AWS EBS plugin appears to use the name field of the volume as an idempotency token that persists across the entire AWS account, not just the plugin lifespan. Also fix the regex for the volume ID, which was originally taken from the job ID regex but isn't actually the same. This hasn't failed tests for us because we've always passed in the same volume ID. --- e2e/csi/csi.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/e2e/csi/csi.go b/e2e/csi/csi.go index e570f7383..dc2b36473 100644 --- a/e2e/csi/csi.go +++ b/e2e/csi/csi.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/nomad/api" e2e "github.com/hashicorp/nomad/e2e/e2eutil" "github.com/hashicorp/nomad/e2e/framework" + "github.com/hashicorp/nomad/helper/uuid" "github.com/hashicorp/nomad/testutil" ) @@ -226,13 +227,15 @@ func volumeRegister(volID, volFilePath, createOrRegister string) error { } // hack off the first line to replace with our unique ID - var idRegex = regexp.MustCompile(`(?m)^id ".*"`) + var idRegex = regexp.MustCompile(`(?m)^id[\s]+= ".*"`) volspec := idRegex.ReplaceAllString(string(content), fmt.Sprintf("id = %q", volID)) - var nameRegex = regexp.MustCompile(`(?m)^name ".*"`) + // the EBS plugin uses the name as an idempotency token across the + // whole AWS account, so it has to be globally unique + var nameRegex = regexp.MustCompile(`(?m)^name[\s]+= ".*"`) volspec = nameRegex.ReplaceAllString(volspec, - fmt.Sprintf("name = %q", volID)) + fmt.Sprintf("name = %q", uuid.Generate())) go func() { defer stdin.Close()