Skip to content

Commit 942df24

Browse files
committed
Allow :ref suffix in additionalLayerStores path for stargz-store to support lazy image pulling
Introduced LayerStorePath type for additionalLayerStores that allows paths ending with :ref (e.g., /var/lib/stargz-store/store:ref), while keeping StorePath unchanged for additionalImageStores and additionalArtifactStores. Fixes: https://issues.redhat.com/browse/OCPBUGS-83492
1 parent 464776f commit 942df24

10 files changed

Lines changed: 105 additions & 25 deletions

machineconfiguration/v1/tests/containerruntimeconfigs.machineconfiguration.openshift.io/AdditionalStorageConfig.yaml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,42 @@ tests:
2626
- path: /mnt/nydus-store
2727
- path: /opt/layer_store-v1.0
2828
29+
- name: Should be able to create ContainerRuntimeConfig with additionalLayerStores using :ref suffix for stargz-store
30+
initial: |
31+
apiVersion: machineconfiguration.openshift.io/v1
32+
kind: ContainerRuntimeConfig
33+
spec:
34+
containerRuntimeConfig:
35+
additionalLayerStores:
36+
- path: /var/lib/stargz-store/store:ref
37+
expected: |
38+
apiVersion: machineconfiguration.openshift.io/v1
39+
kind: ContainerRuntimeConfig
40+
spec:
41+
containerRuntimeConfig:
42+
additionalLayerStores:
43+
- path: /var/lib/stargz-store/store:ref
44+
45+
- name: Should be able to create ContainerRuntimeConfig with mixed additionalLayerStores paths (with and without :ref)
46+
initial: |
47+
apiVersion: machineconfiguration.openshift.io/v1
48+
kind: ContainerRuntimeConfig
49+
spec:
50+
containerRuntimeConfig:
51+
additionalLayerStores:
52+
- path: /var/lib/stargz-store/store:ref
53+
- path: /mnt/nydus-store
54+
- path: /opt/layer-store:ref
55+
expected: |
56+
apiVersion: machineconfiguration.openshift.io/v1
57+
kind: ContainerRuntimeConfig
58+
spec:
59+
containerRuntimeConfig:
60+
additionalLayerStores:
61+
- path: /var/lib/stargz-store/store:ref
62+
- path: /mnt/nydus-store
63+
- path: /opt/layer-store:ref
64+
2965
- name: Should fail if additionalLayerStores path is empty
3066
initial: |
3167
apiVersion: machineconfiguration.openshift.io/v1
@@ -64,7 +100,17 @@ tests:
64100
containerRuntimeConfig:
65101
additionalLayerStores:
66102
- path: /var/lib/stargz@store
67-
expectedError: "path must be absolute and contain only alphanumeric characters, '/', '.', '_', and '-'"
103+
expectedError: "path must be absolute and contain only alphanumeric characters, '/', '.', '_', '-', and optionally end with ':ref'"
104+
105+
- name: Should fail if additionalLayerStores path contains colon with suffix other than :ref
106+
initial: |
107+
apiVersion: machineconfiguration.openshift.io/v1
108+
kind: ContainerRuntimeConfig
109+
spec:
110+
containerRuntimeConfig:
111+
additionalLayerStores:
112+
- path: /var/lib/stargz-store:other
113+
expectedError: "path must be absolute and contain only alphanumeric characters, '/', '.', '_', '-', and optionally end with ':ref'"
68114

69115
- name: Should fail if additionalLayerStores path is too long
70116
initial: |

machineconfiguration/v1/types.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,17 +976,30 @@ const (
976976
// +kubebuilder:validation:XValidation:rule="!self.contains('//')",message="path must not contain consecutive forward slashes"
977977
type StorePath string
978978

979+
// LayerStorePath is an absolute filesystem path used by additional layer store configurations.
980+
// The path must be between 1 and 256 characters long, begin with a forward slash, and only contain
981+
// the characters a-z, A-Z, 0-9, '/', '.', '_', '-', and ':'. The colon is only permitted as part of
982+
// the ':ref' suffix for reference-based layer organization (e.g., stargz-store).
983+
// Consecutive forward slashes are not permitted.
984+
// +kubebuilder:validation:MinLength=1
985+
// +kubebuilder:validation:MaxLength=256
986+
// +kubebuilder:validation:XValidation:rule="self.matches('^/[a-zA-Z0-9/._-]+(:ref)?$')",message="path must be absolute and contain only alphanumeric characters, '/', '.', '_', '-', and optionally end with ':ref'"
987+
// +kubebuilder:validation:XValidation:rule="!self.contains('//')",message="path must not contain consecutive forward slashes"
988+
type LayerStorePath string
989+
979990
// AdditionalLayerStore defines a read-only storage location for Open Container Initiative (OCI) container image layers.
980991
type AdditionalLayerStore struct {
981992
// path specifies the absolute location of the additional layer store.
982993
// The path must exist on the node before configuration is applied.
983994
// When a container image is requested, layers found at this location will be used instead of
984995
// retrieving from the registry.
985996
// The path is required and must be between 1 and 256 characters long, begin with a forward slash,
986-
// and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', and '-'.
997+
// and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', '-', and ':'.
998+
// The colon is only permitted as part of the ':ref' suffix for reference-based layer organization
999+
// (e.g., /var/lib/stargz-store/store:ref for stargz-store).
9871000
// Consecutive forward slashes are not permitted.
9881001
// +required
989-
Path StorePath `json:"path,omitempty"`
1002+
Path LayerStorePath `json:"path,omitempty"`
9901003
}
9911004

9921005
// AdditionalImageStore defines an additional read-only storage location for Open Container Initiative (OCI) images.

machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_containerruntimeconfigs-CustomNoUpgrade.crd.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,18 @@ spec:
163163
When a container image is requested, layers found at this location will be used instead of
164164
retrieving from the registry.
165165
The path is required and must be between 1 and 256 characters long, begin with a forward slash,
166-
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', and '-'.
166+
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', '-', and ':'.
167+
The colon is only permitted as part of the ':ref' suffix for reference-based layer organization
168+
(e.g., /var/lib/stargz-store/store:ref for stargz-store).
167169
Consecutive forward slashes are not permitted.
168170
maxLength: 256
169171
minLength: 1
170172
type: string
171173
x-kubernetes-validations:
172174
- message: path must be absolute and contain only alphanumeric
173-
characters, '/', '.', '_', and '-'
174-
rule: self.matches('^/[a-zA-Z0-9/._-]+$')
175+
characters, '/', '.', '_', '-', and optionally end with
176+
':ref'
177+
rule: self.matches('^/[a-zA-Z0-9/._-]+(:ref)?$')
175178
- message: path must not contain consecutive forward slashes
176179
rule: '!self.contains(''//'')'
177180
required:

machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_containerruntimeconfigs-DevPreviewNoUpgrade.crd.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,18 @@ spec:
163163
When a container image is requested, layers found at this location will be used instead of
164164
retrieving from the registry.
165165
The path is required and must be between 1 and 256 characters long, begin with a forward slash,
166-
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', and '-'.
166+
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', '-', and ':'.
167+
The colon is only permitted as part of the ':ref' suffix for reference-based layer organization
168+
(e.g., /var/lib/stargz-store/store:ref for stargz-store).
167169
Consecutive forward slashes are not permitted.
168170
maxLength: 256
169171
minLength: 1
170172
type: string
171173
x-kubernetes-validations:
172174
- message: path must be absolute and contain only alphanumeric
173-
characters, '/', '.', '_', and '-'
174-
rule: self.matches('^/[a-zA-Z0-9/._-]+$')
175+
characters, '/', '.', '_', '-', and optionally end with
176+
':ref'
177+
rule: self.matches('^/[a-zA-Z0-9/._-]+(:ref)?$')
175178
- message: path must not contain consecutive forward slashes
176179
rule: '!self.contains(''//'')'
177180
required:

machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_containerruntimeconfigs-TechPreviewNoUpgrade.crd.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,18 @@ spec:
163163
When a container image is requested, layers found at this location will be used instead of
164164
retrieving from the registry.
165165
The path is required and must be between 1 and 256 characters long, begin with a forward slash,
166-
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', and '-'.
166+
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', '-', and ':'.
167+
The colon is only permitted as part of the ':ref' suffix for reference-based layer organization
168+
(e.g., /var/lib/stargz-store/store:ref for stargz-store).
167169
Consecutive forward slashes are not permitted.
168170
maxLength: 256
169171
minLength: 1
170172
type: string
171173
x-kubernetes-validations:
172174
- message: path must be absolute and contain only alphanumeric
173-
characters, '/', '.', '_', and '-'
174-
rule: self.matches('^/[a-zA-Z0-9/._-]+$')
175+
characters, '/', '.', '_', '-', and optionally end with
176+
':ref'
177+
rule: self.matches('^/[a-zA-Z0-9/._-]+(:ref)?$')
175178
- message: path must not contain consecutive forward slashes
176179
rule: '!self.contains(''//'')'
177180
required:

machineconfiguration/v1/zz_generated.featuregated-crd-manifests/containerruntimeconfigs.machineconfiguration.openshift.io/AdditionalStorageConfig.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,18 @@ spec:
163163
When a container image is requested, layers found at this location will be used instead of
164164
retrieving from the registry.
165165
The path is required and must be between 1 and 256 characters long, begin with a forward slash,
166-
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', and '-'.
166+
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', '-', and ':'.
167+
The colon is only permitted as part of the ':ref' suffix for reference-based layer organization
168+
(e.g., /var/lib/stargz-store/store:ref for stargz-store).
167169
Consecutive forward slashes are not permitted.
168170
maxLength: 256
169171
minLength: 1
170172
type: string
171173
x-kubernetes-validations:
172174
- message: path must be absolute and contain only alphanumeric
173-
characters, '/', '.', '_', and '-'
174-
rule: self.matches('^/[a-zA-Z0-9/._-]+$')
175+
characters, '/', '.', '_', '-', and optionally end with
176+
':ref'
177+
rule: self.matches('^/[a-zA-Z0-9/._-]+(:ref)?$')
175178
- message: path must not contain consecutive forward slashes
176179
rule: '!self.contains(''//'')'
177180
required:

machineconfiguration/v1/zz_generated.swagger_doc_generated.go

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

payload-manifests/crds/0000_80_machine-config_01_containerruntimeconfigs-CustomNoUpgrade.crd.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,18 @@ spec:
163163
When a container image is requested, layers found at this location will be used instead of
164164
retrieving from the registry.
165165
The path is required and must be between 1 and 256 characters long, begin with a forward slash,
166-
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', and '-'.
166+
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', '-', and ':'.
167+
The colon is only permitted as part of the ':ref' suffix for reference-based layer organization
168+
(e.g., /var/lib/stargz-store/store:ref for stargz-store).
167169
Consecutive forward slashes are not permitted.
168170
maxLength: 256
169171
minLength: 1
170172
type: string
171173
x-kubernetes-validations:
172174
- message: path must be absolute and contain only alphanumeric
173-
characters, '/', '.', '_', and '-'
174-
rule: self.matches('^/[a-zA-Z0-9/._-]+$')
175+
characters, '/', '.', '_', '-', and optionally end with
176+
':ref'
177+
rule: self.matches('^/[a-zA-Z0-9/._-]+(:ref)?$')
175178
- message: path must not contain consecutive forward slashes
176179
rule: '!self.contains(''//'')'
177180
required:

payload-manifests/crds/0000_80_machine-config_01_containerruntimeconfigs-DevPreviewNoUpgrade.crd.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,18 @@ spec:
163163
When a container image is requested, layers found at this location will be used instead of
164164
retrieving from the registry.
165165
The path is required and must be between 1 and 256 characters long, begin with a forward slash,
166-
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', and '-'.
166+
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', '-', and ':'.
167+
The colon is only permitted as part of the ':ref' suffix for reference-based layer organization
168+
(e.g., /var/lib/stargz-store/store:ref for stargz-store).
167169
Consecutive forward slashes are not permitted.
168170
maxLength: 256
169171
minLength: 1
170172
type: string
171173
x-kubernetes-validations:
172174
- message: path must be absolute and contain only alphanumeric
173-
characters, '/', '.', '_', and '-'
174-
rule: self.matches('^/[a-zA-Z0-9/._-]+$')
175+
characters, '/', '.', '_', '-', and optionally end with
176+
':ref'
177+
rule: self.matches('^/[a-zA-Z0-9/._-]+(:ref)?$')
175178
- message: path must not contain consecutive forward slashes
176179
rule: '!self.contains(''//'')'
177180
required:

payload-manifests/crds/0000_80_machine-config_01_containerruntimeconfigs-TechPreviewNoUpgrade.crd.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,18 @@ spec:
163163
When a container image is requested, layers found at this location will be used instead of
164164
retrieving from the registry.
165165
The path is required and must be between 1 and 256 characters long, begin with a forward slash,
166-
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', and '-'.
166+
and only contain the characters a-z, A-Z, 0-9, '/', '.', '_', '-', and ':'.
167+
The colon is only permitted as part of the ':ref' suffix for reference-based layer organization
168+
(e.g., /var/lib/stargz-store/store:ref for stargz-store).
167169
Consecutive forward slashes are not permitted.
168170
maxLength: 256
169171
minLength: 1
170172
type: string
171173
x-kubernetes-validations:
172174
- message: path must be absolute and contain only alphanumeric
173-
characters, '/', '.', '_', and '-'
174-
rule: self.matches('^/[a-zA-Z0-9/._-]+$')
175+
characters, '/', '.', '_', '-', and optionally end with
176+
':ref'
177+
rule: self.matches('^/[a-zA-Z0-9/._-]+(:ref)?$')
175178
- message: path must not contain consecutive forward slashes
176179
rule: '!self.contains(''//'')'
177180
required:

0 commit comments

Comments
 (0)