[docker] compose: Switch ip_range to ipv4_address 35/65535/1
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Wed, 28 Nov 2018 17:11:20 +0000 (18:11 +0100)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Mon, 3 Dec 2018 13:45:44 +0000 (13:45 +0000)
Explicitly set the ipv4_address for each network instead of relying
on ip_range allocation, which seems to fail / not be picked up.

While at it, use docker-compose 1.22 or newer to bypass slow Docker
network creation with 'macvlan' driver [1].

[1] https://github.com/docker/compose/issues/5248

Change-Id: Ic31851522576ebb2407d869b7c3ed7bd06951922
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
(cherry picked from commit 904183e275ca6b2aa6cad11a330fc060d5379b3e)

mcp/scripts/docker-compose/docker-compose.yaml.j2
mcp/scripts/lib_jump_common.sh
mcp/scripts/lib_jump_deploy.sh

index 8cd9d5d..891d559 100644 (file)
@@ -15,9 +15,12 @@ services:
     container_name: "fuel"
     image: "opnfv/fuel:saltmaster-reclass-{{ conf.MCP_DOCKER_TAG }}"
     networks:
-      - mcpcontrol
-      - pxebr
-      - mgmt
+      mcpcontrol:
+        ipv4_address: {{ conf.SALT_MASTER }}
+      pxebr:
+        ipv4_address: {{ nm.net_admin | ipnet_hostaddr(nm.start_ip[nm.net_admin] + nm.net_admin_hosts.index('opnfv_infra_config_pxe_admin_address') +1) }}
+      mgmt:
+        ipv4_address: {{ nm.net_mgmt | ipnet_hostaddr(nm.start_ip[nm.net_mgmt] + nm.net_mgmt_hosts.index('opnfv_infra_config_address') +1) }}
     volumes:
        - /run/dbus/system_bus_socket:/run/dbus/system_bus_socket:ro
        - {{ conf.MCP_REPO_ROOT_PATH }}:/root/fuel
@@ -42,7 +45,6 @@ networks:
       config:
         - subnet: {{ net_mcpcontrol }}
           gateway: {{ net_mcpcontrol | ipnet_hostaddr(1) }}
-          ip_range: {{ [conf.SALT_MASTER, conf.MCPCONTROL_PREFIX] | join("/") }}
   pxebr:
     driver: macvlan
     driver_opts:
@@ -50,7 +52,6 @@ networks:
     ipam:
       config:
         - subnet: {{ nm.net_admin }}
-          ip_range: {{ [nm.net_admin | ipnet_hostaddr(nm.start_ip[nm.net_admin] + nm.net_admin_hosts.index('opnfv_infra_config_pxe_admin_address') +1), nm.net_admin.split("/")[-1]] | join("/") }}
   mgmt:
     driver: macvlan
     driver_opts:
@@ -62,4 +63,3 @@ networks:
     ipam:
       config:
         - subnet: {{ nm.net_mgmt }}
-          ip_range: {{ [nm.net_mgmt | ipnet_hostaddr(nm.start_ip[nm.net_mgmt] + nm.net_mgmt_hosts.index('opnfv_infra_config_address') +1), nm.net_mgmt.split("/")[-1]] | join("/") }}
index 02ada44..5b09c29 100644 (file)
@@ -114,7 +114,9 @@ function docker_install {
     fi
   fi
   # Distro-provided docker-compose might be simply broken (Ubuntu 16.04, CentOS 7)
-  if ! docker-compose --version > /dev/null 2>&1; then
+  if ! docker-compose --version > /dev/null 2>&1 || \
+      [ "$(docker-compose version --short | tr -d '.')" -lt 1220 ] && \
+      [ "$(uname -m)" = 'x86_64' ]; then
     COMPOSE_BIN="${image_dir}/docker-compose"
     COMPOSE_VERSION='1.22.0'
     notify_n "[WARN] Using docker-compose ${COMPOSE_VERSION} in ${COMPOSE_BIN}" 3
index 634a933..561f2c4 100644 (file)
@@ -412,7 +412,7 @@ function prepare_containers {
   local image_dir=$1
   [ -n "${image_dir}" ] || exit 1
   [ -n "${MCP_REPO_ROOT_PATH}" ] || exit 1
-  docker-compose --version > /dev/null 2>&1 || COMPOSE_PREFIX="${image_dir}/"
+  [ ! -e "${image_dir}/docker-compose" ] || COMPOSE_PREFIX="${image_dir}/"
 
   "${COMPOSE_PREFIX}docker-compose" -f docker-compose/docker-compose.yaml down
   if [[ ! "${MCP_DOCKER_TAG}" =~ 'verify' ]]; then
@@ -426,7 +426,7 @@ function prepare_containers {
 function start_containers {
   local image_dir=$1
   [ -n "${image_dir}" ] || exit 1
-  docker-compose --version > /dev/null 2>&1 || COMPOSE_PREFIX="${image_dir}/"
+  [ ! -e "${image_dir}/docker-compose" ] || COMPOSE_PREFIX="${image_dir}/"
   "${COMPOSE_PREFIX}docker-compose" -f docker-compose/docker-compose.yaml up -d
 }