How do I refresh pulumi state for my stack to sync...
# general
m
How do I refresh pulumi state for my stack to sync with the actual state of my cloud infra? Namely, I have k8s resources (service, deployment, ingress) showing in my state, but the cluster was manually deleted. When I do
pulumi refresh
, I get the following error for these k8s resources:
Copy code
failed to read resource state due to unreachable cluster. If the cluster has been deleted, you can edit the pulumi state to remove this resource
So I get the URN by executing
pulumi stack --show-urns
. But when I copy the URN for the k8s resource in to
pulumi state delete <urn>
, I see the error:
No such resource "<urn>" exists in the current state
Is there a way to sync state so I can reliably do
pulumi destroy/up
again with the correct assumptions about current state of cloud infra?
b
is your cluster unreachable?
m
Yes, it’s deleted
b
set the environment variables
PULUMI_K8S_DELETE_UNREACHABLE
and then run
pulumi refresh
1
PULUMI_K8S_DELETE_UNREACHABLE=true
m
Get the same error
I believe the state is very out of sync now. It doesn’t include resources that are there, and it includes resources that have been deleted/are unreachable. Are there any mechanisms for being able to clear this and run pulumi up? I’d be willing to manually go in and delete all the infra by hand, but want to ensure when
pulumi up
executes that it wouldn’t make false assumptions about certain resources being up with a non-empty state.
b
You must be on an old provider version, you'll have to manually remove the resources in which case
m
Right, I’ll do that on the infra side. But how do I clear the pulumi state for the stack? After I delete the infra, if I run
pulumi up
, it’ll still assume the k8s resources are there since they’re in the state.
b
you'll need to
pulumi stack export
modify the JSON to remove the resources then
pulumi stack import --file
or if you have the urns, you can do
pulumi state delete <urn>
m
export --> import probably would have done the trick. Didn’t let me delete urns since it claimed they didn’t exist. Ended up deleting the stack and redeploying.
351 Views