vmware-archive / vsan-integration-for-prometheus

vSAN Integration for Prometheus: making it easier using Prometheus to monitor vSAN performance

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vsan-prometheus-exporter docker run fails due to ImportError in pyVmomi v7.0.3

crockk opened this issue · comments

commented

Describe the bug

The latest release of pyVmomi (v7.0.3) is for some reason causing an ImportError when trying to run the vsan-prometheus-exporter in standalone Docker. Downgrading to pyvmomi=7.0.2 fixes the error.

Dockerfile:

# Copyright (c) 2020-2021 VMware, Inc. All Rights Reserved
# SPDX-License-Identifier: BSD-2
FROM photon:3.0
RUN tdnf install -y python3 python3-pip && pip3 install setuptools && pip3 install pyvmomi flask gunicorn==19.9.0 && tdnf clean all
WORKDIR /
COPY gunicorn.conf wsgi.py server.py connectUtils.py prometheus.py vsanPrometheusStats.py vsanmgmtObjects.py ./
EXPOSE 8080
ENTRYPOINT ["gunicorn", "-c", "gunicorn.conf", "wsgi:app"]
2022-05-27 19:09:19 +0000 INFO [1|139658128185152] [glogging::info] Starting gunicorn 19.9.0
2022-05-27 19:09:19 +0000 INFO [1|139658128185152] [glogging::info] Listening at: http://0.0.0.0:8080 (1)
2022-05-27 19:09:19 +0000 INFO [1|139658128185152] [glogging::info] Using worker: sync
2022-05-27 19:09:19 +0000 INFO [9|139658128185152] [glogging::info] Booting worker with pid: 9
2022-05-27 19:09:19 +0000 ERROR [9|139658128185152] [glogging::exception] Exception in worker process
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
  File "/usr/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
    self.load_wsgi()
  File "/usr/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
    return self.load_wsgiapp()
  File "/usr/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
    __import__(module)
  File "/wsgi.py", line 7, in <module>
    from server import create_app
  File "/server.py", line 11, in <module>
    from vsanPrometheusStats import VsanPrometheusStats
  File "/vsanPrometheusStats.py", line 17, in <module>
    from connectUtils import ConnectToVC, ConnectToHost, GetClusterInstance
  File "/connectUtils.py", line 13, in <module>
    import vsanmgmtObjects
  File "/vsanmgmtObjects.py", line 7, in <module>
    from pyVmomi.VmomiSupport import CreateDataType, CreateManagedType, CreateEnumType, AddVersion, AddVersionParent, F_LINK, F_LINKABLE, F_OPTIONAL, F_SECRET, newestVersions, stableVersions, publicVersions
ImportError: cannot import name 'stableVersions' from 'pyVmomi.VmomiSupport' (/usr/lib/python3.7/site-packages/pyVmomi/VmomiSupport.py)
2022-05-27 19:09:19 +0000 INFO [9|139658128185152] [glogging::info] Worker exiting (pid: 9)
2022-05-27 19:09:19 +0000 INFO [1|139658128185152] [glogging::info] Shutting down: Master
2022-05-27 19:09:19 +0000 INFO [1|139658128185152] [glogging::info] Reason: Worker failed to boot.

Updated Dockerfile:

# Copyright (c) 2020-2021 VMware, Inc. All Rights Reserved
# SPDX-License-Identifier: BSD-2
FROM photon:3.0
RUN tdnf install -y python3 python3-pip && pip3 install setuptools && pip3 install pyvmomi==7.0.2 flask gunicorn==19.9.0 && tdnf clean all
WORKDIR /
COPY gunicorn.conf wsgi.py server.py connectUtils.py prometheus.py vsanPrometheusStats.py vsanmgmtObjects.py ./
EXPOSE 8080
ENTRYPOINT ["gunicorn", "-c", "gunicorn.conf", "wsgi:app"]

Running the container using the updated Dockerfile:

2022-05-27 19:32:39 +0000 INFO [1|140661303359296] [glogging::info] Starting gunicorn 19.9.0
2022-05-27 19:32:39 +0000 INFO [1|140661303359296] [glogging::info] Listening at: http://0.0.0.0:8080 (1)
2022-05-27 19:32:39 +0000 INFO [1|140661303359296] [glogging::info] Using worker: sync
2022-05-27 19:32:39 +0000 INFO [10|140661303359296] [glogging::info] Booting worker with pid: 10
2022-05-27 19:32:40 +0000 INFO [10|140661303359296] [vsanPrometheusStats::__init__] Env "VCENTER" is set, connecting to VC automatically
2022-05-27 19:32:40 +0000 INFO [10|140661303359296] [vsanPrometheusStats::connectOnStart] vcip: vcenter1, vcport: 443, vcuser: vsphere.user@tdl.com, clusterName: cluster1
. . . 

Reproduction steps

1. Clone the repository
2. Build the vsan-prometheus-exporter docker image using the provided Dockerfile
3. Run the container

Expected behavior

We expect the container to run without any programming errors.

Additional context

No response