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

resource volume - objectionable restriction on parameter labels #646

Open
hkollera-inovex opened this issue Jan 24, 2025 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@hkollera-inovex
Copy link

Creating a volume with a label as described below

resource "stackit_volume" "volume" {
  name           = "${local.vm_real_hostname}_1"
  project_id    = var.project_id
  size              = 60
  performance_class = "storage_premium_perf1"
  availability_zone = "eu01-m"
    
  labels = {
    "mountpoint" = "/opt/mstr"
  }
}

leads to this error:

│ Error: Error creating volume
│ 
│   with module.vm["cg3-mstr-s301"].stackit_volume.volume["opt_mstr"],
│   on .terraform/modules/vm/main.tf line 82, in resource "stackit_volume" "volume":
│   82: resource "stackit_volume" "volume" {
│ 
│ Calling API: 400 Bad Request, status code 400, Body:
│ {"code":400,"msg":"does not match regex ^(-|_|[a-z0-9]){0,63}$: value
│ /opt/mstr"}
│

After changing /opt/mstr to _opt_mstr the deployment succeeds, but is not useful anymore.

The IaaS-API (https://docs.api.stackit.cloud/documentation/iaas/version/v1#tag/Volumes/operation/v1CreateVolume) has no restrictions on parameter labels.

BTW even the example response with label "foo" = "Foo Value", shown in the API-doc, would not be possible with the restriction shown in the error message 😀

@bahkauv70
Copy link
Contributor

Thanks for the report, we're taking a look at this.

@bahkauv70
Copy link
Contributor

bahkauv70 commented Jan 24, 2025

Checked back with the responsible team: The label values are restricted by definition as follows:

Constraints
The labels applied to a resource must meet the following requirements:

  • Each resource can have multiple labels, up to a maximum of 64.
  • Each label must be a key-value pair.
  • Keys have a minimum length of 1 character and a maximum length of 63 characters, and cannot be empty. Values can be empty, and have a maximum length of 63 characters.
  • Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed.
  • The key portion of a label must be unique. However, you can use the same key with multiple resources.
  • Keys must start with a lowercase letter or international character.
  • Keys are case-insensitive

These are same restrictions as for kubernetes label values

This is however missing from the API, CLI and the terraform documentation

@hkollera-inovex
Copy link
Author

Besides the fact that kubernetes allows dots in labels

Valid label value:
must be 63 characters or less (can be empty),
unless empty, must begin and end with an alphanumeric character ([a-z0-9A-Z]),
could contain dashes (-), underscores (), dots (.), and alphanumerics between._

this is not part of the kubernetes description:

All characters must use UTF-8 encoding, and international characters are allowed.

How is the encoding of international characters to pass the regex filter ^(-|_|[a-z0-9]){0,63}$ ? If I use UTF-8 code units, labels are restricted to 32 characters only. (example: /opt/mstr -> 2F 6F 70 74 2F 6D 73 74 72 C3 B6). Other encodings are not possible.

Is there a reason to restrict resources, which are independent of kubernetes usage, to kubernetes specifics?
Do these restriction on labels also apply to other resources?

@hkollera-inovex
Copy link
Author

You can ignore my last question. I just discovered, that the resource server has the same restriction with labels. That is the next bigger problem for us. We use labels for example in server maintenance and monitoring. So at least 4-5 labels, which we use at the moment with VMs based on the openstack provider, will be not be usable any longer.

@bahkauv70 bahkauv70 added the enhancement New feature or request label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants