Skip to content

Commit f631348

Browse files
authored
rorfs for cacheless lacks write access to /tmp/ to generate cache (#3640)
* rorfs for cacheless lacks write access to /tmp/ to generate cache Signed-off-by: grokspawn <[email protected]> * review updates Signed-off-by: grokspawn <[email protected]> --------- Signed-off-by: grokspawn <[email protected]>
1 parent 96b249c commit f631348

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

pkg/controller/registry/reconciler/reconciler.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,22 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name, opmImg, utilImage, img s
319319
}
320320
if grpcPodConfig.ExtractContent.CacheDir != "" {
321321
containerArgs = append(containerArgs, "--cache-dir="+filepath.Join(catalogPath, "cache"))
322+
} else {
323+
// opm serve does not allow us to specify an empty cache directory, which means that it will
324+
// only create new caches in /tmp/, so we need to provide adequate write access there
325+
const tmpdirName = "tmpdir"
326+
tmpdirVolumeMount := corev1.VolumeMount{
327+
Name: tmpdirName,
328+
MountPath: "/tmp/",
329+
}
330+
pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{
331+
Name: tmpdirName,
332+
VolumeSource: corev1.VolumeSource{
333+
EmptyDir: &corev1.EmptyDirVolumeSource{},
334+
},
335+
})
336+
337+
pod.Spec.Containers[0].VolumeMounts = append(pod.Spec.Containers[0].VolumeMounts, tmpdirVolumeMount)
322338
}
323339
pod.Spec.Containers[0].Args = containerArgs
324340
pod.Spec.Containers[0].VolumeMounts = append(pod.Spec.Containers[0].VolumeMounts, contentVolumeMount)

pkg/controller/registry/reconciler/reconciler_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ func TestPodExtractContent(t *testing.T) {
406406
ObjectMeta: metav1.ObjectMeta{
407407
GenerateName: "test-",
408408
Namespace: "testns",
409-
Labels: map[string]string{"olm.pod-spec-hash": "5ToGGS7RLuy9Fq91z7IjESOJXfurg09nHAxtfK", "olm.managed": "true"},
409+
Labels: map[string]string{"olm.pod-spec-hash": "7W3t15wWurp7a9W1VVX392SnNYQu3OLbGDJ0wy", "olm.managed": "true"},
410410
Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"},
411411
},
412412
Spec: corev1.PodSpec{
@@ -419,6 +419,10 @@ func TestPodExtractContent(t *testing.T) {
419419
Name: "catalog-content",
420420
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
421421
},
422+
{
423+
Name: "tmpdir",
424+
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
425+
},
422426
},
423427
InitContainers: []corev1.Container{
424428
{
@@ -497,7 +501,7 @@ func TestPodExtractContent(t *testing.T) {
497501
},
498502
ImagePullPolicy: image.InferImagePullPolicy("image"),
499503
TerminationMessagePolicy: "FallbackToLogsOnError",
500-
VolumeMounts: []corev1.VolumeMount{{Name: "catalog-content", MountPath: "/extracted-catalog"}},
504+
VolumeMounts: []corev1.VolumeMount{{Name: "tmpdir", MountPath: "/tmp/"}, {Name: "catalog-content", MountPath: "/extracted-catalog"}},
501505
},
502506
},
503507
NodeSelector: map[string]string{"kubernetes.io/os": "linux"},
@@ -733,7 +737,7 @@ func TestPodExtractContent(t *testing.T) {
733737
ObjectMeta: metav1.ObjectMeta{
734738
GenerateName: "test-",
735739
Namespace: "testns",
736-
Labels: map[string]string{"olm.pod-spec-hash": "bhL1lOcUJhtisRddUp8tRQupbIii64C6qz9drn", "olm.managed": "true"},
740+
Labels: map[string]string{"olm.pod-spec-hash": "8ed7duDhuISxUmqWPMZfQu9rc02OOJaOeyT6ML", "olm.managed": "true"},
737741
Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"},
738742
},
739743
Spec: corev1.PodSpec{
@@ -746,6 +750,10 @@ func TestPodExtractContent(t *testing.T) {
746750
Name: "catalog-content",
747751
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
748752
},
753+
{
754+
Name: "tmpdir",
755+
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
756+
},
749757
},
750758
InitContainers: []corev1.Container{
751759
{
@@ -830,7 +838,7 @@ func TestPodExtractContent(t *testing.T) {
830838
ReadOnlyRootFilesystem: ptr.To(true),
831839
},
832840
TerminationMessagePolicy: "FallbackToLogsOnError",
833-
VolumeMounts: []corev1.VolumeMount{{Name: "catalog-content", MountPath: "/extracted-catalog"}},
841+
VolumeMounts: []corev1.VolumeMount{{Name: "tmpdir", MountPath: "/tmp/"}, {Name: "catalog-content", MountPath: "/extracted-catalog"}},
834842
},
835843
},
836844
NodeSelector: map[string]string{"kubernetes.io/os": "linux"},

0 commit comments

Comments
 (0)