Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JenkinsMaster container configuration does not receive Lifecycle configuration set in CRD #1059

Open
DionJones615 opened this issue Sep 10, 2024 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers needs triage

Comments

@DionJones615
Copy link

Describe the bug
When setting a Lifecycle configuration for the JenkinsMaster container in the Jenkins CRD, it does not have any effect.

To Reproduce

  1. Set a Lifecycle configuration for the JenkinsMaster container such as:
[...]
spec:
  master:
    containers:
    - name: jenkins-master
      lifecycle:
        preStop:
          exec:
            command:
              - "/bin/bash"
              - "-c"
              - |-
                _log() {
                    local level="$1"
                    local message="$2"
                    local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
                    if [[ "$level" =~ ^(ERROR|ERR|error|err)$ ]]; then
                        echo "${timestamp} - ${level} - ${message}" > /proc/1/fd/2
                    fi
                    echo "${timestamp} - ${level} - ${message}" > /proc/1/fd/1
                }

                NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
                TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
                CACERT=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt

                while [[ ! "$(curl -s --cacert ${CACERT} --header "Authorization: Bearer ${TOKEN}" -X GET https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_PORT_443_TCP_PORT}/api/v1/namespaces/$NAMESPACE/pods/$HOSTNAME | sed -n '/"name": "backup"/,/}/p' | grep terminated)" ]]; do
                    _log "INFO" "[preStop] Waiting for backup container to terminate..."
                    sleep 5
                }
[...]
  1. Observe that the resulting Jenkins pod configuration does not include this lifecycle configuration

Additional information

It appears that the Lifecycle is not passed to the container config here. However, I suspect reconciliation probably needs an update as well

Jenkins Operator version: 0.8.0

@DionJones615 DionJones615 added the bug Something isn't working label Sep 10, 2024
@brokenpip3
Copy link
Collaborator

Yep indeed is not passed, do you mind create a PR? it should be easy, we just need the changes in pod.go (with handling of default empty) and helm chart values/template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers needs triage
Projects
None yet
Development

No branches or pull requests

2 participants