-
Notifications
You must be signed in to change notification settings - Fork 515
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
[#583][Sotw] Ensure resources are properly sent again if envoy unsubscribes then subscribes again to a resource #585
Draft
valerian-roche
wants to merge
6
commits into
envoyproxy:main
Choose a base branch
from
valerian-roche:vr/sotw-subscribe
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a36df79
Rework Cache interface to isolate it from streamState and make it mor…
valerian-roche af7a06d
Fix unittest update wrongly inverted an assert
valerian-roche 4e00420
[#583][Sotw] Ensure resources are properly sent again if envoy unsubs…
valerian-roche 42d626f
Synchronize test helper to pass race detection
valerian-roche fe06bc1
Fix linting errors
valerian-roche 408400c
Ensure we don't create a race between cache and server in sotw. Move …
valerian-roche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ import ( | |
"google.golang.org/protobuf/types/known/durationpb" | ||
|
||
"github.com/envoyproxy/go-control-plane/pkg/cache/types" | ||
"github.com/envoyproxy/go-control-plane/pkg/server/stream/v3" | ||
|
||
discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" | ||
) | ||
|
@@ -37,6 +36,27 @@ type Request = discovery.DiscoveryRequest | |
// DeltaRequest is an alias for the delta discovery request type. | ||
type DeltaRequest = discovery.DeltaDiscoveryRequest | ||
|
||
// ClientState provides additional data on the client knowledge for the type matching the request | ||
// This allows proper implementation of stateful aspects of the protocol (e.g. returning only some updated resources) | ||
// Though the methods may return mutable parts of the state for performance reasons, | ||
// the cache is expected to consider this state as immutable and thread safe between a watch creation and its cancellation | ||
type ClientState interface { | ||
// GetKnownResources returns the list of resources the clients has ACKed and their associated version. | ||
// The versions are: | ||
// - delta protocol: version of the specific resource set in the response | ||
// - sotw protocol: version of the global response when the resource was last ACKed | ||
GetKnownResources() map[string]string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to this name. I have not pushed this branch yet, but I updated #584 |
||
|
||
// GetSubscribedResources returns the list of resources currently subscribed to by the client for the type. | ||
// For delta it keeps track across requests | ||
// For sotw it is a normalized view of the request resources | ||
GetSubscribedResources() map[string]struct{} | ||
|
||
// IsWildcard returns whether the client has a wildcard watch. | ||
// This considers subtilities related to the current migration of wildcard definition within the protocol. | ||
IsWildcard() bool | ||
} | ||
|
||
// ConfigWatcher requests watches for configuration resources by a node, last | ||
// applied version identifier, and resource names hint. The watch should send | ||
// the responses when they are ready. The watch can be canceled by the | ||
|
@@ -50,7 +70,7 @@ type ConfigWatcher interface { | |
// | ||
// Cancel is an optional function to release resources in the producer. If | ||
// provided, the consumer may call this function multiple times. | ||
CreateWatch(*Request, stream.StreamState, chan Response) (cancel func()) | ||
CreateWatch(*Request, ClientState, chan Response) (cancel func()) | ||
|
||
// CreateDeltaWatch returns a new open incremental xDS watch. | ||
// | ||
|
@@ -59,7 +79,7 @@ type ConfigWatcher interface { | |
// | ||
// Cancel is an optional function to release resources in the producer. If | ||
// provided, the consumer may call this function multiple times. | ||
CreateDeltaWatch(*DeltaRequest, stream.StreamState, chan DeltaResponse) (cancel func()) | ||
CreateDeltaWatch(*DeltaRequest, ClientState, chan DeltaResponse) (cancel func()) | ||
} | ||
|
||
// ConfigFetcher fetches configuration resources from cache | ||
|
@@ -85,6 +105,9 @@ type Response interface { | |
// Get the version in the Response. | ||
GetVersion() (string, error) | ||
|
||
// Get the list of resources part of the response without having to cast resources | ||
GetResourceNames() []string | ||
|
||
// Get the context provided during response creation. | ||
GetContext() context.Context | ||
} | ||
|
@@ -122,6 +145,9 @@ type RawResponse struct { | |
// Resources to be included in the response. | ||
Resources []types.ResourceWithTTL | ||
|
||
// Names of the resources included in the response | ||
ResourceNames []string | ||
|
||
// Whether this is a heartbeat response. For xDS versions that support TTL, this | ||
// will be converted into a response that doesn't contain the actual resource protobuf. | ||
// This allows for more lightweight updates that server only to update the TTL timer. | ||
|
@@ -171,6 +197,9 @@ type PassthroughResponse struct { | |
// The discovery response that needs to be sent as is, without any marshaling transformations. | ||
DiscoveryResponse *discovery.DiscoveryResponse | ||
|
||
// Names of the resources set in the response | ||
ResourceNames []string | ||
|
||
ctx context.Context | ||
} | ||
|
||
|
@@ -268,6 +297,12 @@ func (r *RawDeltaResponse) GetDeltaDiscoveryResponse() (*discovery.DeltaDiscover | |
return marshaledResponse.(*discovery.DeltaDiscoveryResponse), nil | ||
} | ||
|
||
// GetResourceNames returns the list of resources returned within the response | ||
// without having to decode the resources | ||
func (r *RawResponse) GetResourceNames() []string { | ||
return r.ResourceNames | ||
} | ||
|
||
// GetRequest returns the original Discovery Request. | ||
func (r *RawResponse) GetRequest() *discovery.DiscoveryRequest { | ||
return r.Request | ||
|
@@ -330,6 +365,11 @@ func (r *PassthroughResponse) GetDiscoveryResponse() (*discovery.DiscoveryRespon | |
return r.DiscoveryResponse, nil | ||
} | ||
|
||
// GetResourceNames returns the list of resources included within the response | ||
func (r *PassthroughResponse) GetResourceNames() []string { | ||
return r.ResourceNames | ||
} | ||
|
||
// GetDeltaDiscoveryResponse returns the final passthrough Delta Discovery Response. | ||
func (r *DeltaPassthroughResponse) GetDeltaDiscoveryResponse() (*discovery.DeltaDiscoveryResponse, error) { | ||
return r.DeltaDiscoveryResponse, nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this comment would benefit from emphasizing that this state is per resource type.
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.
Updated on parent PR #584, not yet rebased on this branch