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

Fix read cache by delegating to uncached client #4748

Closed
wants to merge 1 commit into from
Closed
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
17 changes: 8 additions & 9 deletions flytepropeller/pkg/controller/executors/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@
}

var NewClient = func(config *rest.Config, options client.Options) (client.Client, error) {
var reader *fallbackClientReader
if options.Cache != nil && options.Cache.Reader != nil {
uncachedOptions := options
uncachedOptions.Cache = nil
uncachedK8sClient, err := client.New(config, uncachedOptions)
if err != nil {
return nil, err
}

Check warning on line 43 in flytepropeller/pkg/controller/executors/kube.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/executors/kube.go#L38-L43

Added lines #L38 - L43 were not covered by tests
// if caching is enabled we create a fallback reader so we can attempt the client if the cache
// reader does not have the object
reader = &fallbackClientReader{
orderedClients: []client.Reader{options.Cache.Reader},
options.Cache.Reader = fallbackClientReader{
orderedClients: []client.Reader{options.Cache.Reader, uncachedK8sClient},

Check warning on line 47 in flytepropeller/pkg/controller/executors/kube.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/executors/kube.go#L46-L47

Added lines #L46 - L47 were not covered by tests
}

options.Cache.Reader = reader
}

// create the k8s client
Expand All @@ -52,10 +55,6 @@
}

k8sOtelClient := otelutils.WrapK8sClient(k8sClient)
if reader != nil {
// once the k8s client is created we set the fallback reader's client to the k8s client
reader.orderedClients = append(reader.orderedClients, k8sOtelClient)
}

return k8sOtelClient, nil
}
Expand Down
Loading