From d483066d14b7dd07ca586c3b6c9086ed43de7f3b Mon Sep 17 00:00:00 2001 From: Haroon Khel <34969545+Haroon-Khel@users.noreply.github.com> Date: Tue, 24 Sep 2024 19:45:54 +0800 Subject: [PATCH] docker: Fix dockerinventory script to group containers by label not ip (#3736) * docker: Fix dockerinventory script to group containers by label not ip * Update docker inventory * remove debug --- ansible/DockerInventory.json | 38 ++++++++++++------- .../scripts/updateDockerStaticInventory.py | 4 +- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/ansible/DockerInventory.json b/ansible/DockerInventory.json index d8a93812bb..be50824aad 100644 --- a/ansible/DockerInventory.json +++ b/ansible/DockerInventory.json @@ -15,6 +15,10 @@ "nodeName": "test-docker-alpine320-x64-1", "port": "32784" }, + { + "nodeName": "test-docker-centos7-x64-1", + "port": "No port" + }, { "nodeName": "test-docker-fedora39-x64-2", "port": "32779" @@ -40,7 +44,7 @@ "port": "32782" } ], - "containersCount": 9 + "containersCount": 10 }, { "name": "dockerhost-azure-ubuntu2404-x64-1", @@ -97,6 +101,12 @@ ], "containersCount": 12 }, + { + "name": "dockerhost-azure-win2022-x64-1", + "ip": "No ip", + "containers": [], + "containersCount": 0 + }, { "name": "dockerhost-equinix-ubuntu2204-armv8-1", "ip": "139.178.86.243", @@ -232,7 +242,7 @@ "containersCount": 15 }, { - "name": "dockerhost-marist-ubuntu2204-s390x-1", + "name": "dockerhost-marist-ubuntu2404-s390x-1", "ip": "148.100.74.237", "containers": [ { @@ -255,7 +265,18 @@ "containersCount": 4 }, { - "name": "dockerhost-osuosl-ubuntu2004-ppc64le-1", + "name": "dockerhost-osuosl-ubuntu2404-aarch64-1", + "ip": "140.211.167.67", + "containers": [ + { + "nodeName": "test-docker-ubuntu2404-armv7-1", + "port": "32000" + } + ], + "containersCount": 1 + }, + { + "name": "dockerhost-osuosl-ubuntu2404-ppc64le-1", "ip": "140.211.168.214", "containers": [ { @@ -277,17 +298,6 @@ ], "containersCount": 4 }, - { - "name": "dockerhost-osuosl-ubuntu2404-aarch64-1", - "ip": "140.211.167.67", - "containers": [ - { - "nodeName": "test-docker-ubuntu2404-armv7-1", - "port": "32000" - } - ], - "containersCount": 1 - }, { "name": "dockerhost-skytap-ubuntu2004-ppc64le-1", "ip": "20.61.136.212", diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/scripts/updateDockerStaticInventory.py b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/scripts/updateDockerStaticInventory.py index ab580a6ab6..45b6d480cf 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/scripts/updateDockerStaticInventory.py +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/scripts/updateDockerStaticInventory.py @@ -69,9 +69,9 @@ def main(): for node in nodes: try: nodeConfig = server.get_node_config(node["name"]) - nodeIP = getIP(nodeConfig) nodePort = getNodePort(nodeConfig) - if nodeIP == dockerhost["ip"] and node["name"] != dockerhost["name"]: + nodeLabel = getLabel(nodeConfig) + if nodeLabel.find(dockerhost["name"]) > -1: nodeObject = {"nodeName": node["name"], "port": nodePort} containers.append(nodeObject) except jenkins.NotFoundException: