Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pkg/controller/registry/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,22 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name, opmImg, utilImage, img s
}
if grpcPodConfig.ExtractContent.CacheDir != "" {
containerArgs = append(containerArgs, "--cache-dir="+filepath.Join(catalogPath, "cache"))
} else {
// opm serve does not allow us to specify an empty cache directory, which means that it will
// only create new caches in /tmp/, so we need to provide adequate write access there
const tmpdirPath = "/tmp/"
tmpdirVolumeMount := corev1.VolumeMount{
Name: "tmpdir",
MountPath: tmpdirPath,
}
pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{
Name: "tmpdir",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
})

pod.Spec.Containers[0].VolumeMounts = append(pod.Spec.Containers[0].VolumeMounts, tmpdirVolumeMount)
}
pod.Spec.Containers[0].Args = containerArgs
pod.Spec.Containers[0].VolumeMounts = append(pod.Spec.Containers[0].VolumeMounts, contentVolumeMount)
Expand Down
16 changes: 12 additions & 4 deletions pkg/controller/registry/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func TestPodExtractContent(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
GenerateName: "test-",
Namespace: "testns",
Labels: map[string]string{"olm.pod-spec-hash": "5ToGGS7RLuy9Fq91z7IjESOJXfurg09nHAxtfK", "olm.managed": "true"},
Labels: map[string]string{"olm.pod-spec-hash": "7W3t15wWurp7a9W1VVX392SnNYQu3OLbGDJ0wy", "olm.managed": "true"},
Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"},
},
Spec: corev1.PodSpec{
Expand All @@ -419,6 +419,10 @@ func TestPodExtractContent(t *testing.T) {
Name: "catalog-content",
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
},
{
Name: "tmpdir",
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
},
},
InitContainers: []corev1.Container{
{
Expand Down Expand Up @@ -497,7 +501,7 @@ func TestPodExtractContent(t *testing.T) {
},
ImagePullPolicy: image.InferImagePullPolicy("image"),
TerminationMessagePolicy: "FallbackToLogsOnError",
VolumeMounts: []corev1.VolumeMount{{Name: "catalog-content", MountPath: "/extracted-catalog"}},
VolumeMounts: []corev1.VolumeMount{{Name: "tmpdir", MountPath: "/tmp/"}, {Name: "catalog-content", MountPath: "/extracted-catalog"}},
},
},
NodeSelector: map[string]string{"kubernetes.io/os": "linux"},
Expand Down Expand Up @@ -733,7 +737,7 @@ func TestPodExtractContent(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
GenerateName: "test-",
Namespace: "testns",
Labels: map[string]string{"olm.pod-spec-hash": "bhL1lOcUJhtisRddUp8tRQupbIii64C6qz9drn", "olm.managed": "true"},
Labels: map[string]string{"olm.pod-spec-hash": "8ed7duDhuISxUmqWPMZfQu9rc02OOJaOeyT6ML", "olm.managed": "true"},
Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"},
},
Spec: corev1.PodSpec{
Expand All @@ -746,6 +750,10 @@ func TestPodExtractContent(t *testing.T) {
Name: "catalog-content",
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
},
{
Name: "tmpdir",
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
},
},
InitContainers: []corev1.Container{
{
Expand Down Expand Up @@ -830,7 +838,7 @@ func TestPodExtractContent(t *testing.T) {
ReadOnlyRootFilesystem: ptr.To(true),
},
TerminationMessagePolicy: "FallbackToLogsOnError",
VolumeMounts: []corev1.VolumeMount{{Name: "catalog-content", MountPath: "/extracted-catalog"}},
VolumeMounts: []corev1.VolumeMount{{Name: "tmpdir", MountPath: "/tmp/"}, {Name: "catalog-content", MountPath: "/extracted-catalog"}},
},
},
NodeSelector: map[string]string{"kubernetes.io/os": "linux"},
Expand Down