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

[BUG] Namespace creation or import fails with error: "Bad project id format" #1417

Open
nemobis opened this issue Sep 25, 2024 · 2 comments
Open
Labels

Comments

@nemobis
Copy link
Contributor

nemobis commented Sep 25, 2024

Rancher Server Setup

  • Rancher version: v2.9.1
  • Installation option (Docker install/Helm Chart): N/A
  • Proxy/Cert Details: N/A

Information about the Cluster

  • Kubernetes version: v1.30.3 +k0s
  • Cluster Type (Local/Downstream): N/A

User Information

  • What is the role of the user logged in? Project Owner

Provider Information

  • What is the version of the Rancher v2 Terraform Provider in use? v5.0.0.
  • What is the version of Terraform in use? v1.5.7

Describe the bug

Namespace creation or import fails with

│ Error: [ERROR] Getting clusted ID from project ID: Bad project id format p-ab1c2
│ 
│   with rancher2_namespace.observe_namespace,
│   on main.tf line 56, in resource "rancher2_namespace" "observe_namespace":
│   56: resource "rancher2_namespace" "observe_namespace" {

To Reproduce

Attempt to create the namespace with

resource "rancher2_namespace" "foo_namespace" {
  name       = "foo"
  project_id = "p-ab1c2"
  labels = {
    "owner"                       = "bar"
    "kubernetes.io/metadata.name" = "foo"
  }
}

or create it manually and then attempt import with

terraform import rancher2_namespace.foo_namespace c-defgh:p-ab1c2.foo

Actual Result

Error. The rest of the plan works just fine and workloads appear in the namespace/project.

Expected Result

The namespace is created or imported into the state.

@nemobis
Copy link
Contributor Author

nemobis commented Sep 25, 2024

https://github.com/rancher/terraform-provider-rancher2/pull/1416/files is for the typo in the error message. Why is the provider even trying to look up the cluster ID (something for which it may or may not have sufficient permissions) when I've already provided it?

@nemobis
Copy link
Contributor Author

nemobis commented Sep 25, 2024

Documentation says

[project_id](https://registry.terraform.io/providers/rancher/rancher2/latest/docs/resources/namespace#project_id) - (Required) The project id where assign namespace. It's on the form project_id=<cluster_id>:<id>. Updating <id> part on same <cluster_id> namespace will be moved between projects (string)

Some copyediting of these sentences would be welcome. I'm not super sure what they're expected to mean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant