pulumi / pulumi-rancher2

A Rancher2 Pulumi resource package, providing multi-language access to Rancher2
Apache License 2.0
9 stars 4 forks source link

Unable to move namespaces between projects #496

Open DenMX opened 5 months ago

DenMX commented 5 months ago

Describe what happened

When i trying import existing cluster i got an exception thath says report bug :)

rancher2:index:Cluster (devops.test):
    error: Preview failed: importing devops.test.cluster: importer for devops.test.cluster returned a empty resource state. This is always the result of a bug in the resource provider - please report this as a bug in the Pulumi provider repository.

i created only provider for feature work with pulumi and then try to import cluster with command: pulumi import rancher2:index/cluster:Cluster devops.test devops.test.cluster

Sample program

pulumi import rancher2:index/cluster:Cluster devops.test devops.test.cluster

Log output

rancher2:index:Cluster (devops.test): error: Preview failed: importing devops.test.cluster: importer for devops.test.cluster returned a empty resource state. This is always the result of a bug in the resource provider - please report this as a bug in the Pulumi provider repository.

Affected Resource(s)

No response

Output of pulumi about

CLI Version 3.116.0 Go Version go1.22.2 Go Compiler gc

Plugins KIND NAME VERSION resource grafana 0.4.2 resource kubernetes 3.22.1 language python unknown resource rancher2 6.1.1

Host OS Microsoft Windows 10 Pro Version 10.0.19045 Build 19045 Arch x86_64

This project is written in python: executable='C:\Users***\pulumi-rancher\venv\Scripts\python.exe' version='3.9.13'

Current Stack: pulumi-rancher

TYPE URN pulumi:pulumi:Stack urn:pulumi:pulumi-rancher::pulum::pulumi:pulumi:Stack::pulum-pulumi-rancher pulumi:providers:rancher2 urn:pulumi:pulumi-rancher::pulum::pulumi:providers:rancher2::pulumi provider

Found no pending operations associated with pulumi-rancher

Backend Name HP-SDB641 URL s3://pulumi?region=us-east-1&endpoint=sdnexus.specdep.local:8000&disableSSL=true&s3ForcePathStyle=true User *** Organizations Token type personal

Dependencies: NAME VERSION hvac 1.0.2 pip 24.0 pulumi-kubernetes 3.22.1 pulumi_rancher2 6.1.1 pulumiverse-grafana 0.4.2 python-dotenv 0.21.0 setuptools 65.4.1 wheel 0.37.1

Pulumi locates its logs in C:\Users***\AppData\Local\Temp by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

iwahbe commented 5 months ago

Hi @DenMX. Thanks for reporting this issue.

DenMX commented 5 months ago

Hey, after few days working with pulumi rancher i realised that i was confused with cluster id, so this is not a bug, but exception message also not correct.

I don't know where i can ask a question, so... Is there easy way to change project for existing namespace in inmported cluster with pulumi rancher?

I found few suggestions:

  1. Delete namespace and recreate as pulumi resource
  2. Get in variable existing namespace and created "updated" copy with project_id that i want

1st don't work for me. I can't delete namespaces, there is apps it can ruin something. And 2nd method don't work for me cause pulumi trying create new namespace with same name, so i got an exception.

It will be legendary if pulumi rancher has a method like "move_namespace" or "move_to_project" somewere, where you can just pass namespace and project_id that needs to apply.

iwahbe commented 5 months ago

I'm not sure what you mean. I'm not sure if it's possible to change the project_id of an existing project (though I doubt it), or move namespaces between projects.

DenMX commented 5 months ago

Move namespaces between projects.

iwahbe commented 4 months ago

I don't believe that moving namespaces between projects is possible with this provider. pulumi-rancher2 is generated from (and has the same capabilities as) rancher/terraform-provider-rancher2, which has as an open issue https://github.com/rancher/terraform-provider-rancher2/issues/891.

That implies that it is not possible to move namespaces between projects with the provider.


If you need to move a namespace between projects, I would try moving the namespace manually (outside of Pulumi), then running pulumi --refresh so Pulumi witnesses the new state. You will then need to adjust your program so it describes your desired state.

DenMX commented 4 months ago

Yea, i found a solution - import from terminal, this command can be generated and executed from code. It's a crutch, but it works. Ty for answers!

iwahbe commented 4 months ago

I'm glad you have found a solution. I'll leave this issue open to track the upstream fix.