Bug 1778714

Summary: [wsu] run ansible playbook fail when setting kubeconfig with relative path
Product: OpenShift Container Platform Reporter: gaoshang <sgao>
Component: Windows ContainersAssignee: Aravindh Puthiyaparambil <aravindh>
Status: CLOSED ERRATA QA Contact: gaoshang <sgao>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.3.0CC: aos-bugs, gmarkley, rgudimet
Target Milestone: ---   
Target Release: 4.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-27 15:54:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description gaoshang 2019-12-02 11:30:40 UTC
Description of problem:
When setting kubeconfig with relative path, run wsu ansible playbook will fail in TASK [Check for bootstrap CSR].

Version-Release number of selected component (if applicable):
# oc get clusterversion
NAME      VERSION                             AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.3.0-0.nightly-2019-11-29-051144   True        False         6h57m   Cluster version is 4.3.0-0.nightly-2019-11-29-051144
# git show
commit 22f339a49465138862a490adc632fb11ce62cb20

How reproducible:
always

Steps to Reproduce:
1. Install OCP 4.3 cluster with ovn-kubernetes

2. Set KUBECONFIG with relative path
# export KUBECONFIG=kubeconfig-72923

3. Create windows instance with wni
# ./wni azure create --kubeconfig kubeconfig-72923 --credentials ~/.azure/osServicePrincipal.json --image-id MicrosoftWindowsServer:WindowsServer:2019-Datacenter-with-Containers:latest --instance-type Standard_D2s_v3

4. Run wsu ansible playbook

Actual results:
Ansible run succeed.

Expected results:
Ansible run failed, oc command can not find kubeconfig file.

# ansible-playbook -i hosts ~/go/src/windows-machine-config-operator/tools/ansible/tasks/wsu/main.yaml -v
...
TASK [Check for bootstrap CSR] ******
FAILED - RETRYING: Check for bootstrap CSR (2 retries left).
FAILED - RETRYING: Check for bootstrap CSR (1 retries left).
fatal: [13.67.137.145 -> localhost]: FAILED! => {"attempts": 2, "changed": true, "cmd": "oc get csr | awk '/system:serviceaccount:openshift-machine-config-operator:node-bootstrapper/ && /Pending/ {print $1}'", "delta": "0:00:00.103710", "end": "2019-12-02 18:25:35.516440", "rc": 0, "start": "2019-12-02 18:25:35.412730", "stderr": "error: Missing or incomplete configuration info.  Please login or point to an existing, complete config file:\n\n  1. Via the command-line flag --config\n  2. Via the KUBECONFIG environment variable\n  3. In your home directory as ~/.kube/config\n\nTo view or setup config directly use the 'config' command.", "stderr_lines": ["error: Missing or incomplete configuration info.  Please login or point to an existing, complete config file:", "", "  1. Via the command-line flag --config", "  2. Via the KUBECONFIG environment variable", "  3. In your home directory as ~/.kube/config", "", "To view or setup config directly use the 'config' command."], "stdout": "", "stdout_lines": []}


Additional info:
This issue is caused by ansible "delegate_to" module, seems like when using "delegate_to: localhost", working directory changed to ansible playbook folder, such as: /root/go/src/windows-machine-config-operator/tools/ansible/tasks/wsu, so all oc command will fail in the play book.

Comment 3 Aravindh Puthiyaparambil 2020-05-18 15:20:38 UTC
Update the docs stating you need to provide absolute path for the kubeconfig.

Comment 6 gaoshang 2020-06-09 07:41:15 UTC
QE testing passed by checking docs, thanks.

Comment 8 errata-xmlrpc 2020-10-27 15:54:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Container Platform 4.6 GA Images), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4196