summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2023-05-08 10:41:02 +0200
committernicolargo <nicolas@nicolargo.com>2023-05-08 10:45:20 +0200
commitf0ffd1039214cb70518d61601a7a82e416fba105 (patch)
treee4f063287b5f6d8038c8f0ab5720bfdeac1381f8
parent985dd6c8ea0e8dfad4da08b7373a42fb72a972ba (diff)
Improve Glances start time by disabling Docker and Podman version getter - Related to #1985
-rw-r--r--glances/plugins/containers/glances_docker.py25
-rw-r--r--glances/plugins/containers/glances_podman.py27
2 files changed, 21 insertions, 31 deletions
diff --git a/glances/plugins/containers/glances_docker.py b/glances/plugins/containers/glances_docker.py
index 8ac3fbc9..875952fb 100644
--- a/glances/plugins/containers/glances_docker.py
+++ b/glances/plugins/containers/glances_docker.py
@@ -221,6 +221,7 @@ class DockerContainersExtension:
self.client = None
self.ext_name = "containers (Docker)"
self.stats_fetchers = {}
+
self.connect()
def connect(self):
@@ -233,6 +234,11 @@ class DockerContainersExtension:
logger.error("{} plugin - Can't connect to Docker ({})".format(self.ext_name, e))
self.client = None
+ def update_version(self):
+ # Long and not useful anymore because the information is no more displayed in UIs
+ # return self.client.version()
+ return {}
+
def stop(self):
# Stop all streaming threads
for t in itervalues(self.stats_fetchers):
@@ -240,23 +246,12 @@ class DockerContainersExtension:
def update(self, all_tag):
"""Update Docker stats using the input method."""
- # Docker version
- # Example: {
- # "KernelVersion": "3.16.4-tinycore64",
- # "Arch": "amd64",
- # "ApiVersion": "1.15",
- # "Version": "1.3.0",
- # "GitCommit": "c78088f",
- # "Os": "linux",
- # "GoVersion": "go1.3.3"
- # }
- try:
- version_stats = self.client.version()
- except Exception as e:
- # Correct issue#649
- logger.error("{} plugin - Can't get Docker version ({})".format(self.ext_name, e))
+
+ if not self.client:
return {}, []
+ version_stats = self.update_version()
+
# Update current containers list
try:
# Issue #1152: Docker module doesn't export details about stopped containers
diff --git a/glances/plugins/containers/glances_podman.py b/glances/plugins/containers/glances_podman.py
index be53acf9..21e66c56 100644
--- a/glances/plugins/containers/glances_podman.py
+++ b/glances/plugins/containers/glances_podman.py
@@ -219,17 +219,12 @@ class PodmanContainersExtension:
if import_podman_error_tag:
raise Exception("Missing libs required to run Podman Extension (Containers)")
- self.ext_name = "containers (Podman)"
-
self.client = None
+ self.ext_name = "containers (Podman)"
self.podman_sock = podman_sock
self.pods_stats_fetcher = None
self.container_stats_fetchers = {}
- # Cache version details as the version call is costly (in terms of time)
- self._version = {}
- self._last_version_update = 0
-
self.connect()
def connect(self):
@@ -238,13 +233,12 @@ class PodmanContainersExtension:
self.client = PodmanClient(base_url=self.podman_sock)
except Exception as e:
logger.error("{} plugin - Can't connect to Podman ({})".format(self.ext_name, e))
+ self.client = None
def update_version(self):
- try:
- self._version = self.client.version()
- self._last_version_update = time.time()
- except Exception as e:
- logger.error("{} plugin - Can't get Podman version ({})".format(self.ext_name, e))
+ # Long and not useful anymore because the information is no more displayed in UIs
+ # return self.client.version()
+ return {}
def stop(self):
# Stop all streaming threads
@@ -257,9 +251,10 @@ class PodmanContainersExtension:
def update(self, all_tag):
"""Update Podman stats using the input method."""
- curr_time = time.time()
- if curr_time - self._last_version_update > 300: # 300 seconds
- self.update_version()
+ if not self.client:
+ return {}, []
+
+ version_stats = self.update_version()
# Update current containers list
try:
@@ -270,7 +265,7 @@ class PodmanContainersExtension:
self.pods_stats_fetcher = PodmanPodStatsFetcher(self.client.pods)
except Exception as e:
logger.error("{} plugin - Can't get containers list ({})".format(self.ext_name, e))
- return self._version, []
+ return version_stats, []
# Start new thread for new container
for container in containers:
@@ -298,7 +293,7 @@ class PodmanContainersExtension:
stats["pod_name"] = pod_stats[stats["Id"][:12]]["name"]
stats["pod_id"] = pod_stats[stats["Id"][:12]]["pod_id"]
- return self._version, container_stats
+ return version_stats, container_stats
@property
def key(self):