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

Error when setting VPC as parent of EKS cluster #1209

Closed
harryttd opened this issue Jan 26, 2024 · 4 comments
Closed

Error when setting VPC as parent of EKS cluster #1209

harryttd opened this issue Jan 26, 2024 · 4 comments
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec

Comments

@harryttd
Copy link

harryttd commented Jan 26, 2024

What happened?

I'm trying to create awsx.ec2.VPC and eks.Cluster resources. For the parent option in ResourceOptions of the cluster, i set it to the vpc. Pulumi doesn’t like this and i get the runtime detected promises were still active error (see below). Removing the parent option avoids the error. This did not use to happen in older versions of awsx. I'm upgrading to v2.4.0 from v0.40.0.
Error:

    The Pulumi runtime detected that 947 promises were still active
    at the time that the process exited. There are a few ways that this can occur:
      * Not using `await` or `.then` on a Promise returned from a Pulumi API
      * Introducing a cyclic dependency between two Pulumi Resources
      * A bug in the Pulumi Runtime
    Leaving promises active is probably not what you want. If you are unsure about
    why you are seeing this message, re-run your program with the `PULUMI_DEBUG_PROMISE_LEAKS`
    environment variable. The Pulumi runtime will then print out additional
    debug information about the leaked promises.

    error: an unhandled error occurred: Program exited with non-zero exit code: 1

Example

const vpc = new awsx.ec2.Vpc(
  project,
  {
    subnetStrategy: "Auto",
    subnetSpecs: [
      // Tag subnets for specific load-balancer usage.
      // Any non-null tag value is valid.
      // See:
      //  - https://docs.aws.amazon.com/eks/latest/userguide/network_reqs.html
      //  - https://github.com/pulumi/pulumi-eks/issues/196
      //  - https://github.com/pulumi/pulumi-eks/issues/415
      { type: "Public", tags: { "kubernetes.io/role/elb": "1" } },
      { type: "Private", tags: { "kubernetes.io/role/internal-elb": "1" } },
    ],
    tags: { Name: projectStack },
  },
  {
    // Inform pulumi to ignore tag changes to the VPCs or subnets, so that
    // tags auto-added by AWS EKS do not get removed during future
    // refreshes and updates, as they are added outside of pulumi's management
    // and would be removed otherwise.
    // See: https://github.com/pulumi/pulumi-eks/issues/271#issuecomment-548452554
    transformations: [
      (args: any) => {
        if (["aws:ec2/vpc:Vpc", "aws:ec2/subnet:Subnet"].includes(args.type)) {
          return {
            props: args.props,
            opts: pulumi.mergeOptions(args.opts, { ignoreChanges: ["tags"] }),
          }
        }
        return
      },
    ],
  }
)

const cluster = new eks.Cluster(
  project,
  {
    createOidcProvider: true,
    version: "1.27",
    vpcId: vpc.vpcId,
    publicSubnetIds: vpc.publicSubnetIds,
    privateSubnetIds: vpc.privateSubnetIds,
    instanceType: "t3.large",
    minSize: 2,
    maxSize: 2,
    desiredCapacity: 2,
  },
  { parent: vpc }
)

Output of pulumi about

CLI          
Version      3.102.0
Go Version   go1.21.6
Go Compiler  gc

Plugins
NAME    VERSION
nodejs  unknown

Host     
OS       darwin
Version  14.0
Arch     x86_64

This project is written in nodejs: executable='/usr/local/bin/node' version='v20.2.0'

Additional context

package.json:

    "dependencies": {
        "@pulumi/aws": "^6.18.2",
        "@pulumi/awsx": "^2.4.0",
        "@pulumi/pulumi": "^3.103.1",
    }

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

@harryttd harryttd added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jan 26, 2024
@harryttd
Copy link
Author

Update: Perhaps this is a bug in the eks pkg, as I'm able to add the vpc as a parent to a resource like an aws.rds.SubnetGroup without any errors. I've tried with version: "@pulumi/eks": "^2.1.0"

@mjeffryes
Copy link
Member

Thanks for reaching out @harryttd. I think the issue here is that the eks.Cluster resource depends on the output of the VPC in it's creation. It is a bit unfortunate that the error message doesn't make that clear though.

In general, you shouldn't use the parent property to try connect resources that are peers or that depend on one another. Instead you should create a higher level component resource that both the VPC and the cluster can have as a parent. (see the note on https://www.pulumi.com/docs/concepts/options/parent/)

@mjeffryes mjeffryes added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Jan 30, 2024
@harryttd
Copy link
Author

Thanks for your reply @mjeffryes and for the link. I see that it says:

it is strongly recommended to parent resources only to component resources when they are actually children...

It's interesting because as I mentioned earlier, I had no issue setting the parent in older package versions. Creating a component resource for the VPC and Cluster in my case would be overkill. It's nice to keep them top level and to see a clearly delineated relationship tree in Pulumi logs.

I don't see why the cluster should not be able to wait for the outputs of the VPC like it has up until whatever version exactly this behavior changed. In fact here's a Pulumi repo example of an ECS cluster setting the VPC as the parent. Not sure why an EKS cluster should be any different.

@mjeffryes
Copy link
Member

Creating a component resource for the VPC and Cluster in my case would be overkill. It's nice to keep them top level and to see a clearly delineated relationship tree in Pulumi logs.

Setting VPC as the parent actually makes the Cluster a child resource so it's not at the top level anymore. If you want to keep both resources at the top-level, removing the parent property should do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

2 participants