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

Computed annotations are not showing up correctly in preview for autonamed resources #438

Closed
beetahnator opened this issue Feb 20, 2019 · 3 comments · Fixed by #461
Closed
Assignees
Labels
area/providers impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec
Milestone

Comments

@beetahnator
Copy link
Contributor

beetahnator commented Feb 20, 2019

In the example below, the computed value for the aws security group within metadata.annotations causes all of the supplied annotations to disappear (including the plaintext foo: bar).

Using .apply does not seem to work either.

Expected behavior: Both foo and the computed-value annotation should be present in the update preview.

Current behavior: Only the pulumi.com/autonamed annotation is shown on previews.

pulumi plan output

{
    "name": "aws-typescript",
    "devDependencies": {
        "@types/node": "latest"
    },
    "dependencies": {
        "@pulumi/aws": "latest",
        "@pulumi/kubernetes": "^0.20.2",
        "@pulumi/pulumi": "latest"
    }
}
import * as k8s from "@pulumi/kubernetes";
import * as aws from "@pulumi/aws";

const securityGroup = new aws.ec2.SecurityGroup('sgtest', {
  description: "Container node security group",
  egress: [{
    cidrBlocks: ["0.0.0.0/0"],
    fromPort: 0,
    protocol: "-1",
    toPort: 0,
  }],
  ingress: [{
    cidrBlocks: ["0.0.0.0/0"],
    fromPort: 0,
    protocol: "-1",
    toPort: 0,
  }],
})

const pod = new k8s.core.v1.Pod("podtest", {
  metadata: {
    annotations: {
      "foo": "bar",
      'computed-value': securityGroup.id.apply(id => { return id })
    }
  },
  spec: {
    containers: [{
      name: "nginx",
      image: "nginx:1.13-alpine"
    }]
  }
})

const ingress = new k8s.extensions.v1beta1.Ingress("ingresstest", {
  metadata: {
    annotations: {
      'foo': "bar",
      'computed-value': securityGroup.id
    }
  },
  spec: {
    rules: [
      {
        http: {
          paths: [{
            path: "*",
            backend: {
              serviceName: "test",
              servicePort: 8080
            }
          }]
        }
      }
    ]
  }
})
@lblackstone lblackstone self-assigned this Feb 20, 2019
@lblackstone lblackstone added area/providers impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec labels Feb 20, 2019
@lblackstone
Copy link
Member

lblackstone commented Feb 20, 2019

@mazamats Thanks for the detailed report!

I was able to reproduce this behavior. The annotations are not showing up in preview for either the Ingress or Pod, but they are created when the update runs.

Here's a slightly modified version that successfully updates:

import * as k8s from "@pulumi/kubernetes";
import * as aws from "@pulumi/aws";

const securityGroup = new aws.ec2.SecurityGroup('sgtest', {
    description: "Container node security group",
    egress: [{
        cidrBlocks: ["0.0.0.0/0"],
        fromPort: 0,
        protocol: "-1",
        toPort: 0,
    }],
    ingress: [{
        cidrBlocks: ["0.0.0.0/0"],
        fromPort: 0,
        protocol: "-1",
        toPort: 0,
    }],
});

const pod = new k8s.core.v1.Pod("podtest", {
    metadata: {
        annotations: {
            "foo": "bar",
            'computed-value': securityGroup.id
        }
    },
    spec: {
        containers: [{
            name: "nginx",
            image: "nginx:1.13-alpine"
        }]
    }
});

const ingress = new k8s.extensions.v1beta1.Ingress("ingresstest", {
    metadata: {
        annotations: {
            'foo': "bar",
            'computed-value': securityGroup.id,
            "pulumi.com/skipAwait": "true"
        }
    },
    spec: {
        rules: [
            {
                http: {
                    paths: [{
                        backend: {
                            serviceName: "test",
                            servicePort: 8080
                        }
                    }]
                }
            }
        ]
    }
});
"apiVersion": "v1",
    "kind": "Pod",
    "metadata": {
        "annotations": {
            "computed-value": "sg-09c7e02cbada2066a",
            "foo": "bar",
            "pulumi.com/autonamed": "true"
        },
        "creationTimestamp": "2019-02-20T16:36:27Z",
        "labels": {
            "app.kubernetes.io/managed-by": "pulumi"
        },
        "name": "podtest-bdktmpm5",
        "namespace": "default",
        "resourceVersion": "969710",
        "selfLink": "/api/v1/namespaces/default/pods/podtest-bdktmpm5",
        "uid": "ab1bf321-352d-11e9-acef-025000000001"
    }

@lblackstone lblackstone added this to the 0.21 milestone Feb 20, 2019
@lblackstone lblackstone changed the title metadata annotations do not work with computed aws security group values Annotations are not showing up correctly in preview Feb 20, 2019
@lblackstone lblackstone changed the title Annotations are not showing up correctly in preview Computed annotations are not showing up correctly in preview Feb 25, 2019
@lblackstone
Copy link
Member

Some further testing showed that simple annotations work fine on the preview; it's only when an annotation uses a computed value that they don't show up in the preview.

For example:

const pod = new k8s.core.v1.Pod("pod-test", {
    metadata: {
        annotations: {
            "foo": "bar"
        }
    },
    spec: {
        containers: [
            {name: "nginx", image: "nginx:1.13-alpine"},
        ],
    },
});

works as expected:
screen shot 2019-02-25 at 4 35 15 pm

When at least one annotation uses a computed value, only the pulumi.com/autonamed annotation shows up:

const rand = new random.RandomString("rand", {length: 6});

const pod = new k8s.core.v1.Pod("pod-test", {
    metadata: {
        annotations: {
            "random": rand.result,
            "foo": "bar",
        }
    },
    spec: {
        containers: [
            {name: "nginx", image: "nginx:1.13-alpine"},
        ],
    },
});

screen shot 2019-02-25 at 4 38 26 pm

@lblackstone
Copy link
Member

Manually overriding the name, which prevents the pulumi.com/autonamed annotation from being set works as expected, so that's probably the source of the bug:

const rand = new random.RandomString("rand", {length: 6});

const pod = new k8s.core.v1.Pod("pod-test", {
    metadata: {
        name: "foo",
        annotations: {
            "random": rand.result,
            "foo": "bar",
        }
    },
    spec: {
        containers: [
            {name: "nginx", image: "nginx:1.13-alpine"},
        ],
    },
});

screen shot 2019-02-25 at 4 41 49 pm

@lblackstone lblackstone changed the title Computed annotations are not showing up correctly in preview Computed annotations are not showing up correctly in preview for autonamed resources Feb 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/providers impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants