Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGES/1564.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added gunicorn_access_logformat field to customize access log format for api and content pods.
10 changes: 10 additions & 0 deletions apis/repo-manager.pulpproject.org/v1/pulp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ type Api struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number","urn:alm:descriptor:com.tectonic.ui:advanced"}
GunicornWorkers int `json:"gunicorn_workers,omitempty"`

// For the gunicorn --access-logformat CLI command used to format the access logs.
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text","urn:alm:descriptor:com.tectonic.ui:advanced"}
GunicornAccessLogformat string `json:"gunicorn_access_logformat,omitempty"`

// Resource requirements for the pulp api container.
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:resourceRequirements","urn:alm:descriptor:com.tectonic.ui:advanced"}
Expand Down Expand Up @@ -531,6 +536,11 @@ type Content struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number","urn:alm:descriptor:com.tectonic.ui:advanced"}
GunicornWorkers int `json:"gunicorn_workers,omitempty"`

// For the gunicorn --access-logformat CLI command used to format the access logs.
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text","urn:alm:descriptor:com.tectonic.ui:advanced"}
GunicornAccessLogformat string `json:"gunicorn_access_logformat,omitempty"`

// Periodic probe of container service readiness.
// Container will be removed from service endpoints if the probe fails.
// +kubebuilder:validation:Optional
Expand Down
14 changes: 14 additions & 0 deletions bundle/manifests/pulp-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ spec:
path: api.deployment_annotations
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:hidden
- description: For the gunicorn --access-logformat CLI command used to format
the access logs.
displayName: Gunicorn Access Logformat
path: api.gunicorn_access_logformat
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: 'The timeout for the gunicorn process. Default: 90'
displayName: Gunicorn Timeout
path: api.gunicorn_timeout
Expand Down Expand Up @@ -425,6 +432,13 @@ spec:
path: content.deployment_annotations
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:hidden
- description: For the gunicorn --access-logformat CLI command used to format
the access logs.
displayName: Gunicorn Access Logformat
path: content.gunicorn_access_logformat
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: 'The timeout for the gunicorn process. Default: 90'
displayName: Gunicorn Timeout
path: content.gunicorn_timeout
Expand Down
8 changes: 8 additions & 0 deletions bundle/manifests/repo-manager.pulpproject.org_pulps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,10 @@ spec:
- name
type: object
type: array
gunicorn_access_logformat:
description: For the gunicorn --access-logformat CLI command used
to format the access logs.
type: string
gunicorn_timeout:
description: |-
The timeout for the gunicorn process.
Expand Down Expand Up @@ -4921,6 +4925,10 @@ spec:
- name
type: object
type: array
gunicorn_access_logformat:
description: For the gunicorn --access-logformat CLI command used
to format the access logs.
type: string
gunicorn_timeout:
description: |-
The timeout for the gunicorn process.
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/repo-manager.pulpproject.org_pulps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,10 @@ spec:
- name
type: object
type: array
gunicorn_access_logformat:
description: For the gunicorn --access-logformat CLI command used
to format the access logs.
type: string
gunicorn_timeout:
description: |-
The timeout for the gunicorn process.
Expand Down Expand Up @@ -4921,6 +4925,10 @@ spec:
- name
type: object
type: array
gunicorn_access_logformat:
description: For the gunicorn --access-logformat CLI command used
to format the access logs.
type: string
gunicorn_timeout:
description: |-
The timeout for the gunicorn process.
Expand Down
14 changes: 14 additions & 0 deletions config/manifests/bases/pulp-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ spec:
path: api.deployment_annotations
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:hidden
- description: For the gunicorn --access-logformat CLI command used to format
the access logs.
displayName: Gunicorn Access Logformat
path: api.gunicorn_access_logformat
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: 'The timeout for the gunicorn process. Default: 90'
displayName: Gunicorn Timeout
path: api.gunicorn_timeout
Expand Down Expand Up @@ -435,6 +442,13 @@ spec:
path: content.deployment_annotations
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:hidden
- description: For the gunicorn --access-logformat CLI command used to format
the access logs.
displayName: Gunicorn Access Logformat
path: content.gunicorn_access_logformat
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: 'The timeout for the gunicorn process. Default: 90'
displayName: Gunicorn Timeout
path: content.gunicorn_timeout
Expand Down
11 changes: 10 additions & 1 deletion controllers/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,16 @@ func (d *CommonDeployment) setEnvVars(resources any, pulpcoreType settings.Pulpc
gunicornTimeout = "90"
}

// get gunicornAccessLogformat defintion from CR
gunicornAccessLogformat := pulpcoreTypeField.FieldByName("GunicornAccessLogformat").String()
if gunicornAccessLogformat == "" {
gunicornAccessLogformat = `pulp [%({correlation-id}o)s]: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"`
}

