diff --git a/pkg/manifestclient/read_roundtripper.go b/pkg/manifestclient/read_roundtripper.go index bb02906321..8f88473a14 100644 --- a/pkg/manifestclient/read_roundtripper.go +++ b/pkg/manifestclient/read_roundtripper.go @@ -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) diff --git a/pkg/manifestclienttest/client_test.go b/pkg/manifestclienttest/client_test.go index 2b175322ec..bb25e3c290 100644 --- a/pkg/manifestclienttest/client_test.go +++ b/pkg/manifestclienttest/client_test.go @@ -7,6 +7,7 @@ import ( "io/fs" "net/http" "reflect" + "strings" "testing" "time" @@ -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) {