Skip to content

Conversation

@myacksmith
Copy link

@myacksmith myacksmith commented Dec 16, 2025

Summary

Adds a new CRD field gunicorn_access_logformat to customize gunicorn's access log format for api and content pods.

Closes #1564

Changes

pulp_types.go

  • Add GunicornAccessLogformat field to Api struct
  • Add GunicornAccessLogformat field to Content struct

deployment.go

  • Modify setEnvVars(): Set PULP_GUNICORN_ACCESS_LOGFORMAT env var with default value if field is empty
  • Modify pulpcoreApiContainerArgs(): Remove hardcoded --access-logformat from gunicorn ENTRYPOINT array, add --access-logformat "${PULP_GUNICORN_ACCESS_LOGFORMAT}" to exec command
  • Modify pulpcoreContentContainerArgs(): Add --access-logformat "${PULP_GUNICORN_ACCESS_LOGFORMAT}" to exec command

controller_test.go

  • Add PULP_GUNICORN_ACCESS_LOGFORMAT to envVarsApi and envVarsContent
  • Update apiContainers and content container Args to match new shell script behavior

Default format:

pulp [%({correlation-id}o)s]: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"

This preserves existing behavior when the field is not specified - the default includes the correlation-id header from django_guid.

Usage

spec:
  api:
    gunicorn_access_logformat: '{"remote_ip": "%(h)s", "method": "%(m)s", "path": "%(U)s", "status": "%(s)s"}'
  content:
    gunicorn_access_logformat: '{"remote_ip": "%(h)s", "method": "%(m)s", "path": "%(U)s", "status": "%(s)s"}'

@openshift-ci openshift-ci bot requested review from dkliban and git-hyagi December 16, 2025 20:12
@openshift-ci
Copy link

openshift-ci bot commented Dec 16, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: myacksmith
Once this PR has been reviewed and has the lgtm label, please assign git-hyagi for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link

openshift-ci bot commented Dec 16, 2025

Hi @myacksmith. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@myacksmith myacksmith force-pushed the allow-gunicorn-log-format-to-be-customized branch from cc92715 to c9f7c64 Compare December 16, 2025 20:57
@balasankarc
Copy link
Collaborator

@myacksmith Please run make manifests so that the CRDs are updated.

@openshift-ci
Copy link

openshift-ci bot commented Dec 17, 2025

@balasankarc: changing LGTM is restricted to collaborators

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@myacksmith myacksmith force-pushed the allow-gunicorn-log-format-to-be-customized branch 4 times, most recently from 3935cdf to 023dc5b Compare December 19, 2025 19:56
* 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 pulp#1564
@myacksmith myacksmith force-pushed the allow-gunicorn-log-format-to-be-customized branch from 023dc5b to ddfa162 Compare December 20, 2025 02:11
@balasankarc
Copy link
Collaborator

/ok-to-test

@myacksmith
Copy link
Author

Hi! 👋

Quick note on the CI failures.

Unit tests pass locally (I know, I know... "works on my machine" 🙈) :

Ran 12 of 13 Specs in 24.996 seconds
SUCCESS! -- 12 Passed | 0 Failed | 0 Pending | 1 Skipped

The component and Helm tests appear to be failing due to infrastructure issues:

Kustomize download failing:

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
make: *** [Makefile:248: /home/runner/work/pulp-operator/pulp-operator/bin/kustomize] Error 2

Helm tests - RBAC role not found:

ERROR  controller-runtime.cache.UnhandledError  Failed to watch
{"type": "*v2.HorizontalPodAutoscaler", "error": "failed to list *v2.HorizontalPodAutoscaler: 
horizontalpodautoscalers.autoscaling is forbidden: User \"system:serviceaccount:pulp-operator-system:pulp-operator-controller-manager\" 
cannot list resource \"horizontalpodautoscalers\" in API group \"autoscaling\" in the namespace \"pulp-operator-system\": 
RBAC: role.rbac.authorization.k8s.io \"pulp-operator-manager-role\" not found"}

I'm not familiar enough with the CI setup to know if this is a known/intermittent issue or something new. If there's something I should look into on my end, please let me know!

Thanks for your time reviewing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow gunicorn log format to be customized

2 participants