gunicornEnvVars := []corev1.EnvVar{
{Name: "PULP_GUNICORN_TIMEOUT", Value: gunicornTimeout},
{Name: "PULP_" + strings.ToUpper(string(pulpcoreType)) + "_WORKERS", Value: gunicornWorkers},
{Name: "PULP_GUNICORN_ACCESS_LOGFORMAT", Value: gunicornAccessLogformat},
}
envVars = append(envVars, gunicornEnvVars...)
}
Expand Down Expand Up @@ -992,12 +999,13 @@ func pulpcoreApiContainerArgs(pulp pulpv1.Pulp) []string {
then
PULP_API_ENTRYPOINT=("pulpcore-api")
else
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\"")
PULP_API_ENTRYPOINT=("gunicorn" "pulpcore.app.wsgi:application" "--name" "pulp-api")
fi
exec "${PULP_API_ENTRYPOINT[@]}" \
--bind "` + gunicornBindAddress + `" \
--timeout "${PULP_GUNICORN_TIMEOUT}" \
--workers "${PULP_API_WORKERS}" \
--access-logformat "${PULP_GUNICORN_ACCESS_LOGFORMAT}" \
--access-logfile -`,
}
}
Expand All @@ -1019,6 +1027,7 @@ exec "${PULP_CONTENT_ENTRYPOINT[@]}" \
--bind "` + gunicornBindAddress + `" \
--timeout "${PULP_GUNICORN_TIMEOUT}" \
--workers "${PULP_CONTENT_WORKERS}" \
--access-logformat "${PULP_GUNICORN_ACCESS_LOGFORMAT}" \
--access-logfile -
`,
}
Expand Down
2 changes: 2 additions & 0 deletions controllers/repo_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Api defines desired state of pulpcore-api resources
| topology_spread_constraints | Topology rule(s) for the pods. | []corev1.TopologySpreadConstraint | false |
| gunicorn_timeout | The timeout for the gunicorn process. Default: 90 | int | false |
| gunicorn_workers | The number of gunicorn workers to use for the api. Default: 2 | int | false |
| gunicorn_access_logformat | For the gunicorn --access-logformat CLI command used to format the access logs. | string | false |
| resource_requirements | Resource requirements for the pulp api container. | corev1.ResourceRequirements | false |
| readinessProbe | Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. | *corev1.Probe | false |
| livenessProbe | Periodic probe of container liveness. Container will be restarted if the probe fails. | *corev1.Probe | false |
Expand Down Expand Up @@ -85,6 +86,7 @@ Content defines desired state of pulpcore-content resources
| topology_spread_constraints | Topology rule(s) for the pods. | []corev1.TopologySpreadConstraint | false |
| gunicorn_timeout | The timeout for the gunicorn process. Default: 90 | int | false |
| gunicorn_workers | The number of gunicorn workers to use for the api. Default: 2 | int | false |
| gunicorn_access_logformat | For the gunicorn --access-logformat CLI command used to format the access logs. | string | false |
| readinessProbe | Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. | *corev1.Probe | false |
| livenessProbe | Periodic probe of container liveness. Container will be restarted if the probe fails. | *corev1.Probe | false |
| pdb | PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods | *policy.PodDisruptionBudgetSpec | false |
Expand Down
6 changes: 5 additions & 1 deletion controllers/repo_manager/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ var _ = Describe("Pulp controller", Ordered, func() {
customEnvVar,
{Name: "PULP_GUNICORN_TIMEOUT", Value: strconv.Itoa(90)},
{Name: "PULP_API_WORKERS", Value: strconv.Itoa(2)},
{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"`},
{Name: "POSTGRES_SERVICE_HOST", Value: PulpName + "-database-svc"},
{Name: "POSTGRES_SERVICE_PORT", Value: "5432"},
{Name: "REDIS_SERVICE_HOST", Value: PulpName + "-redis-svc." + PulpNamespace},
Expand All @@ -193,6 +194,7 @@ var _ = Describe("Pulp controller", Ordered, func() {
customEnvVar,
{Name: "PULP_GUNICORN_TIMEOUT", Value: strconv.Itoa(90)},
{Name: "PULP_CONTENT_WORKERS", Value: strconv.Itoa(2)},
{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"`},
{Name: "POSTGRES_SERVICE_HOST", Value: PulpName + "-database-svc"},
{Name: "POSTGRES_SERVICE_PORT", Value: "5432"},
{Name: "REDIS_SERVICE_HOST", Value: PulpName + "-redis-svc." + PulpNamespace},
Expand Down Expand Up @@ -626,12 +628,13 @@ var _ = Describe("Pulp controller", Ordered, func() {
then
PULP_API_ENTRYPOINT=("pulpcore-api")
else
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\"")
PULP_API_ENTRYPOINT=("gunicorn" "pulpcore.app.wsgi:application" "--name" "pulp-api")
fi
exec "${PULP_API_ENTRYPOINT[@]}" \
--bind "[::]:24817" \
--timeout "${PULP_GUNICORN_TIMEOUT}" \
--workers "${PULP_API_WORKERS}" \
--access-logformat "${PULP_GUNICORN_ACCESS_LOGFORMAT}" \
--access-logfile -`,
},
Env: envVarsApi,
Expand Down Expand Up @@ -745,6 +748,7 @@ exec "${PULP_CONTENT_ENTRYPOINT[@]}" \
--bind "[::]:24816" \
--timeout "${PULP_GUNICORN_TIMEOUT}" \
--workers "${PULP_CONTENT_WORKERS}" \
--access-logformat "${PULP_GUNICORN_ACCESS_LOGFORMAT}" \
--access-logfile -
`,
},
Expand Down
Loading