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

csds: update client resource cache to keep and dump metadata #4217

Merged
merged 7 commits into from Feb 25, 2021

Conversation

menghanl
Copy link
Contributor

@menghanl menghanl commented Feb 19, 2021

Metadata includs timestamp, status, raw message, error details.
Before, it only keeps parsed resources.

  • Change UnmarshalXXX() functions (e.g. UnmarshalListener() to return metadata)
    • Metadata is not populated yet. Will be done in the next PR.
  • Change NewXXX() functions (e.g. NewListener() to handle the metadata)
  • Add Dump() functions to dump message and metadata

Most of the test changes are boilerplate changes due to the function signature change.
The real tests are in dump_test.go

@menghanl menghanl added this to the 1.37 Release milestone Feb 19, 2021
@menghanl menghanl force-pushed the csds_client_keep_md branch 2 times, most recently from 9e0d14b to 050459b Compare February 19, 2021 00:26
xds/internal/client/client.go Outdated Show resolved Hide resolved
xds/internal/client/client.go Show resolved Hide resolved
@menghanl menghanl assigned easwars and unassigned menghanl Feb 23, 2021
@easwars easwars assigned menghanl and unassigned easwars Feb 24, 2021
@menghanl menghanl force-pushed the csds_client_keep_md branch 2 times, most recently from 3e56155 to 822ff9b Compare February 24, 2021 18:40
…data

Metadata including timestamp, status, raw message, error details.
Before, it only keeps parsed resources.

Metadata is not populated yet. Will be populated in the next PR.
@menghanl menghanl assigned easwars and unassigned menghanl Feb 24, 2021
@easwars easwars assigned menghanl and unassigned easwars Feb 24, 2021
@menghanl menghanl assigned easwars and unassigned menghanl Feb 24, 2021
Copy link
Contributor

@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.

LGTM.
Some minor nits and questions.

}
}

func (c *clientImpl) dump(t ResourceType) (version string, _ map[string]UpdateWithMD) {
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 remove the named parameters here please (for sure in the DumpXxx() methods). It is just going to add one line version string to the var block. The _ map[stringUpdateWithMD in the return parameters is quite distracting.

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

mu sync.Mutex
ldsWatchers map[string]map[*watchInfo]bool
ldsVersion string
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this version field only used in the CSDS response? Can we add a small comment for the same. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, comment added.

Actually, only LDS needs the version 🤷‍♂️
But I added version for the other resources as well.

xds/internal/client/callback.go Show resolved Hide resolved
xds/internal/client/callback.go Show resolved Hide resolved
xds/internal/client/client.go Show resolved Hide resolved
xds/internal/client/client_test.go Show resolved Hide resolved
xds/internal/client/xds.go Show resolved Hide resolved
compareDump(t, client.DumpEDS, nackVersion, wantDump)
}

func compareDump(t *testing.T, dumpFunc func() (string, map[string]UpdateWithMD), wantVersion string, wantDump interface{}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Test helper is a function that performs a setup or teardown task, such as constructing an input message, that does not depend on the code under test. See: go/go-style/decisions#mark-test-helpers

This function should ideally be changed to return an error and let the test handle it.

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

xds/internal/client/client_test.go Show resolved Hide resolved
@easwars easwars assigned menghanl and unassigned easwars Feb 25, 2021
Copy link
Contributor Author

@menghanl menghanl 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 review. All fixed. PTAL.

xds/internal/client/callback.go Show resolved Hide resolved
xds/internal/client/callback.go Show resolved Hide resolved
xds/internal/client/client.go Show resolved Hide resolved
mu sync.Mutex
ldsWatchers map[string]map[*watchInfo]bool
ldsVersion string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, comment added.

Actually, only LDS needs the version 🤷‍♂️
But I added version for the other resources as well.

xds/internal/client/client_test.go Show resolved Hide resolved
xds/internal/client/client_test.go Show resolved Hide resolved
}
}

func (c *clientImpl) dump(t ResourceType) (version string, _ map[string]UpdateWithMD) {
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

xds/internal/client/xds.go Show resolved Hide resolved
@menghanl menghanl assigned easwars and unassigned menghanl Feb 25, 2021
@menghanl menghanl merged commit c8cef76 into grpc:master Feb 25, 2021
@menghanl menghanl deleted the csds_client_keep_md branch February 25, 2021 20:57
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants