Skip to content

xds: cleanup bootstrap processing functionality #7299

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 4 commits into from
Jun 6, 2024

Conversation

easwars
Copy link
Contributor

@easwars easwars commented Jun 4, 2024

This PR cleans up how to process the bootstrap configuration. This also brings up in line with other languages in the following ways:

  • Do not use a Node proto to unmarshal bootstrap config's node field. Instead only read the supported fields. This is done by defining a struct with only the supported fields, and appropriate json struct tags.
    • This also ensures that we don't read the client_features field from the bootstrap configuration. This is a field which should be completely controlled by the client implementation.

Summary of changes:

  • internal/xds/bootstrap package now exports the following types:
    • ChannelCreds: corresponds to the channel_credentials field in the bootstrap config
    • Authority: corresponds to the authority field in the bootstrap config
      • The above types are very simple, and do not contain custom JSON marshal/unmarshal logic;
      • Therefore, these contain fields that are exported with json struct tags in them. This makes it possible to marshal and unmarshal using json.Marshal and json.Unmarshal;
      • These types do implement an Equal method to ensure that tests can use cmp.Diff or cmp.Equal without any custom cmp opts.
    • ServerConfig: corresponds to the message type within the xds_servers field in the bootstrap config
    • Config: the complete bootstrap configuration
      • The above types contain custom marshal/unmarshal logic. So, they implement MarshalJSON and UnmarshalJSON methods;
      • These types are opaque, i.e fields are not exported, but they do come with getters;
      • They also implement an Equal method for use with cmp.Diff and cmp.Equal.
      • A corresponding unexported type (serverConfigJSON and configJSON) is also defined with exported fields and json struct tags to make it easy to marshal and unamrshal to JSON, instead of the old way, where we marshal to map[string]json.RawMessage and traverse the map, and individually marshal each of the fields.
  • Remove mentions of the xds_v3 server feature. We do not support it any more. See here for when support was removed.
  • Use the passthrough scheme to dial the xDS management server from tests.
    • This is a subtlety arising out of the interaction between grpc.NewClient which defaults to scheme dns, and how some tests override the actual dns resolver with a mock one.

With this change, tests cannot create a ServerConfig or Config struct using literal struct initializations. We have helpers to construct ServerConfig for tests, and we can create Config from JSON for tests. In a follow-up PR, I will move code out of internal/testutils/xds/bootstrap which contains code to create Config for tests using options, and move it into the main bootstrap package. This change will simplify dependencies for tests, and will also help with eventually moving everything out of xds/internal to internal/xds.

#a71-xds-fallback

RELEASE NOTES: none

@easwars easwars requested a review from arvindbr8 June 4, 2024 15:45
@easwars easwars added the Type: Internal Cleanup Refactors, etc label Jun 4, 2024
@easwars easwars added this to the 1.65 Release milestone Jun 4, 2024
Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

Changes looks good to me modulo a few comments

@arvindbr8 arvindbr8 assigned easwars and unassigned arvindbr8 Jun 6, 2024
@arvindbr8 arvindbr8 modified the milestones: 1.65 Release, 1.66 Release Jun 6, 2024
Copy link
Contributor Author

@easwars easwars left a comment

Choose a reason for hiding this comment

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

Thanks for the pass.

@easwars easwars assigned arvindbr8 and unassigned easwars Jun 6, 2024
Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

looks goood to me 👍

@arvindbr8 arvindbr8 assigned easwars and unassigned arvindbr8 Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants