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

Labels do not import cleanly #2390

Open
iwahbe opened this issue Sep 17, 2024 · 6 comments
Open

Labels do not import cleanly #2390

iwahbe opened this issue Sep 17, 2024 · 6 comments
Labels
area/import An issue related to `pulumi import` or the import resource option. kind/bug Some behavior is incorrect or out of spec

Comments

@iwahbe
Copy link
Member

iwahbe commented Sep 17, 2024

Describe what happened

I expect that refresh works well with unmanaged labels.

We should be able to run for the sample program pulumi up --yes && pulumi refresh --yes && pulumi preview --expect-no-changes.

Sample program

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
import { local } from "@pulumi/command";

const gcpConfig = new pulumi.Config("gcp");

const provider = new gcp.Provider("provider", {
  project: gcpConfig.require("project"),
  region: gcpConfig.require("region"),
  defaultLabels: {
    "default-empty": "",
  },
});

const r = new gcp.kms.KeyRing("ring", {
  location: "us-east1",
}, {provider});

const k = new gcp.kms.CryptoKey("key", {
  keyRing: r.id,
  labels: {
    "static": "value",
    //    "empty": "",
  },
}, {deletedWith: r, provider});

export const create = pulumi.interpolate`gcloud kms keys update ${k.id} --keyring=${r.id} --update-labels=unmanaged=value,unmanaged_empty=`;

new local.Command("cmd", {
  create,
}, { deletedWith: k });

export const labels =  k.labels;
export const pulumiLabels = pulumi.unsecret(k.pulumiLabels);
export const effectiveLabels = pulumi.unsecret(k.effectiveLabels);

Log output

NA

Affected Resource(s)

No response

Output of pulumi about

NA

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 iwahbe added area/import An issue related to `pulumi import` or the import resource option. kind/bug Some behavior is incorrect or out of spec labels Sep 17, 2024
@VenelinMartinov
Copy link
Contributor

Which bit does not work here?

@iwahbe iwahbe mentioned this issue Sep 17, 2024
1 task
@VenelinMartinov
Copy link
Contributor

Also is this different with storage Bucket? If so, then this might be a duplicate of #1959

@iwahbe
Copy link
Member Author

iwahbe commented Sep 17, 2024

When we run the normal cycle, we see that pulumi refresh --yes doesn't generate any diff. When the refresh runs (--yes), no changes are shown but the next pulumi up will add the missing unmanaged labels to effectiveLabels.

This is primarily about the refresh behavior, so it is not a duplicate of #1959.

@VenelinMartinov
Copy link
Contributor

Does that happen without the refresh? AFAIK up actually does an implicit Read of the labels on the cloud resource

@VenelinMartinov
Copy link
Contributor

Either way, this doesn't seem like a huge issue to me - effectiveLabels is meant to represent the actual labels on the resource, so it is expected to change when unmanaged labels change.

@iwahbe
Copy link
Member Author

iwahbe commented Sep 17, 2024

Does that happen without the refresh? AFAIK up actually does an implicit Read of the labels on the cloud resource

Only with refresh.

Either way, this doesn't seem like a huge issue to me - effectiveLabels is meant to represent the actual labels on the resource, so it is expected to change when unmanaged labels change.

pulumi up --yes && pulumi refresh --yes && pulumi preview --expect-no-changes should always succeed. In the case of the above, the refresh should show a diff (but doesn't) and the second update shouldn't have a diff (but it has the diff that refresh should have had).

The final result is correct, but the order is very wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/import An issue related to `pulumi import` or the import resource option. kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

2 participants