-
Notifications
You must be signed in to change notification settings - Fork 113
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
Handle ignoreChanges for Server-Side Apply mode #2074
Conversation
Note: I tagged @pulumi/platform in case anyone has suggestions for a better way to do this now. This implementation seems to work, but I wasn't sure if there was a function somewhere that handles this. |
Does the PR have any schema changes?Looking good! No breaking changes found. |
if err != nil { | ||
return nil, fmt.Errorf("failed to parse ignore path: %w", err) | ||
} | ||
for p := range detailedDiff { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we flip the loops so we go over detailedDiff at the top level and look through ignoreChanges in the nested loop? I assume ignore changes is a typically smaller slice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why we need to do this? I haven't looked through engine code here but I would expect the engine to ignore relevant things from the diff response on the engine side instead? cc @Frassle for comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viveklak There's some additional context in #2012 (comment)
Comment posted from Unblocked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my question was if the engine should be doing the filtering of ignored changes given it has all the information it needs in order to perform the filtering on its side? Currently the provider has the opportunity to hand off diff to the engine with a DiffResponse_DIFF_UNKNOWN
. Does this need to be as all-or-nothing as that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my question was if the engine should be doing the filtering of ignored changes given it has all the information it needs in order to perform the filtering on its side?
I'm not sure about this. With SSA, I'm not sure if the engine would always be operating on the same information as the provider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why we need to do this? I haven't looked through engine code here but I would expect the engine to ignore relevant things from the diff response on the engine side instead?
I remember being confused why there was an ignoreChanges passed to the provider at all when I first saw, thinking the same thing. @pgavlin added it in pulumi/pulumi#3005. The engine will have already reset the inputs map to any old values due to ignoreChanges, I'll admit I'm not sure why this is insufficient for tf/k8ssa 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://pulumi.slack.com/archives/C011EMDQ8JE/p1649841058403479 slack thread where Pat tried to explain why it's needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm not quite sure why this update is needed, but it's not working with the existing Diff code. The Update
method isn't handling ignoreChanges
at all, but it's also not doing any additional diff calculation, so perhaps it's deferring that work to the engine. Given the extra moving parts being introduced with Patch support, I'm hesitant to make major changes to the diff logic right now, so I think we should stick with this fix for the meantime.
Does the PR have any schema changes?Looking good! No breaking changes found. |
|
||
import * as k8s from "@pulumi/kubernetes"; | ||
|
||
// This test creates a Provider with `enableServerSideApply` enabled. The following scenarios are tested: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the comments here! I wish we did this in all the tests that are otherwise not exactly readable as to their intent.
provider/pkg/provider/provider.go
Outdated
} | ||
|
||
if len(detailedDiff) > 0 { | ||
for k := range patchObj { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know this code very well but I wanted to ask if this change here is allright? This is now conditional. detailedDiff
is now filtered by taking IgnoreChanges into account. The copying of patchObj to changes is now conditional. But it is not filtered. Is this OK? Consider:
- IgnoreChanges is meaningful
- detailedDiff got filtered, so
delete(detailedDiff, diffPath.String())
fired a few times - remaining detailedDiff is non-empty; so
len(detailedDiff) > 0
- now changes becomes a copy of
patchObj
, including changes that are filtered out of detailedDiff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think @t0yv0's observation is correct here? Seems like we should be scoping the keys to populate changes from detailedDiff
instead (i.e. things that survived the pruning due to ignoreChanges
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points, thanks. I'll take another look at this logic today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, have a few questions, not super familiar with this code though.
a4aaa11
to
bd1e975
Compare
Does the PR have any schema changes?Looking good! No breaking changes found. |
1 similar comment
Does the PR have any schema changes?Looking good! No breaking changes found. |
@@ -1629,7 +1654,6 @@ func (k *kubeProvider) Diff(ctx context.Context, req *pulumirpc.DiffRequest) (*p | |||
Replaces: replaces, | |||
Stables: []string{}, | |||
DeleteBeforeReplace: deleteBeforeReplace, | |||
Diffs: changes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I got rid of the Diffs
computation and am letting the engine handle this now. The DetailedDiff
computation seems to be necessary to get an accurate diff with Server-side Apply. I tried setting DiffResponse_DIFF_UNKNOWN
, but the result was incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting... Could you add a comment here in code to document the same? (why diffs are omitted?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I think this might be a tiny compatibility break with some very old versions of the CLI (~v0.17.20, which was released in June 2019). I think that the only break would be in the display code, which may no longer render the list of changed properties. I think that this is acceptable.
Does the PR have any schema changes?Looking good! No breaking changes found. |
for _, ignorePath := range ignorePaths { | ||
for _, diffPath := range diffPaths { | ||
if ignorePath.Contains(diffPath) { | ||
delete(detailedDiff, diffPath.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note I have found some instances where resource.PropertyPath doesn't retain the format when calling .String()
. I will have fixes for this as part of pulumi/pulumi#10095. Shouldn't affect this change as long as we pull in fixes after the above lands. FYI.
Proposed changes
Related issues (optional)
Fix #2012