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

resolver/google-c2p: introduce SetUniverseDomain API #7719

Merged
merged 7 commits into from
Oct 21, 2024

Conversation

apolcyn
Copy link
Contributor

@apolcyn apolcyn commented Oct 9, 2024

As title

@dfawley

RELEASE NOTES: none

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.09%. Comparing base (b8ee37d) to head (f24007e).
Report is 16 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7719      +/-   ##
==========================================
+ Coverage   81.84%   82.09%   +0.25%     
==========================================
  Files         361      362       +1     
  Lines       27827    28128     +301     
==========================================
+ Hits        22775    23092     +317     
+ Misses       3850     3841       -9     
+ Partials     1202     1195       -7     
Files with missing lines Coverage Δ
xds/googledirectpath/googlec2p.go 94.28% <100.00%> (+1.83%) ⬆️

... and 29 files with indirect coverage changes

@apolcyn apolcyn marked this pull request as ready for review October 9, 2024 22:18
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

LGTM, mostly just some nits about comments.

Comment on lines +64 to +66
logger = internalgrpclog.NewPrefixLogger(grpclog.Component("directpath"), logPrefix)
universeDomainMu sync.Mutex
universeDomain = ""
Copy link
Member

Choose a reason for hiding this comment

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

Can you move the comment above to onGCE / randInt instead of the whole block, please? It no longer applies to everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 73 to 74
// SetUniverseDomain informs the gRPC library of the TPC universe domain
// in which the process is running. It is the caller's responsibility to
Copy link
Member

Choose a reason for hiding this comment

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

Is there any documentation we can point to about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Asking around, I'll get back to this comment after I hear back

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No documentation currently

Comment on lines 83 to 86
// Arguments:
//
// d: The DNS domain for Google APIs in the current TPC universe
// (for example, "googleapis.com" or "apis-s3ns.fr").
Copy link
Member

Choose a reason for hiding this comment

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

Is this a new Go style thing? I've not seen it before. If not, please follow the normal style of just mentioning it inline. Or I think it can just be removed and d renamed to domain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry this is probably not golang style (this is something my editor suggested). Moved to a more inline comment.

return fmt.Errorf("universe domain cannot be empty")
}
if universeDomain == "" {
universeDomain = d
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to do any paranoid validation in case SetUniverseDomain is called using unsanitized data?

I'm not sure that anything could actually go wrong if we don't (aside from it just not working), though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We perhaps could, but I'm not sure how aggressive we want to be in this check.

Because this is a DNS domain that we're configuring, standard DNS rules should apply:

  1. The entire Traffic Director DNS name cannot exceed 255 characters (https://datatracker.ietf.org/doc/html/rfc1035#section-2.3.4). So we could perhaps do a simple check here that this domain does not exceed 255 characters. We could perhaps also do a more complicated check that each label does not exceed 63 characters.

  2. Each character within a label should be a letter, number, or hyphen (https://datatracker.ietf.org/doc/html/rfc1034#section-3.5)

Asking around to see what other clients are doing here. I'll get back to this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Circling back on this.

In principle it seems very reasonable to add some input validation. And we can probably do it according to those standard DNS rules I mentioned.

However, client libraries are apparently not doing any such input validation here, and I've yet to hear of any actual specific validation that's been agreed upon.

So as for now, I think it's safest to not do any validation beyond the empty string check.

As you mentioned, things are expected to not work if the input is bad. Most likely DNS resolution of the Traffic Director endpoint will fail.

@dfawley dfawley added the Type: Feature New features or improvements in behavior label Oct 14, 2024
@dfawley dfawley added this to the 1.68 Release milestone Oct 14, 2024
@dfawley dfawley changed the title [google-c2p resolver] Introduce SetUniverseDomain API resolver/google-c2p: introduce SetUniverseDomain API Oct 14, 2024
@purnesh42H purnesh42H modified the milestones: 1.68 Release, 1.69 Release Oct 16, 2024
@apolcyn
Copy link
Contributor Author

apolcyn commented Oct 17, 2024

@dfawley PTAL

@purnesh42H purnesh42H added the Area: Resolvers/Balancers Includes LB policy & NR APIs, resolver/balancer/picker wrappers, LB policy impls and utilities. label Oct 21, 2024
@dfawley dfawley merged commit 14e2a20 into grpc:master Oct 21, 2024
15 checks passed
misvivek pushed a commit to misvivek/grpc-go that referenced this pull request Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Resolvers/Balancers Includes LB policy & NR APIs, resolver/balancer/picker wrappers, LB policy impls and utilities. Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants