From 647589ac0d55bcecb00225f5861e90881eb68b83 Mon Sep 17 00:00:00 2001 From: git-hyagi <45576767+git-hyagi@users.noreply.github.com> Date: Fri, 13 Oct 2023 08:13:14 -0300 Subject: [PATCH] Modify the entrypoint of pulpcore containers closes: #1101 --- CHANGES/1101.misc | 1 + controllers/deployment.go | 47 +++----------------- controllers/repo_manager/controller_test.go | 49 +++------------------ main.go | 2 +- 4 files changed, 15 insertions(+), 84 deletions(-) create mode 100644 CHANGES/1101.misc diff --git a/CHANGES/1101.misc b/CHANGES/1101.misc new file mode 100644 index 000000000..d14fdc050 --- /dev/null +++ b/CHANGES/1101.misc @@ -0,0 +1 @@ +Modified the entrypoint of pulpcore containers. diff --git a/controllers/deployment.go b/controllers/deployment.go index 3356319ba..62ff0e068 100644 --- a/controllers/deployment.go +++ b/controllers/deployment.go @@ -865,22 +865,8 @@ func (d *CommonDeployment) setContainers(pulp repomanagerpulpprojectorgv1beta2.P Name: "api", Image: d.image, ImagePullPolicy: corev1.PullPolicy(pulp.Spec.ImagePullPolicy), - Command: []string{"/bin/sh"}, - Args: []string{ - "-c", - `if which pulpcore-api -then - PULP_API_ENTRYPOINT=("pulpcore-api") -else - PULP_API_ENTRYPOINT=("gunicorn" "pulpcore.app.wsgi:application" "--bind" "[::]:24817" "--name" "pulp-api" "--access-logformat" "pulp [%({correlation-id}o)s]: %(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"") -fi - -exec "${PULP_API_ENTRYPOINT[@]}" \ ---timeout "${PULP_GUNICORN_TIMEOUT}" \ ---workers "${PULP_API_WORKERS}" \ ---access-logfile -`, - }, - Env: d.envVars, + Command: []string{"/usr/bin/pulp-api"}, + Env: d.envVars, Ports: []corev1.ContainerPort{{ ContainerPort: 24817, Protocol: "TCP", @@ -897,24 +883,9 @@ exec "${PULP_API_ENTRYPOINT[@]}" \ Name: "content", Image: d.image, ImagePullPolicy: corev1.PullPolicy(pulp.Spec.ImagePullPolicy), - Command: []string{"/bin/sh"}, - Args: []string{ - "-c", - `if which pulpcore-content -then - PULP_CONTENT_ENTRYPOINT=("pulpcore-content") -else - PULP_CONTENT_ENTRYPOINT=("gunicorn" "pulpcore.content:server" "--worker-class" "aiohttp.GunicornWebWorker" "--name" "pulp-content" "--bind" "[::]:24816") -fi - -exec "${PULP_CONTENT_ENTRYPOINT[@]}" \ ---timeout "${PULP_GUNICORN_TIMEOUT}" \ ---workers "${PULP_CONTENT_WORKERS}" \ ---access-logfile - -`, - }, - Resources: d.resourceRequirements, - Env: d.envVars, + Command: []string{"/usr/bin/pulp-content"}, + Resources: d.resourceRequirements, + Env: d.envVars, Ports: []corev1.ContainerPort{{ ContainerPort: 24816, Protocol: "TCP", @@ -929,13 +900,7 @@ exec "${PULP_CONTENT_ENTRYPOINT[@]}" \ Name: "worker", Image: d.image, ImagePullPolicy: corev1.PullPolicy(pulp.Spec.ImagePullPolicy), - Command: []string{"/bin/sh"}, - Args: []string{ - "-c", - `export PULP_SETTINGS=/etc/pulp/settings.py -export PATH=/usr/local/bin:/usr/bin/ -exec pulpcore-worker`, - }, + Command: []string{"/usr/bin/pulp-worker"}, Env: d.envVars, LivenessProbe: d.livenessProbe, ReadinessProbe: d.readinessProbe, diff --git a/controllers/repo_manager/controller_test.go b/controllers/repo_manager/controller_test.go index eb0820fbf..493404c1d 100644 --- a/controllers/repo_manager/controller_test.go +++ b/controllers/repo_manager/controller_test.go @@ -604,22 +604,8 @@ var _ = Describe("Pulp controller", Ordered, func() { apiContainers := []corev1.Container{{ Name: "api", Image: "quay.io/pulp/pulp-minimal:latest", - Command: []string{"/bin/sh"}, - Args: []string{ - "-c", - `if which pulpcore-api -then - PULP_API_ENTRYPOINT=("pulpcore-api") -else - PULP_API_ENTRYPOINT=("gunicorn" "pulpcore.app.wsgi:application" "--bind" "[::]:24817" "--name" "pulp-api" "--access-logformat" "pulp [%({correlation-id}o)s]: %(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"") -fi - -exec "${PULP_API_ENTRYPOINT[@]}" \ ---timeout "${PULP_GUNICORN_TIMEOUT}" \ ---workers "${PULP_API_WORKERS}" \ ---access-logfile -`, - }, - Env: envVarsApi, + Command: []string{"/usr/bin/pulp-api"}, + Env: envVarsApi, Ports: []corev1.ContainerPort{{ ContainerPort: 24817, Protocol: "TCP", @@ -717,24 +703,9 @@ exec "${PULP_API_ENTRYPOINT[@]}" \ Name: "content", Image: "quay.io/pulp/pulp-minimal:latest", ImagePullPolicy: corev1.PullPolicy("IfNotPresent"), - Command: []string{"/bin/sh"}, - Args: []string{ - "-c", - `if which pulpcore-content -then - PULP_CONTENT_ENTRYPOINT=("pulpcore-content") -else - PULP_CONTENT_ENTRYPOINT=("gunicorn" "pulpcore.content:server" "--worker-class" "aiohttp.GunicornWebWorker" "--name" "pulp-content" "--bind" "[::]:24816") -fi - -exec "${PULP_CONTENT_ENTRYPOINT[@]}" \ ---timeout "${PULP_GUNICORN_TIMEOUT}" \ ---workers "${PULP_CONTENT_WORKERS}" \ ---access-logfile - -`, - }, - Resources: corev1.ResourceRequirements{}, - Env: envVarsContent, + Command: []string{"/usr/bin/pulp-content"}, + Resources: corev1.ResourceRequirements{}, + Env: envVarsContent, Ports: []corev1.ContainerPort{{ ContainerPort: 24816, Protocol: "TCP", @@ -805,14 +776,8 @@ exec "${PULP_CONTENT_ENTRYPOINT[@]}" \ Name: "worker", Image: "quay.io/pulp/pulp-minimal:latest", ImagePullPolicy: corev1.PullPolicy("IfNotPresent"), - Command: []string{"/bin/sh"}, - Args: []string{ - "-c", - `export PULP_SETTINGS=/etc/pulp/settings.py -export PATH=/usr/local/bin:/usr/bin/ -exec pulpcore-worker`, - }, - Env: envVarsWorker, + Command: []string{"/usr/bin/pulp-worker"}, + Env: envVarsWorker, // LivenessProbe: livenessProbe, // ReadinessProbe: readinessProbe, VolumeMounts: volumeMountsWorker, diff --git a/main.go b/main.go index a3280a3fc..8de8c3638 100644 --- a/main.go +++ b/main.go @@ -170,7 +170,7 @@ func main() { os.Exit(1) } - setupLog.Info("pulp-operator version: 1.0.6-beta.2") + setupLog.Info("pulp-operator version: 1.0.7-beta.2") setupLog.Info("starting manager") if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { setupLog.Error(err, "problem running manager")