Skip to content

Commit 5f68c17

Browse files
committed
feat: implement image cache configuration
Implement a feature flag, a resource which controls the flow. This controls the volume configuration, mounting, etc. Fixes #9767 Signed-off-by: Andrey Smirnov <[email protected]>
1 parent 0ffb218 commit 5f68c17

38 files changed

+1331
-116
lines changed

api/resource/definitions/cri/cri.proto

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ option go_package = "github.com/siderolabs/talos/pkg/machinery/api/resource/defi
66
option java_package = "dev.talos.api.resource.definitions.cri";
77

88
import "google/protobuf/struct.proto";
9+
import "resource/definitions/enums/enums.proto";
10+
11+
// ImageCacheConfigSpec represents the ImageCacheConfig.
12+
message ImageCacheConfigSpec {
13+
talos.resource.definitions.enums.CriImageCacheStatus status = 1;
14+
repeated string roots = 2;
15+
}
916

1017
// SeccompProfileSpec represents the SeccompProfile.
1118
message SeccompProfileSpec {

api/resource/definitions/enums/enums.proto

+8
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,14 @@ enum BlockVolumeType {
396396
VOLUME_TYPE_TMPFS = 2;
397397
}
398398

399+
// CriImageCacheStatus describes image cache status type.
400+
enum CriImageCacheStatus {
401+
IMAGE_CACHE_STATUS_UNKNOWN = 0;
402+
IMAGE_CACHE_STATUS_DISABLED = 1;
403+
IMAGE_CACHE_STATUS_PREPARING = 2;
404+
IMAGE_CACHE_STATUS_READY = 3;
405+
}
406+
399407
// KubespanPeerState is KubeSpan peer current state.
400408
enum KubespanPeerState {
401409
PEER_STATE_UNKNOWN = 0;

go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ require (
8888
github.com/godbus/dbus/v5 v5.1.0
8989
github.com/golang/mock v1.6.0
9090
github.com/google/cadvisor v0.51.0
91+
github.com/google/cel-go v0.22.0
9192
github.com/google/go-containerregistry v0.20.2
9293
github.com/google/go-tpm v0.9.1
9394
github.com/google/nftables v0.2.0
@@ -140,7 +141,7 @@ require (
140141
github.com/siderolabs/gen v0.7.0
141142
github.com/siderolabs/go-api-signature v0.3.6
142143
github.com/siderolabs/go-blockdevice v0.4.8
143-
github.com/siderolabs/go-blockdevice/v2 v2.0.5
144+
github.com/siderolabs/go-blockdevice/v2 v2.0.6
144145
github.com/siderolabs/go-circular v0.2.1
145146
github.com/siderolabs/go-cmd v0.1.3
146147
github.com/siderolabs/go-copy v0.1.0
@@ -160,7 +161,6 @@ require (
160161
github.com/siderolabs/kms-client v0.1.0
161162
github.com/siderolabs/net v0.4.0
162163
github.com/siderolabs/proto-codec v0.1.1
163-
github.com/siderolabs/protoenc v0.2.1 // indirect
164164
github.com/siderolabs/siderolink v0.3.11
165165
github.com/siderolabs/talos/pkg/machinery v1.9.0-alpha.2
166166
github.com/spf13/cobra v1.8.1
@@ -177,7 +177,6 @@ require (
177177
go.etcd.io/etcd/etcdutl/v3 v3.5.17
178178
go.uber.org/zap v1.27.0
179179
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
180-
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
181180
golang.org/x/net v0.31.0
182181
golang.org/x/oauth2 v0.24.0
183182
golang.org/x/sync v0.9.0
@@ -267,7 +266,6 @@ require (
267266
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
268267
github.com/golang/protobuf v1.5.4 // indirect
269268
github.com/google/btree v1.1.2 // indirect
270-
github.com/google/cel-go v0.22.0 // indirect
271269
github.com/google/gnostic-models v0.6.8 // indirect
272270
github.com/google/go-cmp v0.6.0 // indirect
273271
github.com/google/gofuzz v1.2.0 // indirect
@@ -328,6 +326,7 @@ require (
328326
github.com/prometheus/common v0.55.0 // indirect
329327
github.com/rivo/uniseg v0.4.7 // indirect
330328
github.com/russross/blackfriday/v2 v2.1.0 // indirect
329+
github.com/siderolabs/protoenc v0.2.1 // indirect
331330
github.com/siderolabs/tcpproxy v0.1.0 // indirect
332331
github.com/sirupsen/logrus v1.9.3 // indirect
333332
github.com/spf13/afero v1.10.0 // indirect
@@ -353,6 +352,7 @@ require (
353352
go.opentelemetry.io/otel/trace v1.31.0 // indirect
354353
go.uber.org/multierr v1.11.0 // indirect
355354
golang.org/x/crypto v0.29.0 // indirect
355+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
356356
golang.org/x/mod v0.21.0 // indirect
357357
golang.org/x/tools v0.26.0 // indirect
358358
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,8 @@ github.com/siderolabs/go-api-signature v0.3.6 h1:wDIsXbpl7Oa/FXvxB6uz4VL9INA9fmr
648648
github.com/siderolabs/go-api-signature v0.3.6/go.mod h1:hoH13AfunHflxbXfh+NoploqV13ZTDfQ1mQJWNVSW9U=
649649
github.com/siderolabs/go-blockdevice v0.4.8 h1:KfdWvIx0Jft5YVuCsFIJFwjWEF1oqtzkgX9PeU9cX4c=
650650
github.com/siderolabs/go-blockdevice v0.4.8/go.mod h1:4PeOuk71pReJj1JQEXDE7kIIQJPVe8a+HZQa+qjxSEA=
651-
github.com/siderolabs/go-blockdevice/v2 v2.0.5 h1:VLmIdDB/1P30Inrpe94FQAz4WUpByGwun5ZeTekxIQc=
652-
github.com/siderolabs/go-blockdevice/v2 v2.0.5/go.mod h1:74htzCV913UzaLZ4H+NBXkwWlYnBJIq5m/379ZEcu8w=
651+
github.com/siderolabs/go-blockdevice/v2 v2.0.6 h1:/NAy3MbNZhjLWo28asZyS/hmf86PEPDMc9i6wIcgbwI=
652+
github.com/siderolabs/go-blockdevice/v2 v2.0.6/go.mod h1:74htzCV913UzaLZ4H+NBXkwWlYnBJIq5m/379ZEcu8w=
653653
github.com/siderolabs/go-circular v0.2.1 h1:a++iVCn9jyhICX3POQZZX8n72p2h5JGdGU6w1ulmpcA=
654654
github.com/siderolabs/go-circular v0.2.1/go.mod h1:ZDItzVyXK+B/XuqTBV5MtQtSv06VI+oCmWGRnNCATo8=
655655
github.com/siderolabs/go-cmd v0.1.3 h1:JrgZwqhJQeoec3QRON0LK+fv+0y7d0DyY7zsfkO6ciw=

internal/app/machined/pkg/controllers/block/internal/volumes/format.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
// Format establishes a filesystem on a block device.
2424
//
25-
//nolint:gocyclo
25+
//nolint:gocyclo,cyclop
2626
func Format(ctx context.Context, logger *zap.Logger, volumeContext ManagerContext) error {
2727
// lock either the parent device or the device itself
2828
devPath := volumeContext.Status.ParentLocation
@@ -111,6 +111,16 @@ func Format(ctx context.Context, logger *zap.Logger, volumeContext ManagerContex
111111
if err = makefs.XFS(volumeContext.Status.MountLocation, makefsOptions...); err != nil {
112112
return fmt.Errorf("error formatting XFS: %w", err)
113113
}
114+
case block.FilesystemTypeEXT4:
115+
var makefsOptions []makefs.Option
116+
117+
if volumeContext.Cfg.TypedSpec().Provisioning.FilesystemSpec.Label != "" {
118+
makefsOptions = append(makefsOptions, makefs.WithLabel(volumeContext.Cfg.TypedSpec().Provisioning.FilesystemSpec.Label))
119+
}
120+
121+
if err = makefs.Ext4(volumeContext.Status.MountLocation, makefsOptions...); err != nil {
122+
return fmt.Errorf("error formatting ext4: %w", err)
123+
}
114124
default:
115125
return fmt.Errorf("unsupported filesystem type: %s", volumeContext.Cfg.TypedSpec().Provisioning.FilesystemSpec.Type)
116126
}
@@ -148,6 +158,14 @@ func GrowFilesystem(logger *zap.Logger, volumeContext ManagerContext) error {
148158
return fmt.Errorf("error growing XFS: %w", err)
149159
}
150160

161+
return nil
162+
case block.FilesystemTypeEXT4:
163+
logger.Info("growing ext4 filesystem", zap.String("device", volumeContext.Status.MountLocation))
164+
165+
if err := makefs.Ext4Resize(volumeContext.Status.MountLocation); err != nil {
166+
return fmt.Errorf("error growing ext4: %w", err)
167+
}
168+
151169
return nil
152170
default:
153171
return fmt.Errorf("unsupported filesystem type to grow: %s", volumeContext.Cfg.TypedSpec().Provisioning.FilesystemSpec.Type)

internal/app/machined/pkg/controllers/block/volume_config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (ctrl *VolumeConfigController) Run(ctx context.Context, r controller.Runtim
209209

210210
func (ctrl *VolumeConfigController) manageEphemeral(config cfg.Config) func(vc *block.VolumeConfig) error {
211211
return func(vc *block.VolumeConfig) error {
212-
extraVolumeConfig := config.Volumes().ByName(constants.EphemeralPartitionLabel)
212+
extraVolumeConfig, _ := config.Volumes().ByName(constants.EphemeralPartitionLabel)
213213

214214
vc.TypedSpec().Type = block.VolumeTypePartition
215215

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

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5+
// Package cri provides CRI related controllers.
56
package cri

0 commit comments

Comments
 (0)