Skip to content

Commit ffb1e16

Browse files
committed
make image metadata cache size configurable
Signed-off-by: Kent Rancourt <[email protected]>
1 parent cce6b9a commit ffb1e16

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

charts/kargo/templates/controller/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ data:
3333
{{- end }}
3434
ALLOW_IMAGE_TAG_CACHING: {{ quote .Values.controller.imageCache.allowUseCachedTags }}
3535
REQUIRE_IMAGE_TAG_CACHING: {{ quote .Values.controller.imageCache.requireUseCachedTags }}
36+
MAX_IMAGE_CACHE_ENTRIES: {{ .Values.controller.imageCache.maxEntries | quote }}
3637
ARGOCD_INTEGRATION_ENABLED: {{ quote .Values.controller.argocd.integrationEnabled }}
3738
{{- if .Values.controller.argocd.integrationEnabled }}
3839
{{- if .Values.kubeconfigSecrets.argocd }}

charts/kargo/values.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,12 @@ controller:
519519
type: ""
520520

521521
imageCache:
522-
## @param controller.imageCache.allowUseCachedTags ALLOWS container image repository subscriptions to improve performance by opting into more aggressive caching. That option is safe only for cases where it is known with certainty that relevant tags are "immutable" (i.e. the exact images referenced by tags remain constant over time and tags are never "re-used" to point to new/different images). If an operator wishes not to run the risk that users will inappropriately opt into this, this setting can be set to `false` to disallow it. Artifact discovery will FAIL if that policy is violated. Note that this setting does not apply at all to the Digest selection strategy, which always assumes tags are mutable.
522+
## @param controller.imageCache.allowUseCachedTags ALLOWS container image repository subscriptions to improve performance by opting into more aggressive image metadata caching. That option is safe only for cases where it is known with certainty that relevant tags are "immutable" (i.e. the exact images referenced by tags remain constant over time and tags are never "re-used" to point to new/different images). If an operator wishes not to run the risk that users will inappropriately opt into this, this setting can be set to `false` to disallow it. Artifact discovery will FAIL if that policy is violated. Note that this setting does not apply at all to the Digest selection strategy, which always assumes tags are mutable.
523523
allowUseCachedTags: true
524-
## @param controller.imageCache.requireUseCachedTags REQUIRES container images repository subscriptions to improve performance by opting into more aggressive caching. That option is safe only for cases where it is known with certainty that relevant tags are "immutable" (i.e. the exact images referenced by tags remain constant over time and tags are never "re-used" to point to new/different images). If an operator wishes to ensure performance, this setting can be set to `true`. Artifact discovery will FAIL if that policy is violated. Note that this setting does not apply at all to the Digest selection strategy, which always assumes tags are mutable.
524+
## @param controller.imageCache.requireUseCachedTags REQUIRES container images repository subscriptions to improve performance by opting into more aggressive image metadata caching. That option is safe only for cases where it is known with certainty that relevant tags are "immutable" (i.e. the exact images referenced by tags remain constant over time and tags are never "re-used" to point to new/different images). If an operator wishes to ensure performance, this setting can be set to `true`. Artifact discovery will FAIL if that policy is violated. Note that this setting does not apply at all to the Digest selection strategy, which always assumes tags are mutable.
525525
requireUseCachedTags: false
526+
## @param controller.imageCache.maxEntries specifies the maximum number of entries in the internal image metadata cache.
527+
maxEntries: 100000
526528

527529
## All settings relating to the Argo CD control plane this controller might
528530
## integrate with.

pkg/image/cache.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package image
22

3-
import "github.com/akuity/kargo/pkg/cache"
3+
import (
4+
"github.com/akuity/kargo/pkg/cache"
5+
"github.com/akuity/kargo/pkg/os"
6+
"github.com/akuity/kargo/pkg/types"
7+
)
48

59
var imageCache cache.Cache[Image]
610

711
func init() {
812
var err error
9-
imageCache, err = cache.NewInMemoryCache[Image](100000)
13+
imageCache, err = cache.NewInMemoryCache[Image](
14+
types.MustParseInt(os.GetEnv("MAX_IMAGE_CACHE_ENTRIES", "100000")),
15+
)
1016
if err != nil {
1117
panic("failed to initialize image cache: " + err.Error())
1218
}

0 commit comments

Comments
 (0)