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

fix concurrent map access in endpoint metadata #44473

Merged
merged 9 commits into from
Apr 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix concurrent map access in endpoint metadata
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
  • Loading branch information
ramaraochavali committed Apr 22, 2023
commit c46458e8910f6a7960b0273aa8f7cb2e52f6ccd1
6 changes: 5 additions & 1 deletion pilot/pkg/model/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,16 @@ func (ep *IstioEndpoint) IsDiscoverableFromProxy(p *Proxy) bool {

// Metadata returns the endpoint metadata used for telemetry purposes.
func (ep *IstioEndpoint) Metadata() *EndpointMetadata {
labels := map[string]string{}
for k, v := range ep.Labels {
labels[k] = v
}
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 deepcopy as needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did n't understand - what else need to be copied apart from labels?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nm, understood what you mean,. Fixed

Copy link
Member

Choose a reason for hiding this comment

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

nit: maps.Clone

actually not really just a nit, it will perform better.

return &EndpointMetadata{
Network: ep.Network,
TLSMode: ep.TLSMode,
WorkloadName: ep.WorkloadName,
Namespace: ep.Namespace,
Labels: ep.Labels,
Labels: labels,
ClusterID: ep.Locality.ClusterID,
}
}
Expand Down