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

The --expect-no-changes flag checks for output diffs #15903

Merged
merged 3 commits into from May 1, 2024

Conversation

PollRobots
Copy link
Contributor

Description

This adds a pseudo op OpOutputChange to the set of changes that are recorded in display.ResourceChanges to count the number of output changes, this is then included in the check used to evaluate the --expect-no-changes flag

When resource outputs are registered, they are checked against their previous value using existing functionality, the total count of changes is then added

The internal capability is validated with an engine test, the cli is validated using an integration test

This will break user workflows that depend on the previous behavior

Fixes #15564

Checklist

  • I have run make tidy to update any new dependencies
  • I have run make lint to verify my code passes the lint check
    • I have formatted my code using gofumpt
  • I have added tests that prove my fix is effective or that my feature works
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version

@PollRobots PollRobots requested a review from a team as a code owner April 11, 2024 00:04
@pulumi-bot
Copy link
Contributor

pulumi-bot commented Apr 11, 2024

Changelog

[uncommitted] (2024-05-01)

Bug Fixes

  • [cli/engine] Make --expect-no-changes fail even if the only changes are output changes
    #15903

@@ -162,7 +163,9 @@ func displayUpdatesJSON(updates []backend.UpdateInfo, decrypter config.Decrypter
info.EndTime = makeStringRef(time.Unix(update.EndTime, 0).UTC().Format(timeFormat))
resourceChanges := make(map[string]int)
for k, v := range update.ResourceChanges {
resourceChanges[string(k)] = v
if k != deploy.OpOutputChange {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we filter out OpOutputChange here? That's not obvious from context, deserves an explanation comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment

newOutputs := step.New().Outputs
diff := oldOutputs.Diff(newOutputs)
if diff.AnyChanges() {
acts.Ops[deploy.OpOutputChange] += len(diff.Adds) + len(diff.Deletes) + len(diff.Updates)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels odd that this counts per-field changes rather than a count of how many resources made any change. Is there a reason to prefer this rather than just +1 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the scenarios where this number is shown to the user, this then means that the number shown matches the listed output diffs

@@ -823,7 +823,7 @@ func TestStackReferenceSecretsNodejs(t *testing.T) {
{
Dir: filepath.Join(d, "nodejs", "step2"),
Additive: true,
ExpectNoChanges: true,
ExpectNoChanges: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just remove the field, it defaults to false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@PollRobots PollRobots force-pushed the proberts/expect-no-changes-should-check-output branch from 6ca6016 to 1f7ee5e Compare April 12, 2024 20:21
@PollRobots PollRobots added this pull request to the merge queue Apr 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 12, 2024
changes:
- type: fix
scope: cli/engine
description: "Fixes #15564, --expect-no-changes now causes pulumi cli to fail if the only changes are output changes"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "Fixes #15564, --expect-no-changes now causes pulumi cli to fail if the only changes are output changes"
description: "Make --expect-no-changes fail if the only changes are output changes"

@PollRobots PollRobots force-pushed the proberts/expect-no-changes-should-check-output branch 2 times, most recently from 8927a32 to 5a4a942 Compare April 15, 2024 16:25
@tgummerer tgummerer disabled auto-merge April 15, 2024 16:54
@PollRobots PollRobots force-pushed the proberts/expect-no-changes-should-check-output branch from 5a4a942 to 6c2125f Compare April 30, 2024 22:02
@PollRobots
Copy link
Contributor Author

This is now safe with pulumi-service

@PollRobots PollRobots added this pull request to the merge queue Apr 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 30, 2024
@PollRobots PollRobots force-pushed the proberts/expect-no-changes-should-check-output branch from 6c2125f to 8a13150 Compare May 1, 2024 00:09
@PollRobots PollRobots enabled auto-merge May 1, 2024 00:09
@PollRobots PollRobots added this pull request to the merge queue May 1, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 1, 2024
@PollRobots PollRobots added this pull request to the merge queue May 1, 2024
Merged via the queue into master with commit b72399b May 1, 2024
49 checks passed
@PollRobots PollRobots deleted the proberts/expect-no-changes-should-check-output branch May 1, 2024 19:17
PollRobots added a commit that referenced this pull request May 6, 2024
github-merge-queue bot pushed a commit that referenced this pull request May 6, 2024
Reverts #15903

This is implicated in Issue #16126 so reverting to allow time to provide
a proper solution

Fixes #16126
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--expect-no-changes doesn't fail on stack output changes
4 participants