Skip to content

Commit

Permalink
Update container entrypoint with new pulp version
Browse files Browse the repository at this point in the history
fixes: pulp#1081
  • Loading branch information
git-hyagi committed Sep 8, 2023
1 parent e8ef354 commit 662e311
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGES/1081.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Modified pulpcore containers entrypoints to support `pulp-minimal:3.33` image.
41 changes: 26 additions & 15 deletions controllers/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,17 @@ func (d *CommonDeployment) setContainers(pulp repomanagerpulpprojectorgv1beta2.P
Command: []string{"/bin/sh"},
Args: []string{
"-c",
`exec gunicorn --bind '[::]:24817' pulpcore.app.wsgi:application --name pulp-api --timeout "${PULP_GUNICORN_TIMEOUT}" --workers "${PULP_API_WORKERS}"`,
`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,
Ports: []corev1.ContainerPort{{
Expand All @@ -899,7 +909,18 @@ func (d *CommonDeployment) setContainers(pulp repomanagerpulpprojectorgv1beta2.P
Command: []string{"/bin/sh"},
Args: []string{
"-c",
`exec gunicorn pulpcore.content:server --name pulp-content --bind '[::]:24816' --worker-class 'aiohttp.GunicornWebWorker' --timeout "${PULP_GUNICORN_TIMEOUT}" --workers "${PULP_CONTENT_WORKERS}" --access-logfile -`,
`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,
Expand All @@ -919,19 +940,9 @@ func (d *CommonDeployment) setContainers(pulp repomanagerpulpprojectorgv1beta2.P
Command: []string{"/bin/sh"},
Args: []string{
"-c",
`NEW_TASKING_SYSTEM=$(python3 -c "from packaging.version import parse; from pulpcore.app.apps import PulpAppConfig; print('yes' if parse(PulpAppConfig.version) >= parse('3.13.0.dev0') else 'no')")
echo $NEW_TASKING_SYSTEM
if [[ "$NEW_TASKING_SYSTEM" == "no" ]]; then
# TODO: Set ${PULP_WORKER_NUMBER} to the Pod Number
# In the meantime, the hostname provides uniqueness.
exec rq worker --url "redis://${REDIS_SERVICE_HOST}:${REDIS_SERVICE_PORT}" -w "pulpcore.tasking.worker.PulpWorker" -c "pulpcore.rqconfig"
else
export DJANGO_SETTINGS_MODULE=pulpcore.app.settings
export PULP_SETTINGS=/etc/pulp/settings.py
export PATH=/usr/local/bin:/usr/bin/
exec pulpcore-worker
fi`,
`export PULP_SETTINGS=/etc/pulp/settings.py
export PATH=/usr/local/bin:/usr/bin/
exec pulpcore-worker`,
},
Env: d.envVars,
LivenessProbe: d.livenessProbe,
Expand Down
41 changes: 26 additions & 15 deletions controllers/repo_manager/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,17 @@ var _ = Describe("Pulp controller", Ordered, func() {
Command: []string{"/bin/sh"},
Args: []string{
"-c",
`exec gunicorn --bind '[::]:24817' pulpcore.app.wsgi:application --name pulp-api --timeout "${PULP_GUNICORN_TIMEOUT}" --workers "${PULP_API_WORKERS}"`,
`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,
Ports: []corev1.ContainerPort{{
Expand Down Expand Up @@ -709,7 +719,18 @@ var _ = Describe("Pulp controller", Ordered, func() {
Command: []string{"/bin/sh"},
Args: []string{
"-c",
`exec gunicorn pulpcore.content:server --name pulp-content --bind '[::]:24816' --worker-class 'aiohttp.GunicornWebWorker' --timeout "${PULP_GUNICORN_TIMEOUT}" --workers "${PULP_CONTENT_WORKERS}" --access-logfile -`,
`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,
Expand Down Expand Up @@ -786,19 +807,9 @@ var _ = Describe("Pulp controller", Ordered, func() {
Command: []string{"/bin/sh"},
Args: []string{
"-c",
`NEW_TASKING_SYSTEM=$(python3 -c "from packaging.version import parse; from pulpcore.app.apps import PulpAppConfig; print('yes' if parse(PulpAppConfig.version) >= parse('3.13.0.dev0') else 'no')")
echo $NEW_TASKING_SYSTEM
if [[ "$NEW_TASKING_SYSTEM" == "no" ]]; then
# TODO: Set ${PULP_WORKER_NUMBER} to the Pod Number
# In the meantime, the hostname provides uniqueness.
exec rq worker --url "redis://${REDIS_SERVICE_HOST}:${REDIS_SERVICE_PORT}" -w "pulpcore.tasking.worker.PulpWorker" -c "pulpcore.rqconfig"
else
export DJANGO_SETTINGS_MODULE=pulpcore.app.settings
export PULP_SETTINGS=/etc/pulp/settings.py
export PATH=/usr/local/bin:/usr/bin/
exec pulpcore-worker
fi`,
`export PULP_SETTINGS=/etc/pulp/settings.py
export PATH=/usr/local/bin:/usr/bin/
exec pulpcore-worker`,
},
Env: envVarsWorker,
// LivenessProbe: livenessProbe,
Expand Down
12 changes: 11 additions & 1 deletion controllers/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ func telemetryConfig(resources any, envVars []corev1.EnvVar, containers []corev1
// when telemetry is enabled we need to modify the entrypoint from container image
containers[0].Command = []string{"/bin/sh", "-c"}
containers[0].Args = []string{
`exec /usr/local/bin/opentelemetry-instrument --service_name pulp-api gunicorn --bind '[::]:24817' pulpcore.app.wsgi:application --name pulp-api --timeout "${PULP_GUNICORN_TIMEOUT}" --workers "${PULP_API_WORKERS}"`,
`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 /usr/local/bin/opentelemetry-instrument --service_name pulp-api "${PULP_API_ENTRYPOINT[@]}" \
--timeout "${PULP_GUNICORN_TIMEOUT}" \
--workers "${PULP_API_WORKERS}" \
--access-logfile -`,
}

// create a volume using the otelconfigmap as source
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func main() {
os.Exit(1)
}

setupLog.Info("pulp-operator version: 1.0.0-beta.2")
setupLog.Info("pulp-operator version: 1.0.1-beta.2")
setupLog.Info("starting manager")
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
setupLog.Error(err, "problem running manager")
Expand Down

0 comments on commit 662e311

Please sign in to comment.