Repository navigation
For dsc resource command, always use Actual Get even when WhatIf is used - #1839
Closed
Steve Lee (SteveL-MSFT) wants to merge 1 commit into
Closed
Steve Lee (SteveL-MSFT) wants to merge 1 commit into
Steve Lee (SteveL-MSFT) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Delete what-if previews lose required set-result fields or emit no stdout, and final-get shutdown failures can be logged without failing the command.
3 open issues
What changed in this PR
This PR updates the delete path used by dsc resource set so state reads use Actual, while deletion honors the requested execution kind.
Changes:
- Forces actual-state reads before and after an actual deletion.
- Separates handling of actual deletion, native WhatIf, and synthetic WhatIf results.
- Moves operation completion to the delete call.
| File | Description |
|---|---|
dsc/src/resource_command.rs |
Adjusts execution kinds, result handling, and completion for set operations routed to delete. |
Review effort: Balanced
| write_object(&json, format, false)?; | ||
| } | ||
| DeleteResultKind::ResourceWhatIf(delete_result) => { | ||
| let json = match serde_json::to_string(&delete_result) { |
Comment on lines
+228
to
+230
| DeleteResultKind::SyntheticWhatIf(_) => { | ||
| info!("{} {}", resource.type_name(), t!("resource_command.syntheticWhatIf")); | ||
| } |
| DeleteResultKind::ResourceActual => { | ||
| // After an actual delete, re-read state and compute diff. | ||
| context.execution_type = ExecutionKind::Actual; | ||
| let after_state = match resource.get(input, &context) { |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


PR Summary
Setting
execution_typeaswhatIfcould result in incorrectgeteven though resources don't implementwhatIfforget, but if this changes, then the result is hypothetical rather than actual.The change here is to always use
Actualfor agetwhile setting it to the specified execution_kind for the actualdelete.