-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Fix dr dependency miss #38088
Conversation
@howardjohn Ready now |
Kindly ping @howardjohn in case you missed it |
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.
some comments
pilot/pkg/model/destination_rule.go
Outdated
@@ -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) |
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.
nit: convertConsolidateDestRule -> convertConsolidatedDestRule
pilot/pkg/model/destination_rule.go
Outdated
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 { |
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.
consolidateDestRule -> consolidatedDestRule
pilot/pkg/model/destination_rule.go
Outdated
if parent == nil { | ||
return child | ||
} | ||
if child == nil { | ||
return parent | ||
} | ||
|
||
parentDR := parent.Spec.(*networking.DestinationRule) | ||
if reflect.DeepEqual(parent.sourceRules, child.sourceRules) { |
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.
Is it possible to avoid reflect.DeepEqual?
pilot/pkg/model/push_context.go
Outdated
@@ -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 |
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.
nit: consolidatedDestRule
pilot/pkg/model/push_context.go
Outdated
} | ||
|
||
func newDestinationRuleIndex() destinationRuleIndex { | ||
return destinationRuleIndex{ | ||
namespaceLocal: map[string]*consolidatedDestRules{}, | ||
exportedByNamespace: map[string]*consolidatedDestRules{}, | ||
inheritedByNamespace: map[string]*config.Config{}, | ||
inheritedByNamespace: map[string]*consolidateDestRule{}, |
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.
same here
pilot/pkg/model/push_context.go
Outdated
@@ -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 |
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.
same
pilot/pkg/model/push_context.go
Outdated
} | ||
|
||
// consolidateDestRule represents a dr and from which it is consolidated. | ||
type consolidateDestRule struct { |
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.
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?
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.
consolidatedDestRules is a wrapper of rules from a single namespace. That one is plural.
How about calling from
?
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.
from makes sense
Also can you please add a description to the PR? |
Make sense, it should include a release note |
LGTM will leave it for @howardjohn to take a look |
pilot/pkg/model/destination_rule.go
Outdated
if parent == nil { | ||
return child | ||
} | ||
if child == nil { | ||
return parent | ||
} | ||
|
||
parentDR := parent.Spec.(*networking.DestinationRule) | ||
if reflect.DeepEqual(parent.from, child.from) { |
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.
can we use a more efficient check for equality?
Especially concerned that this is an ordered list - does order really matter here?
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.
#38088 (comment) - that was my concern as well
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.
The order is determined, we have sorted all the drs before merge
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 can compare them one by one to improve efficiency
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.
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.
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.
improved
@howardjohn Can you ptal |
/retest |
does this impact CDS cache as well?
…On Thu, Mar 31, 2022, 6:03 PM Zhonghu Xu ***@***.***> wrote:
/retest
—
Reply to this email directly, view it on GitHub
<#38088 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEYGXP5JTIJKWML4VAP42DVCZDM7ANCNFSM5RNSVI6Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
It influences a little, previously the cds cache can not be right in some merging cases |
In response to a cherrypick label: #38088 failed to apply on top of branch "release-1.13":
|
In response to a cherrypick label: new issue created for failed cherrypick: #39728 |
@hzxuzhonghu was this issue only present in 1.13? Or does this need to be back ported to 1.14 as well? |
Yes, only exists in version <=1.13 |
Also this should combine with #39730 |
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.