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.
This commit is contained in:
Tim Gross 2022-03-03 17:00:00 -05:00 committed by GitHub
parent 1502af3523
commit b8b08fb32d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -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()