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
pulumi refresh --diff does not show a diff #7665
Comments
This sounds like it could be a rendering issue given both the console shows the diff and the CLI shows |
any update on this? I just stumbled upon the same and we're in a situation where it's rather important being able to see the diff of a sync to remediate drift safely. |
Possibly related pulumi/pulumi-aws#3439 - possibly connected to the bridge diff code. |
I have a very simple repro of this to see the behavior. Code ReproPulumi.yamlname: gcp-bucket
runtime: yaml
description: A minimal Google Cloud Pulumi YAML program
resources:
my-bucket-zbuchheit:
properties:
location: US
type: gcp:storage:Bucket Instructions to Repro
Example output from `pulumi refresh --diff --preview-only`
Additional ContextThe command doesn't have to be Output from
|
To clarify what happens with the repo from #7665 (comment):
Both show a diff, but |
To investigate further, I captured the gRPC logs for each request into with-diff.json{
"method": "/pulumirpc.ResourceProvider/GetPluginInfo",
"request": {},
"response": {
"version": "v7.18.0"
},
"metadata": {
"kind": "resource",
"mode": "client",
"name": "gcp"
}
}
{
"method": "/pulumirpc.ResourceProvider/Configure",
"request": {
"variables": {
"gcp:config:project": "pulumi-development",
"gcp:config:region": "us-west1"
},
"args": {
"project": "pulumi-development",
"region": "us-west1"
},
"acceptSecrets": true,
"acceptResources": true,
"sendsOldInputs": true,
"sendsOldInputsToDelete": true
},
"response": {
"supportsPreview": true
},
"metadata": {
"kind": "resource",
"mode": "client",
"name": "gcp"
}
}
{
"method": "/pulumirpc.ResourceProvider/Read",
"request": {
"id": "my-bucket-iwahbe-dbc8024",
"urn": "urn:pulumi:dev::dev-yaml::gcp:storage/bucket:Bucket::my-bucket-iwahbe",
"properties": {
"__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":600000000000,\"read\":240000000000,\"update\":240000000000},\"schema_version\":\"1\"}",
"autoclass": null,
"cors": [],
"customPlacementConfig": null,
"defaultEventBasedHold": false,
"effectiveLabels": {},
"enableObjectRetention": false,
"encryption": null,
"forceDestroy": false,
"id": "my-bucket-iwahbe-dbc8024",
"labels": {},
"lifecycleRules": [],
"location": "US",
"logging": null,
"name": "my-bucket-iwahbe-dbc8024",
"project": "pulumi-development",
"projectNumber": 921927215178,
"publicAccessPrevention": "inherited",
"pulumiLabels": {},
"requesterPays": false,
"retentionPolicy": null,
"rpo": "DEFAULT",
"selfLink": "https://www.googleapis.com/storage/v1/b/my-bucket-iwahbe-dbc8024",
"softDeletePolicy": {
"effectiveTime": "2024-04-10T14:45:55.883Z",
"retentionDurationSeconds": 604800
},
"storageClass": "ARCHIVE",
"uniformBucketLevelAccess": false,
"url": "gs://my-bucket-iwahbe-dbc8024",
"versioning": null,
"website": null
},
"inputs": {
"__defaults": [
"forceDestroy",
"name"
],
"forceDestroy": false,
"location": "US",
"name": "my-bucket-iwahbe-dbc8024",
"storageClass": "ARCHIVE"
}
},
"response": {
"id": "my-bucket-iwahbe-dbc8024",
"properties": {
"__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":600000000000,\"read\":240000000000,\"update\":240000000000},\"schema_version\":\"1\"}",
"autoclass": null,
"cors": [],
"customPlacementConfig": null,
"defaultEventBasedHold": false,
"effectiveLabels": {},
"enableObjectRetention": false,
"encryption": null,
"forceDestroy": false,
"id": "my-bucket-iwahbe-dbc8024",
"labels": {},
"lifecycleRules": [],
"location": "US",
"logging": null,
"name": "my-bucket-iwahbe-dbc8024",
"project": "pulumi-development",
"projectNumber": 921927215178,
"publicAccessPrevention": "inherited",
"pulumiLabels": {},
"requesterPays": false,
"retentionPolicy": null,
"rpo": "DEFAULT",
"selfLink": "https://www.googleapis.com/storage/v1/b/my-bucket-iwahbe-dbc8024",
"softDeletePolicy": {
"effectiveTime": "2024-04-10T14:45:55.883Z",
"retentionDurationSeconds": 604800
},
"storageClass": "ARCHIVE",
"uniformBucketLevelAccess": false,
"url": "gs://my-bucket-iwahbe-dbc8024",
"versioning": null,
"website": null
},
"inputs": {
"__defaults": [
"forceDestroy",
"name"
],
"forceDestroy": false,
"location": "US",
"name": "my-bucket-iwahbe-dbc8024",
"storageClass": "ARCHIVE"
}
},
"metadata": {
"kind": "resource",
"mode": "client",
"name": "gcp"
}
} no-diff.json{
"method": "/pulumirpc.ResourceProvider/GetPluginInfo",
"request": {},
"response": {
"version": "v7.18.0"
},
"metadata": {
"kind": "resource",
"mode": "client",
"name": "gcp"
}
}
{
"method": "/pulumirpc.ResourceProvider/Configure",
"request": {
"variables": {
"gcp:config:project": "pulumi-development",
"gcp:config:region": "us-west1"
},
"args": {
"project": "pulumi-development",
"region": "us-west1"
},
"acceptSecrets": true,
"acceptResources": true,
"sendsOldInputs": true,
"sendsOldInputsToDelete": true
},
"response": {
"supportsPreview": true
},
"metadata": {
"kind": "resource",
"mode": "client",
"name": "gcp"
}
}
{
"method": "/pulumirpc.ResourceProvider/Read",
"request": {
"id": "my-bucket-iwahbe-dbc8024",
"urn": "urn:pulumi:dev::dev-yaml::gcp:storage/bucket:Bucket::my-bucket-iwahbe",
"properties": {
"__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":600000000000,\"read\":240000000000,\"update\":240000000000},\"schema_version\":\"1\"}",
"autoclass": null,
"cors": [],
"customPlacementConfig": null,
"defaultEventBasedHold": false,
"effectiveLabels": {},
"enableObjectRetention": false,
"encryption": null,
"forceDestroy": false,
"id": "my-bucket-iwahbe-dbc8024",
"labels": {},
"lifecycleRules": [],
"location": "US",
"logging": null,
"name": "my-bucket-iwahbe-dbc8024",
"project": "pulumi-development",
"projectNumber": 921927215178,
"publicAccessPrevention": "inherited",
"pulumiLabels": {},
"requesterPays": false,
"retentionPolicy": null,
"rpo": "DEFAULT",
"selfLink": "https://www.googleapis.com/storage/v1/b/my-bucket-iwahbe-dbc8024",
"softDeletePolicy": {
"effectiveTime": "2024-04-10T14:45:55.883Z",
"retentionDurationSeconds": 604800
},
"storageClass": "STANDARD",
"uniformBucketLevelAccess": false,
"url": "gs://my-bucket-iwahbe-dbc8024",
"versioning": null,
"website": null
},
"inputs": {
"__defaults": [
"forceDestroy",
"name",
"storageClass"
],
"forceDestroy": false,
"location": "US",
"name": "my-bucket-iwahbe-dbc8024",
"storageClass": "STANDARD"
}
},
"response": {
"id": "my-bucket-iwahbe-dbc8024",
"properties": {
"__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":600000000000,\"read\":240000000000,\"update\":240000000000},\"schema_version\":\"1\"}",
"autoclass": null,
"cors": [],
"customPlacementConfig": null,
"defaultEventBasedHold": false,
"effectiveLabels": {},
"enableObjectRetention": false,
"encryption": null,
"forceDestroy": false,
"id": "my-bucket-iwahbe-dbc8024",
"labels": {},
"lifecycleRules": [],
"location": "US",
"logging": null,
"name": "my-bucket-iwahbe-dbc8024",
"project": "pulumi-development",
"projectNumber": 921927215178,
"publicAccessPrevention": "inherited",
"pulumiLabels": {},
"requesterPays": false,
"retentionPolicy": null,
"rpo": "DEFAULT",
"selfLink": "https://www.googleapis.com/storage/v1/b/my-bucket-iwahbe-dbc8024",
"softDeletePolicy": {
"effectiveTime": "2024-04-10T14:45:55.883Z",
"retentionDurationSeconds": 604800
},
"storageClass": "ARCHIVE",
"uniformBucketLevelAccess": false,
"url": "gs://my-bucket-iwahbe-dbc8024",
"versioning": null,
"website": null
},
"inputs": {
"__defaults": [
"forceDestroy",
"name"
],
"forceDestroy": false,
"location": "US",
"name": "my-bucket-iwahbe-dbc8024",
"storageClass": "ARCHIVE"
}
},
"metadata": {
"kind": "resource",
"mode": "client",
"name": "gcp"
}
} The only difference between the two is the the Read request (the response is identical): 𝛌 json-diff <(jq --sort-keys .request with-diff.json) <(jq --sort-keys .request no-diff.json)
{
inputs: {
__defaults: [
...
...
+ "storageClass"
]
- storageClass: "ARCHIVE"
+ storageClass: "STANDARD"
}
properties: {
- storageClass: "ARCHIVE"
+ storageClass: "STANDARD"
}
} This makes me pretty convinced that the problem is in https://github.com/pulumi/pulumi, not https://github.com/pulumi/pulumi-gcp. |
Here's my quick read (I was curious). We seem to intentionally skip showing detailed diffs for refreshes and imports: pulumi/pkg/backend/display/diff.go Line 415 in 29dfdca
But this seems immaterial, because pulumi/pkg/backend/display/diff.go Line 390 in 29dfdca
Why is that pulumi/pkg/resource/deploy/step.go Lines 777 to 787 in 29dfdca
And the engine seems to have been taught to handle the fact that not all steps have Lines 350 to 355 in 29dfdca
Hence the So I guess, unless I'm mistaken or missing something, this is behaving as "intended" by the original implementation -- but if you ask me, it's surprising and should be addressed. |
So I think this might just be the
It looks like this is trying to say "if it's a logical update only show it if we're in progress mode or we've explicitly set ShowReplacmentSteps. But the actual logic means any non-logical step gets skipped in diff or json mode. Fixing that to instead be:
Now shows refresh updates in diff mode, but I suspect this is going to change a lot of display output for diff mode. |
When displaying diff events, we currently try to hide non-logical replacement steps unless we specifically enable showing them. However we currently do that for all non-logical operations, regardless whether they are replacement steps or not. In particular a RefreshStep is non-logical, but it's also not a replacement step. We still want to show them during the diff because their output can be important. Especially if the user just requested a diff it doesn't make sense to hide the diff from them at the same time. The intention here is to only hide replacement steps, so do that. The full diff with the display tests is here: https://gist.github.com/tgummerer/fcd012f13669a9cdc39530cde7770260 It's unedited, so it includes some flakyness which isn't interesting. I looked it over, and I think it looks like what we want, but I'm curious to hear what others think. E.g. https://gist.github.com/tgummerer/fcd012f13669a9cdc39530cde7770260#file-testdata-diff-L558 looks more correct now, as it shows the two delete operation that actually happened, that it didn't show before, and it still shows the same operation (Calling this one out in particular, since it took me a bit to understand that we still have the same operation in the diff) Fixes #7665
I'd like to see the differences between actual values of resources' attributes and their Pulumi state.
Steps to reproduce
Expected:
A diff like:
Actual:
No diff output:
The funny thing is that the Pulumi Console shows a nice diff for the same run:
The text was updated successfully, but these errors were encountered: