Skip to content

Conversation

@eshitachandwani
Copy link
Member

This is part of A74 implementation which add CDS/EDS/DNS watchers to the dependency manager. It also adds a temporary flag that is disabled by default so that it is not used in the current RPC paths , but enabled in the dependency manager tests.

RELEASE NOTES: None

@eshitachandwani eshitachandwani added this to the 1.78 Release milestone Dec 4, 2025
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 77.00348% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.32%. Comparing base (4c27cc8) to head (4b86074).
⚠️ Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
internal/xds/xdsdepmgr/xds_dependency_manager.go 80.41% 31 Missing and 16 partials ⚠️
internal/xds/xdsdepmgr/watch_service.go 59.57% 16 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8744      +/-   ##
==========================================
+ Coverage   83.28%   83.32%   +0.04%     
==========================================
  Files         418      418              
  Lines       32367    32663     +296     
==========================================
+ Hits        26958    27218     +260     
- Misses       4034     4061      +27     
- Partials     1375     1384       +9     
Files with missing lines Coverage Δ
internal/xds/xdsdepmgr/watch_service.go 69.33% <59.57%> (-16.39%) ⬇️
internal/xds/xdsdepmgr/xds_dependency_manager.go 81.89% <80.41%> (-3.01%) ⬇️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines 535 to 536
// We want to stop using this cluster as we received a resource error so
// remove the last update.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Only onListenerResourceAmbientError and onRouteConfigResourceAmbientError currently have docstrings. A comment like this makes more sense to be part of the docstring (for all watchers). But as they will be repeated for all watchers, please keep it short and sweet.

}
}

type clusterWatcher struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it that the listener and route watchers store the cancel func inside themselves, while the cluster and endpoints watchers don't?

Copy link
Contributor

Choose a reason for hiding this comment

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

And a result of this difference the LDS/RDS watchers have a stop method, while the CDS/EDS watchers don't.

}

m.clustersFromRouteConfig = newClusters
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we not create new cluster watchers from here since we know the list of clusters at this point?

}
}

func (m *DependencyManager) populateClusterConfigLocked(name string, depth int, clusterMap map[string]*xdsresource.ClusterResult, edsSeen, dnsSeen, clusterSeen map[string]bool) (bool, []string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method accepts a bunch of arguments, returns a bunch of values, and has complex logic in it. This needs to have a good docstring to help the reader.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, can we have better variable names for the arguments.

  • s/name/clusterName
  • What does clusterMap really represent? This needs a more descriptive name.
  • s/clusterSeen/clustersSeen etc

@easwars
Copy link
Contributor

easwars commented Dec 11, 2025

Can you also please check the codecov report here: #8744 (comment) to see if there are any valid lines that are missing test coverage. Thanks.

}
}

func (m *DependencyManager) populateClusterConfigLocked(name string, depth int, clusterMap map[string]*xdsresource.ClusterResult, edsSeen, dnsSeen, clusterSeen map[string]bool) (bool, []string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, can we have better variable names for the arguments.

  • s/name/clusterName
  • What does clusterMap really represent? This needs a more descriptive name.
  • s/clusterSeen/clustersSeen etc

return false, nil, nil
}

state := m.clusterWatchers[name]
Copy link
Contributor

Choose a reason for hiding this comment

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

You could avoid another map lookup by doing

state, ok := m.clusterWatchers[name]; 
if !ok { ... }

Comment on lines +244 to +261
// If update is not yet received for this cluster, return.
if state.lastUpdate == nil && state.lastErr == nil {
return false, nil, nil
}

// If resource error is seen for this cluster, save it in the cluster map
// and return.
if state.lastUpdate == nil && state.lastErr != nil {
clusterMap[name] = &xdsresource.ClusterResult{Err: state.lastErr}
return true, nil, nil
}

update := state.lastUpdate
clusterMap[name] = &xdsresource.ClusterResult{
Config: xdsresource.ClusterConfig{
Cluster: update,
},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be changed to a switch because it looks like all of this is handling different cases for an update/error being already present.

Comment on lines +265 to +270
var edsName string
if update.EDSServiceName == "" {
edsName = name
} else {
edsName = update.EDSServiceName
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be shortened as follows:

	edsName := clusterName
	if update.EDSServiceName != "" {
		edsName = update.EDSServiceName
	}

}

func (dr *dnsResolver) NewAddress(addresses []resolver.Address) {
dr.UpdateState(resolver.State{Addresses: addresses})
Copy link
Contributor

Choose a reason for hiding this comment

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

We know for a fact that our DNS resolver implementation does not call NewAddresses. Should we panic here instead?

}

func (dr *dnsResolver) ParseServiceConfig(string) *serviceconfig.ParseResult {
return &serviceconfig.ParseResult{Err: fmt.Errorf("service config not supported")}
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that this is existing behavior, but do you happen to know if this is what other languages do as well?


// dnsResolverState watches updates for the given DNS hostname. It implements
// resolver.ClientConn interface to work with the DNS resolver.
type dnsResolver struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make an interface that both the endpointsWatcher and the dnsWatcher can satisfy, so that the dependency manager can treat them as equals?

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