Skip to content

Fix dr dependency miss #38088

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

Merged
merged 1 commit into from
Apr 1, 2022
Merged

Fix dr dependency miss #38088

merged 1 commit into from
Apr 1, 2022

Conversation

hzxuzhonghu
Copy link
Member

@hzxuzhonghu hzxuzhonghu commented Mar 23, 2022

Please provide a description of this PR:

Fix #38082

For merged DRs, currently we have only one DR meta(name/namespace) and add only one DR dependency.
And so we will miss xds push for some update.

The pr solves this by recording all DRs' meta, and adding all dependencies.

@hzxuzhonghu hzxuzhonghu requested a review from a team as a code owner March 23, 2022 10:36
@istio-testing istio-testing added do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-rebase Indicates a PR needs to be rebased before being merged labels Mar 23, 2022
@istio-testing istio-testing removed the needs-rebase Indicates a PR needs to be rebased before being merged label Mar 24, 2022
@hzxuzhonghu hzxuzhonghu changed the title WIP: Fix dr dependency miss Fix dr dependency miss Mar 25, 2022
@istio-testing istio-testing removed the do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. label Mar 25, 2022
@hzxuzhonghu
Copy link
Member Author

@howardjohn Ready now

@hzxuzhonghu hzxuzhonghu added the release-notes-none Indicates a PR that does not require release notes. label Mar 25, 2022
@hzxuzhonghu
Copy link
Member Author

Kindly ping @howardjohn in case you missed it

Copy link
Contributor

@ramaraochavali ramaraochavali left a comment

Choose a reason for hiding this comment

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

some comments

@@ -80,37 +83,56 @@ func (ps *PushContext) mergeDestinationRule(p *consolidatedDestRules, destRuleCo
}

// DestinationRule does not exist for the resolved host so add it
p.destRule[resolvedHost] = &destRuleConfig
p.destRule[resolvedHost] = convertConsolidateDestRule(&destRuleConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: convertConsolidateDestRule -> convertConsolidatedDestRule

p.exportTo[resolvedHost] = exportToMap
}

