Skip to content

Commit 023dc5b

Browse files
committed
feat: add gunicorn_access_logformat field to Api and Content specs
* Pass gunicorn_access_logformat as env var and use in container args * Add gunicorn_access_logformat field to Api and Content specs * Add changelog * Update controller_test.go with new env vars and args * Run `make manifests` and `make bundle` to update CRDs closes #1564
1 parent 6a04fe6 commit 023dc5b

File tree

9 files changed

+73
-3
lines changed

9 files changed

+73
-3
lines changed

CHANGES/1564.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added gunicorn_access_logformat field to customize access log format for api and content pods.

apis/repo-manager.pulpproject.org/v1/pulp_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,11 @@ type Api struct {
435435
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number","urn:alm:descriptor:com.tectonic.ui:advanced"}
436436
GunicornWorkers int `json:"gunicorn_workers,omitempty"`
437437

438+
// For the gunicorn --access-logformat CLI command used to format the access logs.
439+
// +kubebuilder:validation:Optional
440+
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text","urn:alm:descriptor:com.tectonic.ui:advanced"}
441+
GunicornAccessLogformat string `json:"gunicorn_access_logformat,omitempty"`
442+
438443
// Resource requirements for the pulp api container.
439444
// +kubebuilder:validation:Optional
440445
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:resourceRequirements","urn:alm:descriptor:com.tectonic.ui:advanced"}
@@ -531,6 +536,11 @@ type Content struct {
531536
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number","urn:alm:descriptor:com.tectonic.ui:advanced"}
532537
GunicornWorkers int `json:"gunicorn_workers,omitempty"`
533538

539+
// For the gunicorn --access-logformat CLI command used to format the access logs.
540+
// +kubebuilder:validation:Optional
541+
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text","urn:alm:descriptor:com.tectonic.ui:advanced"}
542+
GunicornAccessLogformat string `json:"gunicorn_access_logformat,omitempty"`
543+
534544
// Periodic probe of container service readiness.
535545
// Container will be removed from service endpoints if the probe fails.
536546
// +kubebuilder:validation:Optional

bundle/manifests/pulp-operator.clusterserviceversion.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ metadata:
6464
capabilities: Full Lifecycle
6565
categories: Integration & Delivery
6666
containerImage: quay.io/pulp/pulp-operator:v1.0.0
67-
createdAt: "2025-11-24T09:59:39Z"
67+
createdAt: "2025-12-18T15:04:24Z"
6868
description: Pulp is a platform for managing repositories of software packages
6969
and making them available to a large number of consumers.
7070
metadata.annotations.support: Community
@@ -216,6 +216,13 @@ spec:
216216
path: api.deployment_annotations
217217
x-descriptors:
218218
- urn:alm:descriptor:com.tectonic.ui:hidden
219+
- description: For the gunicorn --access-logformat CLI command used to format
220+
the access logs.
221+
displayName: Gunicorn Access Logformat
222+
path: api.gunicorn_access_logformat
223+
x-descriptors:
224+
- urn:alm:descriptor:com.tectonic.ui:text
225+
- urn:alm:descriptor:com.tectonic.ui:advanced
219226
- description: 'The timeout for the gunicorn process. Default: 90'
220227
displayName: Gunicorn Timeout
221228
path: api.gunicorn_timeout
@@ -425,6 +432,13 @@ spec:
425432
path: content.deployment_annotations
426433
x-descriptors:
427434
- urn:alm:descriptor:com.tectonic.ui:hidden
435+
- description: For the gunicorn --access-logformat CLI command used to format
436+
the access logs.
437+
displayName: Gunicorn Access Logformat
438+
path: content.gunicorn_access_logformat
439+
x-descriptors:
440+
- urn:alm:descriptor:com.tectonic.ui:text
441+
- urn:alm:descriptor:com.tectonic.ui:advanced
428442
- description: 'The timeout for the gunicorn process. Default: 90'
429443
displayName: Gunicorn Timeout
430444
path: content.gunicorn_timeout

bundle/manifests/repo-manager.pulpproject.org_pulps.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,10 @@ spec:
13701370
- name
13711371
type: object
13721372
type: array
1373+
gunicorn_access_logformat:
1374+
description: For the gunicorn --access-logformat CLI command used
1375+
to format the access logs.
1376+
type: string
13731377
gunicorn_timeout:
13741378
description: |-
13751379
The timeout for the gunicorn process.
@@ -4921,6 +4925,10 @@ spec:
49214925
- name
49224926
type: object
49234927
type: array
4928+
gunicorn_access_logformat:
4929+
description: For the gunicorn --access-logformat CLI command used
4930+
to format the access logs.
4931+
type: string
49244932
gunicorn_timeout:
49254933
description: |-
49264934
The timeout for the gunicorn process.

config/crd/bases/repo-manager.pulpproject.org_pulps.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,10 @@ spec:
13701370
- name
13711371
type: object
13721372
type: array
1373+
gunicorn_access_logformat:
1374+
description: For the gunicorn --access-logformat CLI command used
1375+
to format the access logs.
1376+
type: string
13731377
gunicorn_timeout:
13741378
description: |-
13751379
The timeout for the gunicorn process.
@@ -4921,6 +4925,10 @@ spec:
49214925
- name
49224926
type: object
49234927
type: array
4928+
gunicorn_access_logformat:
4929+
description: For the gunicorn --access-logformat CLI command used
4930+
to format the access logs.
4931+
type: string
49244932
gunicorn_timeout:
49254933
description: |-
49264934
The timeout for the gunicorn process.

config/manifests/bases/pulp-operator.clusterserviceversion.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ spec:
226226
path: api.deployment_annotations
227227
x-descriptors:
228228
- urn:alm:descriptor:com.tectonic.ui:hidden
229+
- description: For the gunicorn --access-logformat CLI command used to format
230+
the access logs.
231+
displayName: Gunicorn Access Logformat
232+
path: api.gunicorn_access_logformat
233+
x-descriptors:
234+
- urn:alm:descriptor:com.tectonic.ui:text
235+
- urn:alm:descriptor:com.tectonic.ui:advanced
229236
- description: 'The timeout for the gunicorn process. Default: 90'
230237
displayName: Gunicorn Timeout
231238
path: api.gunicorn_timeout
@@ -435,6 +442,13 @@ spec:
435442
path: content.deployment_annotations
436443
x-descriptors:
437444
- urn:alm:descriptor:com.tectonic.ui:hidden
445+
- description: For the gunicorn --access-logformat CLI command used to format
446+
the access logs.
447+
displayName: Gunicorn Access Logformat
448+
path: content.gunicorn_access_logformat
449+
x-descriptors:
450+
- urn:alm:descriptor:com.tectonic.ui:text
451+
- urn:alm:descriptor:com.tectonic.ui:advanced
438452
- description: 'The timeout for the gunicorn process. Default: 90'
439453
displayName: Gunicorn Timeout
440454
path: content.gunicorn_timeout

controllers/deployment.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,16 @@ func (d *CommonDeployment) setEnvVars(resources any, pulpcoreType settings.Pulpc
268268
gunicornTimeout = "90"
269269
}
270270

271+
// get gunicornAccessLogformat defintion from CR
272+
gunicornAccessLogformat := pulpcoreTypeField.FieldByName("GunicornAccessLogformat").String()
273+
if gunicornAccessLogformat == "" {
274+
gunicornAccessLogformat = `pulp [%({correlation-id}o)s]: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"`
275+
}
276+
271277
gunicornEnvVars := []corev1.EnvVar{
272278
{Name: "PULP_GUNICORN_TIMEOUT", Value: gunicornTimeout},
273279
{Name: "PULP_" + strings.ToUpper(string(pulpcoreType)) + "_WORKERS", Value: gunicornWorkers},
280+
{Name: "PULP_GUNICORN_ACCESS_LOGFORMAT", Value: gunicornAccessLogformat},
274281
}
275282
envVars = append(envVars, gunicornEnvVars...)
276283
}
@@ -992,12 +999,13 @@ func pulpcoreApiContainerArgs(pulp pulpv1.Pulp) []string {
992999
then
9931000
PULP_API_ENTRYPOINT=("pulpcore-api")
9941001
else
995-
PULP_API_ENTRYPOINT=("gunicorn" "pulpcore.app.wsgi:application" "--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\"")
1002+
PULP_API_ENTRYPOINT=("gunicorn" "pulpcore.app.wsgi:application" "--name" "pulp-api")
9961003
fi
9971004
exec "${PULP_API_ENTRYPOINT[@]}" \
9981005
--bind "` + gunicornBindAddress + `" \
9991006
--timeout "${PULP_GUNICORN_TIMEOUT}" \
10001007
--workers "${PULP_API_WORKERS}" \
1008+
--access-logformat "${PULP_GUNICORN_ACCESS_LOGFORMAT}" \
10011009
--access-logfile -`,
10021010
}
10031011
}
@@ -1019,6 +1027,7 @@ exec "${PULP_CONTENT_ENTRYPOINT[@]}" \
10191027
--bind "` + gunicornBindAddress + `" \
10201028
--timeout "${PULP_GUNICORN_TIMEOUT}" \
10211029
--workers "${PULP_CONTENT_WORKERS}" \
1030+
--access-logformat "${PULP_GUNICORN_ACCESS_LOGFORMAT}" \
10221031
--access-logfile -
10231032
`,
10241033
}

controllers/repo_manager/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Api defines desired state of pulpcore-api resources
3434
| topology_spread_constraints | Topology rule(s) for the pods. | []corev1.TopologySpreadConstraint | false |
3535
| gunicorn_timeout | The timeout for the gunicorn process. Default: 90 | int | false |
3636
| gunicorn_workers | The number of gunicorn workers to use for the api. Default: 2 | int | false |
37+
| gunicorn_access_logformat | For the gunicorn --access-logformat CLI command used to format the access logs. | string | false |
3738
| resource_requirements | Resource requirements for the pulp api container. | corev1.ResourceRequirements | false |
3839
| readinessProbe | Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. | *corev1.Probe | false |
3940
| livenessProbe | Periodic probe of container liveness. Container will be restarted if the probe fails. | *corev1.Probe | false |
@@ -85,6 +86,7 @@ Content defines desired state of pulpcore-content resources
8586
| topology_spread_constraints | Topology rule(s) for the pods. | []corev1.TopologySpreadConstraint | false |
8687
| gunicorn_timeout | The timeout for the gunicorn process. Default: 90 | int | false |
8788
| gunicorn_workers | The number of gunicorn workers to use for the api. Default: 2 | int | false |
89+
| gunicorn_access_logformat | For the gunicorn --access-logformat CLI command used to format the access logs. | string | false |
8890
| readinessProbe | Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. | *corev1.Probe | false |
8991
| livenessProbe | Periodic probe of container liveness. Container will be restarted if the probe fails. | *corev1.Probe | false |
9092
| pdb | PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods | *policy.PodDisruptionBudgetSpec | false |

controllers/repo_manager/controller_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ var _ = Describe("Pulp controller", Ordered, func() {
182182
envVarsApi := []corev1.EnvVar{
183183
customEnvVar,
184184
{Name: "PULP_GUNICORN_TIMEOUT", Value: strconv.Itoa(90)},
185+
{Name: "PULP_GUNICORN_ACCESS_LOGFORMAT", Value: `pulp [%({correlation-id}o)s]: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"`},
185186
{Name: "PULP_API_WORKERS", Value: strconv.Itoa(2)},
186187
{Name: "POSTGRES_SERVICE_HOST", Value: PulpName + "-database-svc"},
187188
{Name: "POSTGRES_SERVICE_PORT", Value: "5432"},
@@ -192,6 +193,7 @@ var _ = Describe("Pulp controller", Ordered, func() {
192193
envVarsContent := []corev1.EnvVar{
193194
customEnvVar,
194195
{Name: "PULP_GUNICORN_TIMEOUT", Value: strconv.Itoa(90)},
196+
{Name: "PULP_GUNICORN_ACCESS_LOGFORMAT", Value: `pulp [%({correlation-id}o)s]: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"`},
195197
{Name: "PULP_CONTENT_WORKERS", Value: strconv.Itoa(2)},
196198
{Name: "POSTGRES_SERVICE_HOST", Value: PulpName + "-database-svc"},
197199
{Name: "POSTGRES_SERVICE_PORT", Value: "5432"},
@@ -626,12 +628,13 @@ var _ = Describe("Pulp controller", Ordered, func() {
626628
then
627629
PULP_API_ENTRYPOINT=("pulpcore-api")
628630
else
629-
PULP_API_ENTRYPOINT=("gunicorn" "pulpcore.app.wsgi:application" "--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\"")
631+
PULP_API_ENTRYPOINT=("gunicorn" "pulpcore.app.wsgi:application" "--name" "pulp-api")
630632
fi
631633
exec "${PULP_API_ENTRYPOINT[@]}" \
632634
--bind "[::]:24817" \
633635
--timeout "${PULP_GUNICORN_TIMEOUT}" \
634636
--workers "${PULP_API_WORKERS}" \
637+
--access-logformat "${PULP_GUNICORN_ACCESS_LOGFORMAT}" \
635638
--access-logfile -`,
636639
},
637640
Env: envVarsApi,
@@ -745,6 +748,7 @@ exec "${PULP_CONTENT_ENTRYPOINT[@]}" \
745748
--bind "[::]:24816" \
746749
--timeout "${PULP_GUNICORN_TIMEOUT}" \
747750
--workers "${PULP_CONTENT_WORKERS}" \
751+
--access-logformat "${PULP_GUNICORN_ACCESS_LOGFORMAT}" \
748752
--access-logfile -
749753
`,
750754
},

0 commit comments

Comments
 (0)