Skip to content

Commit af91c99

Browse files
committed
chore: update image cache config
Make it nested, so that we can expand easily to support e.g. distributed cache. Signed-off-by: Andrey Smirnov <[email protected]>
1 parent e10e90b commit af91c99

File tree

11 files changed

+110
-14
lines changed

11 files changed

+110
-14
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: Question
4+
url: https://github.com/siderolabs/talos/discussions
5+
about: Ask a question about Talos Linux.
6+
- name: Community
47
url: https://taloscommunity.slack.com
5-
about: Ask a question. Get your invite by visiting https://slack.dev.talos-systems.io.
8+
about: Join the community. Get your invite by visiting https://slack.dev.talos-systems.io.

internal/app/machined/pkg/controllers/cri/image_cache_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (ctrl *ImageCacheConfigController) Run(ctx context.Context, r controller.Ru
119119
}
120120

121121
// image cache is disabled
122-
imageCacheDisabled := cfg == nil || cfg.Config().Machine() == nil || !cfg.Config().Machine().Features().ImageCacheEnabled()
122+
imageCacheDisabled := cfg == nil || cfg.Config().Machine() == nil || !cfg.Config().Machine().Features().ImageCache().LocalEnabled()
123123

124124
var (
125125
status cri.ImageCacheStatus

internal/app/machined/pkg/controllers/cri/image_cache_config_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ func (suite *ImageCacheConfigSuite) TestReconcileFeatureEnabled() {
5151
cfg := config.NewMachineConfig(container.NewV1Alpha1(&v1alpha1.Config{
5252
MachineConfig: &v1alpha1.MachineConfig{
5353
MachineFeatures: &v1alpha1.FeaturesConfig{
54-
ImageCache: pointer.To(true),
54+
ImageCacheSupport: &v1alpha1.ImageCacheConfig{
55+
CacheLocalEnabled: pointer.To(true),
56+
},
5557
},
5658
},
5759
}))
@@ -117,7 +119,9 @@ func (suite *ImageCacheConfigSuite) TestReconcileWithImageCacheVolume() {
117119
v1alpha1Cfg := &v1alpha1.Config{
118120
MachineConfig: &v1alpha1.MachineConfig{
119121
MachineFeatures: &v1alpha1.FeaturesConfig{
120-
ImageCache: pointer.To(true),
122+
ImageCacheSupport: &v1alpha1.ImageCacheConfig{
123+
CacheLocalEnabled: pointer.To(true),
124+
},
121125
},
122126
},
123127
}

internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (r *Runtime) CanApplyImmediate(cfg config.Provider) error {
164164
newConfig.MachineConfig.MachineFeatures.KubernetesTalosAPIAccessConfig = currentConfig.MachineConfig.MachineFeatures.KubernetesTalosAPIAccessConfig
165165
newConfig.MachineConfig.MachineFeatures.KubePrismSupport = currentConfig.MachineConfig.MachineFeatures.KubePrismSupport
166166
newConfig.MachineConfig.MachineFeatures.HostDNSSupport = currentConfig.MachineConfig.MachineFeatures.HostDNSSupport
167-
newConfig.MachineConfig.MachineFeatures.ImageCache = currentConfig.MachineConfig.MachineFeatures.ImageCache
167+
newConfig.MachineConfig.MachineFeatures.ImageCacheSupport = currentConfig.MachineConfig.MachineFeatures.ImageCacheSupport
168168
}
169169
}
170170

pkg/machinery/config/config/machine.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ type Features interface {
448448
DiskQuotaSupportEnabled() bool
449449
HostDNS() HostDNS
450450
KubePrism() KubePrism
451-
ImageCacheEnabled() bool
451+
ImageCache() ImageCache
452452
}
453453

454454
// KubernetesTalosAPIAccess describes the Kubernetes Talos API access features.
@@ -471,6 +471,11 @@ type HostDNS interface {
471471
ResolveMemberNames() bool
472472
}
473473

474+
// ImageCache describes the image cache configuration.
475+
type ImageCache interface {
476+
LocalEnabled() bool
477+
}
478+
474479
// UdevConfig describes configuration for udev.
475480
type UdevConfig interface {
476481
Rules() []string

pkg/machinery/config/schemas/config.schema.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,7 @@
20722072
"x-intellij-html-description": "\u003cp\u003eConfigures host DNS caching resolver.\u003c/p\u003e\n"
20732073
},
20742074
"imageCache": {
2075-
"type": "boolean",
2075+
"$ref": "#/$defs/v1alpha1.ImageCacheConfig",
20762076
"title": "imageCache",
20772077
"description": "Enable Image Cache feature.\n",
20782078
"markdownDescription": "Enable Image Cache feature.",
@@ -2125,6 +2125,19 @@
21252125
"additionalProperties": false,
21262126
"type": "object"
21272127
},
2128+
"v1alpha1.ImageCacheConfig": {
2129+
"properties": {
2130+
"localEnabled": {
2131+
"type": "boolean",
2132+
"title": "localEnabled",
2133+
"description": "Enable local image cache.\n",
2134+
"markdownDescription": "Enable local image cache.",
2135+
"x-intellij-html-description": "\u003cp\u003eEnable local image cache.\u003c/p\u003e\n"
2136+
}
2137+
},
2138+
"additionalProperties": false,
2139+
"type": "object"
2140+
},
21282141
"v1alpha1.InstallConfig": {
21292142
"properties": {
21302143
"disk": {

pkg/machinery/config/types/v1alpha1/v1alpha1_features.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ func (f *FeaturesConfig) KubePrism() config.KubePrism {
5757
return f.KubePrismSupport
5858
}
5959

60-
// ImageCacheEnabled implements config.Features interface.
61-
func (f *FeaturesConfig) ImageCacheEnabled() bool {
62-
return pointer.SafeDeref(f.ImageCache)
60+
// ImageCache implements config.Features interface.
61+
func (f *FeaturesConfig) ImageCache() config.ImageCache {
62+
if f.ImageCacheSupport == nil {
63+
return &ImageCacheConfig{}
64+
}
65+
66+
return f.ImageCacheSupport
6367
}
6468

6569
const defaultKubePrismPort = 7445
@@ -92,3 +96,8 @@ func (h *HostDNSConfig) ForwardKubeDNSToHost() bool {
9296
func (h *HostDNSConfig) ResolveMemberNames() bool {
9397
return pointer.SafeDeref(h.HostDNSResolveMemberNames)
9498
}
99+
100+
// LocalEnabled implements config.ImageCache.
101+
func (i *ImageCacheConfig) LocalEnabled() bool {
102+
return pointer.SafeDeref(i.CacheLocalEnabled)
103+
}

pkg/machinery/config/types/v1alpha1/v1alpha1_types.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ type FeaturesConfig struct {
21692169
HostDNSSupport *HostDNSConfig `yaml:"hostDNS,omitempty"`
21702170
// description: |
21712171
// Enable Image Cache feature.
2172-
ImageCache *bool `yaml:"imageCache,omitempty"`
2172+
ImageCacheSupport *ImageCacheConfig `yaml:"imageCache,omitempty"`
21732173
}
21742174

21752175
// KubePrism describes the configuration for the KubePrism load balancer.
@@ -2182,6 +2182,13 @@ type KubePrism struct {
21822182
ServerPort int `yaml:"port,omitempty"`
21832183
}
21842184

2185+
// ImageCacheConfig describes the configuration for the Image Cache feature.
2186+
type ImageCacheConfig struct {
2187+
// description: |
2188+
// Enable local image cache.
2189+
CacheLocalEnabled *bool `yaml:"localEnabled,omitempty"`
2190+
}
2191+
21852192
// KubernetesTalosAPIAccessConfig describes the configuration for the Talos API access from Kubernetes pods.
21862193
type KubernetesTalosAPIAccessConfig struct {
21872194
// description: |

pkg/machinery/config/types/v1alpha1/v1alpha1_types_doc.go

Lines changed: 27 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/content/v1.9/reference/configuration/v1alpha1/config.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2627,7 +2627,7 @@ kubernetesTalosAPIAccess:
26272627
|`diskQuotaSupport` |bool |<details><summary>Enable XFS project quota support for EPHEMERAL partition and user disks.</summary>Also enables kubelet tracking of ephemeral disk usage in the kubelet via quota.</details> | |
26282628
|`kubePrism` |<a href="#Config.machine.features.kubePrism">KubePrism</a> |<details><summary>KubePrism - local proxy/load balancer on defined port that will distribute</summary>requests to all API servers in the cluster.</details> | |
26292629
|`hostDNS` |<a href="#Config.machine.features.hostDNS">HostDNSConfig</a> |Configures host DNS caching resolver. | |
2630-
|`imageCache` |bool |Enable Image Cache feature. | |
2630+
|`imageCache` |<a href="#Config.machine.features.imageCache">ImageCacheConfig</a> |Enable Image Cache feature. | |
26312631

26322632

26332633

@@ -2698,6 +2698,22 @@ HostDNSConfig describes the configuration for the host DNS resolver.
26982698

26992699

27002700

2701+
#### imageCache {#Config.machine.features.imageCache}
2702+
2703+
ImageCacheConfig describes the configuration for the Image Cache feature.
2704+
2705+
2706+
2707+
2708+
| Field | Type | Description | Value(s) |
2709+
|-------|------|-------------|----------|
2710+
|`localEnabled` |bool |Enable local image cache. | |
2711+
2712+
2713+
2714+
2715+
2716+
27012717

27022718

27032719
### udev {#Config.machine.udev}

0 commit comments

Comments
 (0)