// inheritDestinationRule child config inherits settings from parent mesh/namespace
func (ps *PushContext) inheritDestinationRule(parent, child *config.Config) *config.Config {
func (ps *PushContext) inheritDestinationRule(parent, child *consolidateDestRule) *consolidateDestRule {
Copy link
Contributor

Choose a reason for hiding this comment

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

consolidateDestRule -> consolidatedDestRule

if parent == nil {
return child
}
if child == nil {
return parent
}

parentDR := parent.Spec.(*networking.DestinationRule)
if reflect.DeepEqual(parent.sourceRules, child.sourceRules) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to avoid reflect.DeepEqual?

@@ -115,14 +116,14 @@ type destinationRuleIndex struct {
exportedByNamespace map[string]*consolidatedDestRules
rootNamespaceLocal *consolidatedDestRules
// mesh/namespace dest rules to be inherited
inheritedByNamespace map[string]*config.Config
inheritedByNamespace map[string]*consolidateDestRule
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: consolidatedDestRule

}

func newDestinationRuleIndex() destinationRuleIndex {
return destinationRuleIndex{
namespaceLocal: map[string]*consolidatedDestRules{},
exportedByNamespace: map[string]*consolidatedDestRules{},
inheritedByNamespace: map[string]*config.Config{},
inheritedByNamespace: map[string]*consolidateDestRule{},
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@@ -252,7 +253,13 @@ type consolidatedDestRules struct {
// Map of dest rule host to the list of namespaces to which this destination rule has been exported to
exportTo map[host.Name]map[visibility.Instance]bool
// Map of dest rule host and the merged destination rules for that host
destRule map[host.Name]*config.Config
destRule map[host.Name]*consolidateDestRule
Copy link
Contributor

Choose a reason for hiding this comment

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

same

}

// consolidateDestRule represents a dr and from which it is consolidated.
type consolidateDestRule struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

consolidatedDestRules already exists. So it would be very confusing to have this struct. I think DestRuleConsolidationSource may be better. If you agree, change sourceRules -> fromRules?

Copy link
Member Author

Choose a reason for hiding this comment

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

consolidatedDestRules is a wrapper of rules from a single namespace. That one is plural.

How about calling from?

Copy link
Contributor

Choose a reason for hiding this comment

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

from makes sense

@ramaraochavali
Copy link
Contributor

Also can you please add a description to the PR?

@hzxuzhonghu
Copy link
Member Author

Make sense, it should include a release note

@hzxuzhonghu hzxuzhonghu requested review from a team as code owners March 28, 2022 08:27
@ramaraochavali
Copy link
Contributor

LGTM will leave it for @howardjohn to take a look

if parent == nil {
return child
}
if child == nil {
return parent
}

parentDR := parent.Spec.(*networking.DestinationRule)
if reflect.DeepEqual(parent.from, child.from) {
Copy link
Member

Choose a reason for hiding this comment

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

can we use a more efficient check for equality?

Especially concerned that this is an ordered list - does order really matter here?

Copy link
Contributor

Choose a reason for hiding this comment

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

#38088 (comment) - that was my concern as well

Copy link
Member Author

Choose a reason for hiding this comment

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

The order is determined, we have sorted all the drs before merge

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 can compare them one by one to improve efficiency

Copy link
Member Author

Choose a reason for hiding this comment

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

But not sure how much it improves, since i can see many places in k8s use reflect.DeepEqual to compare labels.
I have never tested the two ways. Either make sense to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

improved

@hzxuzhonghu
Copy link
Member Author

@howardjohn Can you ptal

@hzxuzhonghu
Copy link
Member Author

/retest

@howardjohn
Copy link
Member

howardjohn commented Apr 1, 2022 via email

@istio-testing istio-testing merged commit 9fcfe23 into istio:master Apr 1, 2022
@hzxuzhonghu
Copy link
Member Author

It influences a little, previously the cds cache can not be right in some merging cases

@hzxuzhonghu hzxuzhonghu deleted the fix-dr-2 branch April 1, 2022 01:15
aryan16 pushed a commit to aryan16/istio that referenced this pull request Apr 8, 2022
aryan16 pushed a commit to aryan16/istio that referenced this pull request Apr 11, 2022
@istio-testing
Copy link
Collaborator

In response to a cherrypick label: #38088 failed to apply on top of branch "release-1.13":

Applying: Fix missing dr dependency when merging
Using index info to reconstruct a base tree...
M	pilot/pkg/model/config.go
M	pilot/pkg/model/destination_rule.go
M	pilot/pkg/model/push_context.go
M	pilot/pkg/model/push_context_test.go
M	pilot/pkg/model/sidecar.go
Falling back to patching base and 3-way merge...
Auto-merging pilot/pkg/model/sidecar.go
CONFLICT (content): Merge conflict in pilot/pkg/model/sidecar.go
Auto-merging pilot/pkg/model/push_context_test.go
CONFLICT (content): Merge conflict in pilot/pkg/model/push_context_test.go
Auto-merging pilot/pkg/model/push_context.go
CONFLICT (content): Merge conflict in pilot/pkg/model/push_context.go
Auto-merging pilot/pkg/model/destination_rule.go
CONFLICT (content): Merge conflict in pilot/pkg/model/destination_rule.go
Auto-merging pilot/pkg/model/config.go
CONFLICT (content): Merge conflict in pilot/pkg/model/config.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix missing dr dependency when merging
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

@istio-testing
Copy link
Collaborator

In response to a cherrypick label: new issue created for failed cherrypick: #39728

@GregHanson
Copy link
Member

@hzxuzhonghu was this issue only present in 1.13? Or does this need to be back ported to 1.14 as well?

@hzxuzhonghu
Copy link
Member Author

Yes, only exists in version <=1.13

@hzxuzhonghu
Copy link
Member Author

Also this should combine with #39730

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes-none Indicates a PR that does not require release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SidecarScope.DependsOnConfig is not correct for DestinationRule
5 participants