pulumi/pulumi-kubernetes-operator

Deleting a Program before deleting a Stack blocks the deletion of the Stack

roothorp opened this issue · 0 comments

What happened?

If deleting both a stack and a program at the same time (e.g. they are defined in the same file, or if done manually), the program will delete fine, but the stack will enter a stalled condition as it tries to resolve a reference to a program that does not exist. This hangs the deletion of the stack (and blocks your terminal, as kubectl waits).

If the program is re-created, the stack will catch up and delete, and the program can be deleted again. Doing this, as far as I can tell, appropriately deletes and cleans up resources created by the stack.

Steps to reproduce

Define a stack and a program in the same YAML file
apiVersion: pulumi.com/v1
kind: Stack
metadata:
  name: deployment-example
spec:
  stack: deployment-example
  programRef:
    name: deployment-example
  destroyOnFinalize: true
  envRefs:
    PULUMI_ACCESS_TOKEN:
      type: Secret
      secret:
        name: pulumi-api-secret
        key: accessToken
---
apiVersion: pulumi.com/v1
kind: Program
metadata:
  name: deployment-example
program:
  resources:
    random:
      type: random:RandomInteger
      properties:
        min: 1
        max: 10
    nginx:
      type: kubernetes:apps/v1:Deployment
      properties:
        metadata:
          name: nginx2
        spec:
          selector:
            matchLabels:
              app: nginx
          replicas: ${random.result}
          template: 
            metadata:
              labels: 
                app: nginx
            spec:
              containers:
                - name: nginx
                  image: nginx

Create the resources with kubectl create -f <file>

Delete the resources with kubectl delete -f <file>
The delete will hang; kubectl describe-ing the stack in another terminal window will show it has stalled as it tries to find the program.

If you once again create the resources with kubectl create -f <file>, the stack fails to create (as it already exists), the Program creates (as it has already been deleted), and the Stack finds the Program and deletes finally. You can then kubectl delete -f <file> again to clean up the Program.

Expected Behavior

Stack should delete, even when it cannot find the program references.

Actual Behavior

Delete hangs when the stack is stalled looking for the referenced program.

Output of pulumi about

No response

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).