Skip to content

Fix GCP resource labels for mixed-case owner#6737

Open
kiryl-filatau wants to merge 3 commits into
GoogleCloudPlatform:masterfrom
kiryl-filatau:gcp-tags-lower-fix
Open

Fix GCP resource labels for mixed-case owner#6737
kiryl-filatau wants to merge 3 commits into
GoogleCloudPlatform:masterfrom
kiryl-filatau:gcp-tags-lower-fix

Conversation

@kiryl-filatau

@kiryl-filatau kiryl-filatau commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

GCP rejects resource labels if they contain uppercase letters (for example owner=Name_Surname). The owner field in _GetResourceDict is now passed through _SafeLabelKeyOrValue, consistent with how --metadata pairs are already handled. GCE metadata (like enable-oslogin=FALSE) is not changed.


What broke

Running on GCP:

```bash
./pkb.py --cloud=GCP --benchmarks=kubernetes_scale
```

Cluster create failed:

```text
ERROR: (gcloud.container.clusters.create) ResponseError: code=400, message=Invalid field 'resource_labels.value':
"Name_Surname". It must only contain lowercase letters ([a-z]), numeric characters ([0-9]), underscores (_) and dashes (-).
International characters are allowed.
```

owner comes from --owner / getpass.getuser() and was passed to gcloud --labels without lowercasing.


Fix

In perfkitbenchmarker/benchmark_spec.py (_GetResourceDict):

  • owner is now wrapped in _SafeLabelKeyOrValue() — same as --metadata pairs

One unit test: testOwnerFromGetuserIsSanitized in benchmark_spec_test.py.


How was tested

  • python3 -m pytest tests/benchmark_spec_test.py tests/providers/gcp/util_test.py -v
  • ./pkb.py --cloud=GCP --benchmarks=kubernetes_scale — cluster create works, labels are lowercase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant