Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
10687: add envvar to omit snapshot writes on each state mutation r=dixler a=dixler <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> Fixes #10668 Provides an environment variable to override the internal behavior of the SnapshotManager to speed up large deployments by only writing the final state of the snapshot rather than the current behavior which saves every mutation to the snapshot to the state backend. ## Checklist <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have updated the [CHANGELOG-PENDING](https://github.com/pulumi/pulumi/blob/master/CHANGELOG_PENDING.md) file with my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Service, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. --> 10729: ci: Fix package parallelism assignment r=AaronFriel a=AaronFriel 10740: Add missing `ProgramTestOptions` overrides in `With` r=justinvp a=justinvp These options were previously added without also adding the override handling in `With`. Co-authored-by: Kyle Dixler <kyle@pulumi.com> Co-authored-by: Aaron Friel <mayreply@aaronfriel.com> Co-authored-by: Justin Van Patten <jvp@justinvp.com>
- Loading branch information
Showing
9 changed files
with
258 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
tests/integration/unsafe_snapshot_tests/bad_resource/Pulumi.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name: bad_resource | ||
runtime: nodejs |
17 changes: 17 additions & 0 deletions
17
tests/integration/unsafe_snapshot_tests/bad_resource/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2016-2022, Pulumi Corporation. All rights reserved. | ||
import * as process from "process"; | ||
import { Resource } from "./resource"; | ||
// Base depends on nothing. | ||
const a = new Resource("base", { uniqueKey: 1, state: 99 }); | ||
|
||
for(let i = 0; i < 1000; i++) { | ||
new Resource(`base-${i}`, { uniqueKey: 100+i, state: 99 }); | ||
} | ||
|
||
// Dependent depends on Base with state 99. | ||
new Resource("dependent", { uniqueKey: a.state.apply(() => { | ||
if (process.env["PULUMI_NODEJS_DRY_RUN"] != "true") { | ||
throw Error("`base` should be created and `dependent` should not"); | ||
} | ||
return 1; | ||
}), state: a.state }); |
13 changes: 13 additions & 0 deletions
13
tests/integration/unsafe_snapshot_tests/bad_resource/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "stack_project_name", | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"typescript": "^3.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@pulumi/pulumi": "latest" | ||
}, | ||
"dependencies": { | ||
"@types/node": "^18.7.17" | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
tests/integration/unsafe_snapshot_tests/bad_resource/resource.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2016-2022, Pulumi Corporation. All rights reserved. | ||
|
||
import * as pulumi from "@pulumi/pulumi"; | ||
import * as dynamic from "@pulumi/pulumi/dynamic"; | ||
|
||
export class Provider implements dynamic.ResourceProvider { | ||
public static readonly instance = new Provider(); | ||
|
||
private id: number = 0; | ||
|
||
public async check(olds: any, news: any): Promise<dynamic.CheckResult> { | ||
// When the engine re-creates a resource after it was deleted, it should | ||
// not pass the old (deleted) inputs to Check when re-creating. | ||
// | ||
// This Check implementation fails the test if this happens. | ||
if (olds.state === 99 && news.state === 22) { | ||
return { | ||
inputs: news, | ||
failures: [ | ||
{ | ||
property: "state", | ||
reason: "engine did invalid comparison of old and new check inputs for recreated resource", | ||
}, | ||
], | ||
}; | ||
} | ||
|
||
return { | ||
inputs: news, | ||
}; | ||
} | ||
|
||
public async diff(id: pulumi.ID, olds: any, news: any): Promise<dynamic.DiffResult> { | ||
if (olds.state !== news.state) { | ||
return { | ||
changes: true, | ||
replaces: ["state"], | ||
deleteBeforeReplace: true, | ||
}; | ||
} | ||
|
||
return { | ||
changes: false, | ||
}; | ||
} | ||
|
||
public async create(inputs: any): Promise<dynamic.CreateResult> { | ||
return { | ||
id: (this.id++).toString(), | ||
outs: inputs, | ||
}; | ||
} | ||
} | ||
|
||
export class Resource extends pulumi.dynamic.Resource { | ||
public uniqueKey?: pulumi.Output<number>; | ||
public state: pulumi.Output<number>; | ||
|
||
constructor(name: string, props: ResourceProps, opts?: pulumi.ResourceOptions) { | ||
super(Provider.instance, name, props, opts); | ||
} | ||
} | ||
|
||
export interface ResourceProps { | ||
readonly uniqueKey?: pulumi.Input<number>; | ||
readonly state: pulumi.Input<number>; | ||
} |