fix: GCP data disk snapshot never refreshed after first stop cycle#389
fix: GCP data disk snapshot never refreshed after first stop cycle#389arnaud-robin wants to merge 1 commit into
Conversation
|
Thanks for this PR! Have you tested the fix yourself? |
|
Yes I just tested it and the fix is working as intended. A new snapshot is created after each stop cycle and the data is restored as intended. |
|
Tested, reproduced the issue and it works with the fix. Thanks! Will merge soon after review comments are processed :) |
| * Unique version identifier for the snapshot. A new value forces creation | ||
| * of a fresh snapshot replacing the previous one. | ||
| */ | ||
| snapshotVersion?: string |
There was a problem hiding this comment.
This should be required, not optional, given the behavior identified. It will also avoid having checks for undefined in code - being cleaner
| const config = new pulumi.Config() | ||
| const volumeId = config.get("volumeId") | ||
| const additionalTags = config.getObject<string[]>("additionalTags") || [] | ||
| const snapshotVersion = config.get("snapshotVersion") |
There was a problem hiding this comment.
| const snapshotVersion = config.get("snapshotVersion") | |
| const snapshotVersion = config.require("snapshotVersion") |
| // and force replacement of snapshot if volumeId changes | ||
| deleteBeforeReplace: true, | ||
| replaceOnChanges: ["sourceDisk"], | ||
| replaceOnChanges: ["sourceDisk", "name"], |
There was a problem hiding this comment.
Not needed to replaceOnChanges name, changing name already causes a replacement: https://www.pulumi.com/registry/packages/gcp/api-docs/compute/snapshot/#inputs
| /** | ||
| * Unique version identifier forcing snapshot replacement when it changes. | ||
| */ | ||
| snapshotVersion?: pulumi.Input<string> |
There was a problem hiding this comment.
As in other comment: should be required
GCP data disk snapshot was only created on the first instance stop and never updated afterwards, causing any data written after the first stop/start cycle to be lost on restart (PierreBeucher#388). The snapshot stack relied on replaceOnChanges: ["sourceDisk"] to take a fresh snapshot on each stop, a pattern inherited from AWS where a volume restored from snapshot gets a brand new random ID (vol-xxx), naturally triggering replacement. On GCP however the disk is identified by its name (<instance>-data) which stays identical across delete/restore cycles: Pulumi saw no diff on subsequent stops and silently kept the stale snapshot. Since GCP provides no naturally-changing input, introduce a synthetic one: provisioner now passes a unique snapshotVersion (timestamp) on every data snapshot provision, included in the snapshot name. GCP snapshot names are immutable so the name change forces Pulumi to replace the snapshot on every stop cycle.
ee03c77 to
1a4979f
Compare
|
Updated thanks to your comments |
GCP data disk snapshot was only created on the first instance stop and
never updated afterwards, causing any data written after the first
stop/start cycle to be lost on restart
The snapshot stack relied on replaceOnChanges: ["sourceDisk"] to take a
fresh snapshot on each stop, a pattern inherited from AWS where a volume
restored from snapshot gets a brand new random ID (vol-xxx), naturally
triggering replacement. On GCP however the disk is identified by its
name (-data) which stays identical across delete/restore
cycles: Pulumi saw no diff on subsequent stops and silently kept the
stale snapshot.
Since GCP provides no naturally-changing input, introduce a synthetic
one: provisioner now passes a unique snapshotVersion (timestamp) on
every data snapshot provision, included in the snapshot name. GCP
snapshot names are immutable so the name change forces Pulumi to
replace the snapshot on every stop cycle.
Fix #388