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

Unable to connect openshift using inventory plugin #52

Closed
savitojs opened this issue Apr 12, 2021 · 6 comments · Fixed by #63
Closed

Unable to connect openshift using inventory plugin #52

savitojs opened this issue Apr 12, 2021 · 6 comments · Fixed by #63
Assignees
Labels
type/bug Something isn't working verified The issue is reproduced
Milestone

Comments

@savitojs
Copy link

savitojs commented Apr 12, 2021

SUMMARY
ISSUE TYPE
  • Bug
COMPONENT NAME
ANSIBLE VERSION
$ ansible --version               
ansible 2.10.7
  config file = /home/savsingh/openshift/ansible.cfg
  configured module search path = ['/home/savsingh/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/savsingh/virtualenvs/openshfit-test2/lib64/python3.6/site-packages/ansible
  executable location = /home/savsingh/virtualenvs/openshfit-test2/bin/ansible
  python version = 3.6.8 (default, Aug 18 2020, 08:33:21) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
$ cat openshift.yaml                             
plugin: redhat.openshift.openshift
connections:
  - host: https://api.ocp4.example.com:6443/
    api_key: sha256~zqxxxxxxx-T
    validate_certs: false
EXPECTED RESULTS

inventory should gather the information about the objects in openshift.

ACTUAL RESULTS
$ ansible-inventory all -i openshift.yaml --list
[WARNING]:  * Failed to parse /home/savsingh/openshift/openshift.yaml with auto plugin: 404 Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Audit-Id': '4b09d246-0fbe-46c2-823d-8609472afd06', 'Cache-Control': 'no-
cache, private', 'Content-Type': 'application/json', 'Date': 'Mon, 12 Apr 2021 11:24:29 GMT', 'Content-Length':
'1228'}) HTTP response body: b'{\n  "paths": [\n    "/apis",\n    "/apis/",\n    "/apis/apiextensions.k8s.io",\n
"/apis/apiextensions.k8s.io/v1",\n    "/apis/apiextensions.k8s.io/v1beta1",\n    "/healthz",\n
"/healthz/etcd",\n    "/healthz/log",\n    "/healthz/ping",\n    "/healthz/poststarthook/crd-informer-synced",\n
"/healthz/poststarthook/generic-apiserver-start-informers",\n    "/healthz/poststarthook/start-apiextensions-
controllers",\n    "/healthz/poststarthook/start-apiextensions-informers",\n    "/livez",\n    "/livez/etcd",\n
"/livez/log",\n    "/livez/ping",\n    "/livez/poststarthook/crd-informer-synced",\n
"/livez/poststarthook/generic-apiserver-start-informers",\n    "/livez/poststarthook/start-apiextensions-
controllers",\n    "/livez/poststarthook/start-apiextensions-informers",\n    "/metrics",\n    "/openapi/v2",\n
"/readyz",\n    "/readyz/etcd",\n    "/readyz/informer-sync",\n    "/readyz/log",\n    "/readyz/openshift-
apiservices-available",\n    "/readyz/ping",\n    "/readyz/poststarthook/crd-informer-synced",\n
"/readyz/poststarthook/generic-apiserver-start-informers",\n    "/readyz/poststarthook/start-apiextensions-
controllers",\n    "/readyz/poststarthook/start-apiextensions-informers",\n    "/readyz/shutdown",\n
"/version"\n  ]\n}' Original traceback:    File "/home/savsingh/virtualenvs/openshfit-
test2/lib64/python3.6/site-packages/openshift/dynamic/client.py", line 42, in inner     resp = func(self, *args,
**kwargs)    File "/home/savsingh/virtualenvs/openshfit-test2/lib64/python3.6/site-
packages/openshift/dynamic/client.py", line 247, in request
_return_http_data_only=params.get('_return_http_data_only', True)    File "/home/savsingh/virtualenvs/openshfit-
test2/lib64/python3.6/site-packages/kubernetes/client/api_client.py", line 353, in call_api
_preload_content, _request_timeout, _host)    File "/home/savsingh/virtualenvs/openshfit-
test2/lib64/python3.6/site-packages/kubernetes/client/api_client.py", line 184, in __call_api
_request_timeout=_request_timeout)    File "/home/savsingh/virtualenvs/openshfit-test2/lib64/python3.6/site-
packages/kubernetes/client/api_client.py", line 377, in request     headers=headers)    File
"/home/savsingh/virtualenvs/openshfit-test2/lib64/python3.6/site-packages/kubernetes/client/rest.py", line 243,
in GET     query_params=query_params)    File "/home/savsingh/virtualenvs/openshfit-test2/lib64/python3.6/site-
packages/kubernetes/client/rest.py", line 233, in request     raise ApiException(http_resp=r)
[WARNING]:  * Failed to parse /home/savsingh/openshift/openshift.yaml with yaml plugin: Plugin configuration
YAML file, not YAML inventory
[WARNING]:  * Failed to parse /home/savsingh/openshift/openshift.yaml with ini plugin: Invalid host pattern
'plugin:' supplied, ending in ':' is not allowed, this character is reserved to provide a port.
[WARNING]: Unable to parse /home/savsingh/openshift/openshift.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
    "_meta": {
        "hostvars": {}
    },
    "all": {
        "children": [
            "ungrouped"
        ]
    }
}

@savitojs
Copy link
Author

cc @Akasurde

@Akasurde Akasurde self-assigned this Apr 12, 2021
@Akasurde
Copy link
Member

@savitojs Thanks for reporting this issue. I will try to reproduce this on my setup.

@gomix
Copy link

gomix commented Apr 12, 2021

This also happens with Ansible 2.9.

ansible 2.9.19                                                                                                                                    
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ggomezsa/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Aug 18 2020, 08:33:21) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]``

@Akasurde
Copy link
Member

While debugging found another issue - #57

Akasurde added a commit to Akasurde/kubernetes.core that referenced this issue Apr 16, 2021
When user provides hostname with trailing slashes like
https://localhost:6443/, the openshift library fails to
enumerate the APIs from the given cluster.

This fix removes any extra trailing slashes before sending it
to the openshift DynamicClient.

Fixes: ansible-collections#52

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@Akasurde
Copy link
Member

resolved_by_pr #63

@Akasurde
Copy link
Member

When the user specifies a hostname with extra trailing space (e.g. https://localhost:6443/), DynamicClient fails to enumerate the APIs from the cluster server. Removing such extra trailing slashes resolves the issue.

@Akasurde Akasurde added type/bug Something isn't working verified The issue is reproduced labels Apr 16, 2021
@Akasurde Akasurde added this to the 2.0.0 milestone Apr 16, 2021
Akasurde added a commit that referenced this issue Apr 20, 2021
When the user provides a hostname with trailing slashes like
https://localhost:6443/, the openshift library fails to
enumerate the APIs from the given cluster.

This fix removes any extra trailing slashes before sending it
to the openshift DynamicClient.

Fixes: #52

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working verified The issue is reproduced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants