Skip to content

Commit

Permalink
Fix read cache by delegating to uncached client
Browse files Browse the repository at this point in the history
  • Loading branch information
honnix committed Jan 19, 2024
1 parent 2866d5a commit ab70c1d
Showing 1 changed file with 8 additions and 9 deletions.
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 NewCache = func(config *rest.Config, options cache.Options) (cache.Cache, er
}

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
}
// 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},
}

options.Cache.Reader = reader
}

// create the k8s client
Expand All @@ -52,10 +55,6 @@ var NewClient = func(config *rest.Config, options client.Options) (client.Client
}

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

0 comments on commit ab70c1d

Please sign in to comment.