From 39cab1d3169c924dd8b800207f0d74752d5f1393 Mon Sep 17 00:00:00 2001 From: Armel Soro Date: Tue, 27 Feb 2024 15:36:12 +0100 Subject: [PATCH] fix: increase default size of the dynamic-plugins-root volume from 1Gi to 2Gi (#238) * fix: increase default size of the dynamic-plugins-root volume from 1Gi to 2Gi This applies the same fix done in the Helm Chart [1]. As depicted in [2], the init container might fail with insufficient space error: ``` ======= Installing dynamic plugin ./dynamic-plugins/dist/backstage-plugin-scaffolder-backend-module-github-dynamic ==> Grabbing package archive through `npm pack` Traceback (most recent call last): File "/opt/app-root/src/install-dynamic-plugins.py", line 304, in main() File "/opt/app-root/src/install-dynamic-plugins.py", line 230, in main raise InstallException(f'Error while installing plugin \{ package } with \'npm pack\' : ' + completed.stderr.decode('utf-8')) __main__.InstallException: Error while installing plugin /opt/app-root/src/dynamic-plugins/dist/backstage-plugin-scaffolder-backend-module-github-dynamic with 'npm pack' : npm notice npm notice New major version of npm available! 9.8.1 -> 10.4.0 npm notice Changelog: npm notice Run `npm install -g npm@10.4.0` to update! npm notice npm ERR! code ENOSPC npm ERR! syscall open npm ERR! path /dynamic-plugins-root/backstage-plugin-scaffolder-backend-module-github-dynamic-0.2.0-next.3.tgz npm ERR! errno -28 npm ERR! nospc ENOSPC: no space left on device, open '/dynamic-plugins-root/backstage-plugin-scaffolder-backend-module-github-dynamic-0.2.0-next.3.tgz' npm ERR! nospc There appears to be insufficient space on your system to finish. npm ERR! nospc Clear up some disk space and try again. ``` [1] https://github.com/redhat-developer/rhdh-chart/pull/5 [2] https://issues.redhat.com/browse/RHIDP-1332 * Add test --- .../backstage-default-config_v1_configmap.yaml | 2 +- config/manager/default-config/deployment.yaml | 2 +- controllers/backstage_controller_test.go | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/bundle/manifests/backstage-default-config_v1_configmap.yaml b/bundle/manifests/backstage-default-config_v1_configmap.yaml index 1c5bdbf1..f462e9fc 100644 --- a/bundle/manifests/backstage-default-config_v1_configmap.yaml +++ b/bundle/manifests/backstage-default-config_v1_configmap.yaml @@ -180,7 +180,7 @@ data: - ReadWriteOnce resources: requests: - storage: 1Gi + storage: 2Gi name: dynamic-plugins-root - name: dynamic-plugins-npmrc secret: diff --git a/config/manager/default-config/deployment.yaml b/config/manager/default-config/deployment.yaml index 30e495ff..fbe4b05d 100644 --- a/config/manager/default-config/deployment.yaml +++ b/config/manager/default-config/deployment.yaml @@ -21,7 +21,7 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi + storage: 2Gi name: dynamic-plugins-root - name: dynamic-plugins-npmrc secret: diff --git a/controllers/backstage_controller_test.go b/controllers/backstage_controller_test.go index e99c8f6e..f9550cbd 100644 --- a/controllers/backstage_controller_test.go +++ b/controllers/backstage_controller_test.go @@ -26,6 +26,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/pointer" @@ -299,8 +300,17 @@ var _ = Describe("Backstage controller", func() { By("Checking the Volumes in the Backstage Deployment", func() { Expect(found.Spec.Template.Spec.Volumes).To(HaveLen(4)) - _, ok := findVolume(found.Spec.Template.Spec.Volumes, "dynamic-plugins-root") + dpRootVol, ok := findVolume(found.Spec.Template.Spec.Volumes, "dynamic-plugins-root") Expect(ok).To(BeTrue(), "No volume found with name: dynamic-plugins-root") + Expect(dpRootVol.Ephemeral).ShouldNot(BeNil()) + Expect(dpRootVol.Ephemeral.VolumeClaimTemplate).ShouldNot(BeNil()) + storage := dpRootVol.Ephemeral.VolumeClaimTemplate.Spec.Resources.Requests.Storage() + Expect(storage).ShouldNot(BeNil()) + q, pErr := resource.ParseQuantity("1Gi") + Expect(pErr).ShouldNot(HaveOccurred()) + // https://issues.redhat.com/browse/RHIDP-1332: storage size should be > 1Gi + Expect(storage.Cmp(q)).To(Equal(1), + "storage size for dynamic-plugins-root volume is currently %v, but it should be more than %v", storage, q) _, ok = findVolume(found.Spec.Template.Spec.Volumes, "dynamic-plugins-npmrc") Expect(ok).To(BeTrue(), "No volume found with name: dynamic-plugins-npmrc")