Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nickboldt/83e866a748850e95276ea8f247a3d86c to your computer and use it in GitHub Desktop.
Save nickboldt/83e866a748850e95276ea8f247a3d86c to your computer and use it in GitHub Desktop.
collecting konflux pipeline and task run logs

Collect Konflux/Tekton logs with opc

Get logs for a running build

Install opc from https://docs.openshift.com/pipelines/latest/tkn_cli/installing-tkn.html

pr=abcde # some hash code for the specific pull request pipeline

# get the full pipeline run log (all tasks)
opc pr logs -n rhdh-tenant rhdh-hub-1-on-pull-request-${pr} -f | tee ~/tmp/rhdh-hub-1-on-pull-request-${pr}.log.txt &

# for just the build container, wait 8 mins for dep resolution step, then get the task run
sleep 8m; opc tr logs -n rhdh-tenant rhdh-hub-1-on-pull-request-${pr}-build-container -f | tee ~/tmp/rhdh-hub-1-on-pull-request-${pr}-build-container.log.txt

or for a push

pr=abcde # some hash code for the specific push pipeline

# get the full pipeline run log (all tasks)
opc pr logs -n rhdh-tenant rhdh-hub-1-on-push-${pr} -f | tee /tmp/rhdh-hub-1-on-push-${pr}.log.txt &

# for just the build container, wait 8 mins for dep resolution step, then get the task run
sleep 8m; opc tr logs -n rhdh-tenant rhdh-hub-1-on-push-${pr}-build-container -f | tee /tmp/rhdh-hub-1-on-push-${pr}-build-container.log.txt

Get logs for a running release (managed pipeline run):

opc pr logs -n rhtap-releng-tenant managed-9k68t -f | tee /tmp/release-1.4.2-stage-managed-9k68t.log.txt

Collect running pod logs

og get Pods

oc logs -f rhdh-hub-1-4-on-push-4npgp-publish-helm-pod -c step-publish

oc logs -f rhdh-hub-1-on-pull-request-67jzd-prefetch-dependencies-pod -c step-prefetch-dependencies

oc logs -f rhdh-hub-1-4-on-push-4npgp-build-container-pod -c step-build

oc logs -f rhdh-hub-1-on-pull-request-67jzd-build-container-pod -c step-build \
| tee /tmp/rhdh-hub-1-on-pull-request-67jzd-build-container-pod_step-build.log.txt

podprefix=$(oc get Pods | grep "rhdh-hub-1-on-pull" | tail -1 | sed -r -e "s@(.+-request-([0-9a-z]+)-).+-pod.+@\1@")
echo $podprefix

oc logs -f ${podprefix}prefetch-dependencies-pod -c step-prefetch-dependencies \
| tee /tmp/${podprefix}prefetch-dependencies-pod_step-prefetch-dependencies.log.txt; \
sleep 2m; \
oc logs -f ${podprefix}build-container-pod -c step-build \
| tee /tmp/${podprefix}build-container-pod_step-build.log.txt  

using tekton plugin

Install from https://gitlab.cee.redhat.com/konflux/docs/sop/-/blob/main/pipeline-service/results/kubectl-plugin.md or https://github.com/sayan-biswas/kubectl-tekton

Log in

kubectl tekton config results host="https://tekton-results-tekton-results.apps.<your-cluster>" token="sha256~<your-token>" --no-prompt

for EC Tests - pipeline runs and task runs

kubectl tekton get pr --limit 5 --annotations "pac.test.appstudio.openshift.io/original-prname=rhdh-hub-1-on-push"
kubectl tekton get tr --limit 5 --annotations "pac.test.appstudio.openshift.io/original-prname=rhdh-hub-1-on-push"

takes only a 2-3 seconds to get a list of pipeline runs and task runs

kubectl tekton get pr --limit 5 --annotations "pipelinesascode.tekton.dev/original-prname=rhdh-hub-1-on-push" 
kubectl tekton get tr --limit 5 --annotations "pipelinesascode.tekton.dev/original-prname=rhdh-hub-1-on-push" 

takes under 2 seconds to get a task run log

kubectl tekton logs tr rhdh-hub-1-on-push-zql8k-build-container > /tmp/log.txt 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment