Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/manifestclient/read_roundtripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ func (mrt *manifestRoundTripper) RoundTrip(req *http.Request) (*http.Response, e
}
timeoutDuration = time.Duration(currSeconds) * time.Second
}

// WatchList is unnecessary for the manifest client since we read from disk and performance isn't a concern.
// Returning an error forces the client to fall back to the standard List.
if req.URL.Query().Get("sendInitialEvents") == "true" {
return nil, fmt.Errorf("manifest client does not support WatchList feature")
}

resp := &http.Response{}
resp.StatusCode = http.StatusOK
resp.Status = http.StatusText(resp.StatusCode)
Expand Down
20 changes: 20 additions & 0 deletions pkg/manifestclienttest/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/fs"
"net/http"
"reflect"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -278,6 +279,25 @@ func TestWatchChecks(t *testing.T) {
name string
testFn func(*testing.T, *http.Client)
}{
{
name: "WATCH-send-initial-events-unsupported",
testFn: func(t *testing.T, httpClient *http.Client) {
sendInitialEvents := true
configClient, err := configclient.NewForConfigAndClient(&rest.Config{}, httpClient)
if err != nil {
t.Fatal(err)
}
_, err = configClient.ConfigV1().FeatureGates().Watch(context.TODO(), metav1.ListOptions{
SendInitialEvents: &sendInitialEvents,
})
if err == nil {
t.Fatal("expected WatchList error, got nil")
}
if !strings.Contains(err.Error(), "manifest client does not support WatchList feature") {
t.Fatalf("unexpected error: %v", err)
}
},
},
{
name: "WATCH-from-individual-file-success-server-close",
testFn: func(t *testing.T, httpClient *http.Client) {
Expand Down