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
Conversation
9e0d14b
to
050459b
Compare
3e56155
to
822ff9b
Compare
…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.
822ff9b
to
d3d81ba
Compare
There was a problem hiding this 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.
xds/internal/client/dump.go
Outdated
} | ||
} | ||
|
||
func (c *clientImpl) dump(t ResourceType) (version string, _ map[string]UpdateWithMD) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.go
Outdated
mu sync.Mutex | ||
ldsWatchers map[string]map[*watchInfo]bool | ||
ldsVersion string |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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/dump_test.go
Outdated
compareDump(t, client.DumpEDS, nackVersion, wantDump) | ||
} | ||
|
||
func compareDump(t *testing.T, dumpFunc func() (string, map[string]UpdateWithMD), wantVersion string, wantDump interface{}) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this 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/client.go
Outdated
mu sync.Mutex | ||
ldsWatchers map[string]map[*watchInfo]bool | ||
ldsVersion string |
There was a problem hiding this comment.
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/dump.go
Outdated
} | ||
} | ||
|
||
func (c *clientImpl) dump(t ResourceType) (version string, _ map[string]UpdateWithMD) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Metadata includs timestamp, status, raw message, error details.
Before, it only keeps parsed resources.
UnmarshalXXX()
functions (e.g.UnmarshalListener()
to return metadata)NewXXX()
functions (e.g.NewListener()
to handle the metadata)Dump()
functions to dump message and metadataMost of the test changes are boilerplate changes due to the function signature change.
The real tests are in
dump_test.go