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

Fixed a bug in #4199 that resulted in wrong Out of Sync. #4248

Merged
merged 11 commits into from
Mar 8, 2023
Merged

Conversation

funera1
Copy link
Member

@funera1 funera1 commented Mar 6, 2023

What this PR does / why we need it:
Fixed a bug in #4199 that resulted in wrong Out of Sync.
Also, during this modification, the diff option WithIgnoreAddingMapKeys was made commutative. That is, diff a b = diff b a.
I would like to discuss the validity of this modification.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

NONE

@funera1
Copy link
Member Author

funera1 commented Mar 8, 2023

@knanao
Please review this PR, when you have time:bow:

@knanao knanao merged commit c93204e into master Mar 8, 2023
@knanao knanao deleted the fix_#4199 branch March 8, 2023 08:57
@@ -53,19 +53,19 @@ type DiffListChange struct {
func Diff(old, new Manifest, logger *zap.Logger, opts ...diff.Option) (*diff.Result, error) {
if old.Key.IsSecret() && new.Key.IsSecret() {
var err error
new.u, err = normalizeNewSecret(old.u, new.u)
old.u, err = normalizeNewSecret(old.u, new.u)
Copy link
Member

Choose a reason for hiding this comment

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

sorry but why does normalizeNewSecret return old stub 🤔 This does not make sense to me 👀

Copy link
Member Author

@funera1 funera1 Mar 9, 2023

Choose a reason for hiding this comment

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

In a nutshell, it is because we swapped the order of headManifest and liveManifest in Diff.
The ignoreAddingMapKeys in diff/diff.go is to ignore LiveManifest and normalizeNewSecret depends on to ignore LiveManifest with ignoreAddingMapKeys.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for clarifying, then in that case, why not just mention directly here that it's Live/Head manifest or, even better Base/Compare instead of Old/New one here? 🤔 I'm not talking about the logic but the readability of the code, return value from normalizeNewSecret is set to old one doesn't make sense to me, that's my point 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

I see what you mean. I too have a problem with the fact that old/new is not explicitly tied to live/head.
However, since the relationship between old/new and live/head is not only in this section, but is tied across the board, I also think that a separate Issue or PR should be created to rename it.

Or is your point that normalizeNewSecret should be normalizeOldSecret? If so, I will create an improved PR immediately.

Copy link
Member

Choose a reason for hiding this comment

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

I also think that a separate Issue or PR should be created to rename it.

Yes, It's what I mean too 👍 The logic around this part is tricky, and if the flow & naming are hard to follow, it's hard for us to debug next time problems occur around here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I will create this issue. Thank you for nice comment:smile:

@github-actions github-actions bot mentioned this pull request Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants