Uploaded image for project: 'OpenShift Pipelines'
  1. OpenShift Pipelines
  2. SRVKP-9292

Results not getting retained per retention when 2 policies specified with same namespaces

XMLWordPrintable

    • 3
    • False
    • Hide

      None

      Show
      None
    • False
    • Hide
      Fixes a bug in the Results retention where status-based policies were not applied correctly, causing higher-priority rules such as “Failed before” with longer retention durations to be ignored in favor of more generic policies. Additionally, TaskRuns that belonged to PipelineRuns were incorrectly treated as standalone and deleted prematurely, even though their cleanup should occur only when their parent PipelineRun is removed. This update ensures accurate policy precedence evaluation and restricts TaskRun retention logic to true standalone TaskRuns, restoring expected retention behavior across namespaces and statuses.
      Show
      Fixes a bug in the Results retention where status-based policies were not applied correctly, causing higher-priority rules such as “Failed before” with longer retention durations to be ignored in favor of more generic policies. Additionally, TaskRuns that belonged to PipelineRuns were incorrectly treated as standalone and deleted prematurely, even though their cleanup should occur only when their parent PipelineRun is removed. This update ensures accurate policy precedence evaluation and restricts TaskRun retention logic to true standalone TaskRuns, restoring expected retention behavior across namespaces and statuses.
    • Pipelines Sprint Pioneers 42, Pipelines Sprint Pioneers 43

      Results not getting retained per retention when 2 policies specified with same namespaces

      Steps to reproduce:

      1. Edit the tektonconfig with restention policies as defined below
      result:
            auth_disable: true
            disabled: false
            is_external_db: false
            log_level: debug
            loki_stack_name: logging-loki
            loki_stack_namespace: openshift-logging
            options:
              configMaps:
                tekton-results-config-results-retention-policy:
                  data:
                    defaultRetention: 60m
                    policies: |
                      - name: "retain-critical-failures-prod"
                        selector:
                          matchNamespaces:
                            - "production"
                            - "prod-east"
                          matchLabels:
                            "env": ["prod"]
                          matchStatuses: ["Failed"]
                        retention: "20m"
                      - name: "default-prod-policy"
                        selector:
                          matchNamespaces:
                            - "production"
                            - "prod-east"
                        retention: "5m"
                    runAt: '*/1 * * * *'
                  metadata:
                    creationTimestamp: null
            performance:
              buckets: 2
              disable-ha: false
              replicas: 2
              statefulset-ordinals: true
       
      1. Create a new project named prod-east and create the below pipelineruns 
        1. 1 pipeline having label env:prod and tend to Fail
        2.  1 pipeline having label env:prod and gets Succeeded
      [12:47:37] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ oc project
      Using project "prod-east" on server "https://api.long-running-1105379.aws.ospqa.com:6443".
      [12:47:40] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ oc create -f testdata/ecosystem/pipelines/buildah.yaml 
      pipeline.tekton.dev/buildah-pipeline created
      [12:47:55] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ oc create -f testdata/ecosystem/pipelines/jib-maven.yaml 
      pipeline.tekton.dev/jib-maven-pipeline created
      [12:48:02] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ oc create -f testdata/pvc/pvc.yaml 
      persistentvolumeclaim/shared-pvc created
      [12:48:16] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ oc create -f testdata/ecosystem/pipelineruns/buildah.yaml 
      pipelinerun.tekton.dev/prod-buildah-run created
      [12:48:42] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ echo $RESULTS_API 
      tekton-results-api-service-openshift-pipelines.apps.long-running-1105379.aws.ospqa.com:443
      [12:48:49] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ opc pr ls
      NAME               STARTED          DURATION   STATUS
      prod-buildah-run   12 seconds ago   ---        Running
      [12:48:54] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ opc pr ls
      NAME               STARTED          DURATION   STATUS
      prod-buildah-run   21 seconds ago   ---        Running
      [12:49:03] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ oc create -f testdata/ecosystem/pipelineruns/jib-maven.yaml 
      pipelinerun.tekton.dev/prod-jib-maven-run created
      [12:49:12] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ opc pr ls
      NAME                 STARTED          DURATION   STATUS
      prod-jib-maven-run   7 seconds ago    ---        Running
      prod-buildah-run     37 seconds ago   35s        Succeeded
      [12:49:19] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ opc results result list --insecure --addr ${RESULTS_API} prod-east
      Name                                                    Start                                   Update
      prod-east/results/7a47fd77-f338-4f87-8e34-aa7d662dc52c  2025-11-11 12:49:12 +0530 IST           2025-11-11 12:49:20 +0530 IST
      prod-east/results/9e3bc31f-b25d-48b0-9e91-ddff851d4211  2025-11-11 12:48:42 +0530 IST           2025-11-11 12:49:17 +0530 IST
      [12:49:31] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ opc pr ls
      NAME                 STARTED          DURATION   STATUS
      prod-jib-maven-run   27 seconds ago   25s        Failed
      prod-buildah-run     57 seconds ago   35s        Succeeded
       
      1. Once the pipelineruns are executed, validate the logs of both the pipelineRuns

      Expected Result:
      The failed pipelineRun in prod-east namespace having label env:prod with status Failed should retain for 20m

      Actual Result:
      The failed pipelineRun was not getting retained for 20m and getting cleanedup after 5m as specified in other retention policy

      [12:53:26] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ opc pr ls
      NAME                 STARTED         DURATION   STATUS
      prod-jib-maven-run   4 minutes ago   25s        Failed
      prod-buildah-run     4 minutes ago   35s        Succeeded
      [12:53:31] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ opc results result list --insecure --addr ${RESULTS_API} prod-east
      Name                                                    Start                                   Update
      prod-east/results/7a47fd77-f338-4f87-8e34-aa7d662dc52c  2025-11-11 12:49:12 +0530 IST           2025-11-11 12:49:37 +0530 IST
      prod-east/results/9e3bc31f-b25d-48b0-9e91-ddff851d4211  2025-11-11 12:48:42 +0530 IST           2025-11-11 12:49:17 +0530 IST
      [12:53:40] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ opc results result list --insecure --addr ${RESULTS_API} prod-east
      Name                                                    Start                                   Update
      prod-east/results/7a47fd77-f338-4f87-8e34-aa7d662dc52c  2025-11-11 12:49:12 +0530 IST           2025-11-11 12:49:37 +0530 IST
      [12:54:38] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ opc results result list --insecure --addr ${RESULTS_API} prod-east
      Name                                    Start                                   Update
      [12:55:35] smanthin@smanthin-thinkpadp16vgen1:~/Automation/release-tests$ opc results result list --insecure --addr ${RESULTS_API} prod-east
      Name                                    Start                                   Update
       

      Note: Please observe the timestamps of the above pipelineRuns execution/logs

      PFA screenshots, recordings & logs for reference

       



      Screencast From 2025-11-11 12-47-12.mp4
      PFA PR yamls for reference
      prod-jib-maven-run-failed.yaml
      prod-buildah-run-succeeded.yaml

       

        1. Screencast From 2025-11-11 12-47-12.mp4
          14.69 MB
          Sai Raju Manthina
        2. prod-jib-maven-run-failed.yaml
          3 kB
          Sai Raju Manthina
        3. prod-buildah-run-succeeded.yaml
          3 kB
          Sai Raju Manthina
        4. image-2025-11-11-13-05-56-388.png
          324 kB
          Sai Raju Manthina
        5. image-2025-11-11-13-02-34-191.png
          69 kB
          Sai Raju Manthina
        6. image-2025-11-11-13-02-08-246.png
          169 kB
          Sai Raju Manthina

              rh-ee-kbaig Khurram Baig
              rh-ee-smanthin Sai Raju Manthina
              Sai Raju Manthina Sai Raju Manthina
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: