Skip to content

oc-login Race Condition #41

@nmajin

Description

@nmajin

Version

redhat-actions/oc-login@v1

Describe the bug

We experienced a race condition where we had two separate pipelines run at the same time on the same runner, changing the KUBECONFIG's current-context:

app1 logs in

Fri, 05 Sep 2025 16:04:20 GMT Run redhat-actions/oc-login@v1
Fri, 05 Sep 2025 16:04:20 GMT /home/github/runner01/_work/_temp/openshift-bin/oc login
Fri, 05 Sep 2025 16:04:21 GMT /home/github/runner01/_work/_temp/openshift-bin/oc config current-context
Fri, 05 Sep 2025 16:04:21 GMT app1/***/system:serviceaccount:app1:app1-sa
Fri, 05 Sep 2025 16:04:21 GMT Set current context's namespace to "app1"
Fri, 05 Sep 2025 16:04:21 GMT /home/github/runner01/_work/_temp/openshift-bin/oc config set-context app1/***/system:serviceaccount:app1:app1-sa --namespace=app1
Fri, 05 Sep 2025 16:04:21 GMT Context "app1/***/system:serviceaccount:app1:app1-sa" modified.
Fri, 05 Sep 2025 16:04:21 GMT /home/github/runner01/_work/_temp/openshift-bin/oc config view --flatten
Fri, 05 Sep 2025 16:04:21 GMT *** Suppressing command output
Fri, 05 Sep 2025 16:04:21 GMT Writing out Kubeconfig to /home/github/runner01/_work/app1/app1/kubeconfig.yaml
Fri, 05 Sep 2025 16:04:21 GMT Kubeconfig contents
Fri, 05 Sep 2025 16:04:21 GMT Exporting KUBECONFIG=/home/github/runner01/_work/app1/app1/kubeconfig.yaml

At the same time, another app (app2) logs in (on a different runner though on the same VM)

Fri, 05 Sep 2025 16:04:20 GMT Run redhat-actions/oc-login@v1
Fri, 05 Sep 2025 16:04:20 GMT /home/github/runner02/_work/_temp/openshift-bin/oc login
Fri, 05 Sep 2025 16:04:21 GMT /home/github/runner02/_work/_temp/openshift-bin/oc config current-context
Fri, 05 Sep 2025 16:04:21 GMT app2/***/system:serviceaccount:app2:app2-sa
Fri, 05 Sep 2025 16:04:21 GMT Set current context's namespace to "app2"
Fri, 05 Sep 2025 16:04:21 GMT /home/github/runner02/_work/_temp/openshift-bin/oc config set-context app2/***/system:serviceaccount:app2:app2-sa --namespace=app2
Fri, 05 Sep 2025 16:04:21 GMT Context "app2/***/system:serviceaccount:app2:app2-sa" modified.
Fri, 05 Sep 2025 16:04:21 GMT /home/github/runner02/_work/_temp/openshift-bin/oc config view --flatten
Fri, 05 Sep 2025 16:04:21 GMT *** Suppressing command output
Fri, 05 Sep 2025 16:04:21 GMT Writing out Kubeconfig to /home/github/runner02/_work/app2/app2/kubeconfig.yaml
Fri, 05 Sep 2025 16:04:21 GMT Kubeconfig contents
Fri, 05 Sep 2025 16:04:21 GMT Exporting KUBECONFIG=/home/github/runner02/_work/app2/app2/kubeconfig.yaml

app1 has it's context changed and is now in another app2 namespace, which fails to deploy

Fri, 05 Sep 2025 16:04:21 GMT Run oc project
Fri, 05 Sep 2025 16:04:21 GMT   oc project
Fri, 05 Sep 2025 16:04:21 GMT   shell: /usr/bin/bash -e {0}
Fri, 05 Sep 2025 16:04:21 GMT   env:
Fri, 05 Sep 2025 16:04:21 GMT     NAMESPACE: app1
Fri, 05 Sep 2025 16:04:21 GMT     IMAGE_NAME: app1
Fri, 05 Sep 2025 16:04:21 GMT     KUBECONFIG: /home/github/runner01/_work/app1/app1/kubeconfig.yaml
Fri, 05 Sep 2025 16:04:21 GMT Using project "app2" on server "https://api.<CLUSTER>:6443".
...
Fri, 05 Sep 2025 16:04:21 GMT Run oc apply...
Fri, 05 Sep 2025 16:04:21 GMT from server for: "STDIN": configmaps "app1" is forbidden: User "system:serviceaccount:app2:app2-sa" cannot get resource "configmaps" in API group "" in the namespace "app1"
...

Steps to reproduce, workflow links, screenshots

See above, just using the oc-login action at the same time for two or more Jobs, creating a race condition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions