Skip to content

Commit 39932d4

Browse files
authored
Reduce user-k8s-client caching (#1778)
* Reduce user-k8s-client caching - When a cluster comes up we can cache the client immediately with missing Flux CRDs, apps/sources won't work. System doesn't recover until the client expires in 30mins - Also add extraEnvVars for users to use that doesn't wipe out default envVars * Fixes missing end * Adds some logging * Fixes userNamespace cache cleanup - Was only every 5mins * main is up to date now
1 parent c8d1ae2 commit 39932d4

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

charts/mccp/templates/clusters-service/deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ spec:
7171
{{- toYaml . | nindent 12 }}
7272
{{- end }}
7373
{{- end }}
74+
{{- if .Values.extraEnvVars }}
75+
{{- with .Values.extraEnvVars }}
76+
{{- toYaml . | nindent 12 }}
77+
{{- end }}
78+
{{- end }}
7479
volumeMounts:
7580
- name: ui-server-volume
7681
mountPath: /html

charts/mccp/values.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ ingress:
120120
# kubernetes.io/ingress.class: nginx
121121
# kubernetes.io/tls-acme: "true"
122122
hosts:
123-
- host: ""
124-
paths:
125-
- path: /
126-
pathType: ImplementationSpecific
123+
- host: ""
124+
paths:
125+
- path: /
126+
pathType: ImplementationSpecific
127127
#
128128
tls: []
129129
# - secretName: chart-example-tls
@@ -135,6 +135,12 @@ envVars:
135135
value: "true"
136136
- name: WEAVE_GITOPS_FEATURE_CLUSTER
137137
value: "true"
138+
- name: WEAVE_GITOPS_USERS_CLIENTS_TTL
139+
value: "30s"
140+
141+
# extraEnvVars is a list of extra environment variables to set on the
142+
# deployment. These are in addition to the envVars above.
143+
extraEnvVars: []
138144

139145
networkPolicy:
140146
enabled: true

cmd/clusters-service/app/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,10 @@ func StartServer(ctx context.Context, log logr.Logger, tempDir string, p Params)
431431

432432
clientsFactory := clustersmngr.CachedClientFactory
433433
if !p.UseK8sCachedClients {
434+
log.Info("Using un-cached clients")
434435
clientsFactory = clustersmngr.ClientFactory
436+
} else {
437+
log.Info("Using cached clients")
435438
}
436439

437440
clustersManager := clustersmngr.NewClustersManager(

pkg/cluster/namespaces/userCache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
const (
1414
cacheTTL = time.Minute
15-
cacheResolutionTime = 5 * time.Minute
15+
cacheResolutionTime = 30 * time.Second
1616
)
1717

1818
type UsersResourcesNamespaces struct {

0 commit comments

Comments
 (0)