From 91df4825e74cbf0fc2e0b75160e4d5af7bbeed52 Mon Sep 17 00:00:00 2001
From: Ricardo Rocha <rocha.porto@gmail.com>
Date: Fri, 31 Mar 2017 17:05:15 +0200
Subject: [PATCH] [cern] enable cvmfs in swarm mode

setup docker-volume-cvmfs in all nodes, including the master nodes.
swarm mode schedules services and containers in any of the manager or
workers, so we should enable it everywhere.
---
 .../templates/fragments/configure-cvmfs.sh    |  2 +-
 .../swarm_mode_template_def.py                |  2 +-
 .../templates/cluster.yaml                    | 19 +++++++++++++++
 .../templates/swarmmaster.yaml                | 23 ++++++++++++++++++-
 .../templates/swarmnode.yaml                  | 23 +++++++++++++++++++
 5 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/magnum/drivers/common/templates/fragments/configure-cvmfs.sh b/magnum/drivers/common/templates/fragments/configure-cvmfs.sh
index 740afa669..f52cbbc72 100644
--- a/magnum/drivers/common/templates/fragments/configure-cvmfs.sh
+++ b/magnum/drivers/common/templates/fragments/configure-cvmfs.sh
@@ -10,7 +10,7 @@ chattr -i /
 mkdir /cvmfs
 chattr +i /
 
-atomic install gitlab-registry.cern.ch/cloud-infrastructure/docker-volume-cvmfs:${CVMFS_TAG}
+atomic install gitlab-registry.cern.ch/cloud-infrastructure/docker-volume-cvmfs:${CVMFS_TAG:-latest}
 
 # add selinux policy
 docker cp docker-volume-cvmfs:/dockercvmfs.pp /tmp
diff --git a/magnum/drivers/swarm_fedora_atomic_v2/swarm_mode_template_def.py b/magnum/drivers/swarm_fedora_atomic_v2/swarm_mode_template_def.py
index da895cc3b..a53fe94f5 100644
--- a/magnum/drivers/swarm_fedora_atomic_v2/swarm_mode_template_def.py
+++ b/magnum/drivers/swarm_fedora_atomic_v2/swarm_mode_template_def.py
@@ -88,7 +88,7 @@ class SwarmModeTemplateDefinition(template_def.BaseTemplateDefinition):
         osc = self.get_osc(context)
         extra_params['magnum_url'] = osc.magnum_url()
 
-        label_list = ['rexray_preempt', 'swarm_strategy']
+        label_list = ['rexray_preempt', 'swarm_strategy', 'cvmfs_enabled', 'cvmfs_tag']
 
         extra_params['auth_url'] = context.auth_url
 
diff --git a/magnum/drivers/swarm_fedora_atomic_v2/templates/cluster.yaml b/magnum/drivers/swarm_fedora_atomic_v2/templates/cluster.yaml
index c8fc72050..cea6ba3aa 100644
--- a/magnum/drivers/swarm_fedora_atomic_v2/templates/cluster.yaml
+++ b/magnum/drivers/swarm_fedora_atomic_v2/templates/cluster.yaml
@@ -183,6 +183,19 @@ parameters:
       other hosts are using the volume
     default: "false"
 
+  cvmfs_enabled:
+    type: boolean
+    description: >
+      Indicates whether cvmfs support should be enabled in the cluster.
+    default: true
+
+  cvmfs_tag:
+    type: string
+    description: >
+      The tag to use for the docker-volume-cvmfs container.
+    default: "latest"
+
+
   is_primary_master:
     type: boolean
     default: True
@@ -228,6 +241,8 @@ resources:
           auth_url: {get_param: auth_url}
           volume_driver: {get_param: volume_driver}
           rexray_preempt: {get_param: rexray_preempt}
+          cvmfs_enabled: {get_param: cvmfs_enabled}
+          cvmfs_tag: {get_param: cvmfs_tag}
 
   swarm_secondary_masters:
     type: "OS::Heat::ResourceGroup"
@@ -259,6 +274,8 @@ resources:
           auth_url: {get_param: auth_url}
           volume_driver: {get_param: volume_driver}
           rexray_preempt: {get_param: rexray_preempt}
+          cvmfs_enabled: {get_param: cvmfs_enabled}
+          cvmfs_tag: {get_param: cvmfs_tag}
 
   swarm_nodes:
     type: "OS::Heat::ResourceGroup"
@@ -291,6 +308,8 @@ resources:
           auth_url: {get_param: auth_url}
           volume_driver: {get_param: volume_driver}
           rexray_preempt: {get_param: rexray_preempt}
+          cvmfs_enabled: {get_param: cvmfs_enabled}
+          cvmfs_tag: {get_param: cvmfs_tag}
 
 outputs:
 
diff --git a/magnum/drivers/swarm_fedora_atomic_v2/templates/swarmmaster.yaml b/magnum/drivers/swarm_fedora_atomic_v2/templates/swarmmaster.yaml
index 8c24c7090..d52a0c82c 100644
--- a/magnum/drivers/swarm_fedora_atomic_v2/templates/swarmmaster.yaml
+++ b/magnum/drivers/swarm_fedora_atomic_v2/templates/swarmmaster.yaml
@@ -114,6 +114,18 @@ parameters:
       other hosts are using the volume
     default: "false"
 
+  cvmfs_enabled:
+    type: boolean
+    description: >
+      Indicates whether cvmfs support should be enabled in the cluster.
+    default: true
+
+  cvmfs_tag:
+    type: string
+    description: >
+      The tag to use for the docker-volume-cvmfs container.
+    default: "latest"
+
   is_primary_master:
     type: boolean
     description: whether this master is primary or not
@@ -168,6 +180,8 @@ resources:
             "$AUTH_URL": {get_param: auth_url}
             "$VOLUME_DRIVER": {get_param: volume_driver}
             "$REXRAY_PREEMPT": {get_param: rexray_preempt}
+            "$CVMFS_ENABLED": {get_param: cvmfs_enabled}
+            "$CVMFS_TAG": {get_param: cvmfs_tag}
 
   remove_docker_key:
     type: "OS::Heat::SoftwareConfig"
@@ -185,6 +199,12 @@ resources:
             $configure_docker_storage_driver: {get_file: ../../common/templates/fragments/configure_docker_storage_driver_atomic.sh}
           template: {get_file: ../../common/templates/fragments/configure-docker-storage.sh}
 
+  configure_docker_cvmfs:
+    type: "OS::Heat::SoftwareConfig"
+    properties:
+      group: ungrouped
+      config: {get_file: ../../common/templates/fragments/configure-cvmfs.sh}
+
   make_cert:
     type: "OS::Heat::SoftwareConfig"
     properties:
@@ -277,8 +297,9 @@ resources:
         - config: {get_resource: enable_services}
         - config: {get_resource: install_cern_certs}
         - config: {get_resource: write_swarm_master_service}
-        - config: {get_resource: cfn_signal}
         - config: {get_resource: volume_service}
+        - config: {get_resource: configure_docker_cvmfs}
+        - config: {get_resource: cfn_signal}
 
   ######################################################################
   #
diff --git a/magnum/drivers/swarm_fedora_atomic_v2/templates/swarmnode.yaml b/magnum/drivers/swarm_fedora_atomic_v2/templates/swarmnode.yaml
index 14d91027c..41c831abc 100644
--- a/magnum/drivers/swarm_fedora_atomic_v2/templates/swarmnode.yaml
+++ b/magnum/drivers/swarm_fedora_atomic_v2/templates/swarmnode.yaml
@@ -109,6 +109,19 @@ parameters:
       other hosts are using the volume
     default: "false"
 
+  cvmfs_enabled:
+    type: boolean
+    description: >
+      Indicates whether cvmfs support should be enabled in the cluster.
+    default: true
+
+  cvmfs_tag:
+    type: string
+    description: >
+      The tag to use for the docker-volume-cvmfs container.
+    default: "latest"
+
+
 resources:
 
   node_wait_handle:
@@ -157,6 +170,8 @@ resources:
             "$AUTH_URL": {get_param: auth_url}
             "$VOLUME_DRIVER": {get_param: volume_driver}
             "$REXRAY_PREEMPT": {get_param: rexray_preempt}
+            "$CVMFS_ENABLED": {get_param: cvmfs_enabled}
+            "$CVMFS_TAG": {get_param: cvmfs_tag}
 
   remove_docker_key:
     type: "OS::Heat::SoftwareConfig"
@@ -164,6 +179,12 @@ resources:
       group: ungrouped
       config: {get_file: ../../common/templates/swarm/fragments/remove-docker-key.sh}
 
+  configure_docker_cvmfs:
+    type: "OS::Heat::SoftwareConfig"
+    properties:
+      group: ungrouped
+      config: {get_file: ../../common/templates/fragments/configure-cvmfs.sh}
+
   make_cert:
     type: "OS::Heat::SoftwareConfig"
     properties:
@@ -255,6 +276,8 @@ resources:
         - config: {get_resource: write_swarm_agent_service}
         - config: {get_resource: cfn_signal}
         - config: {get_resource: volume_service}
+        - config: {get_resource: configure_docker_cvmfs}
+        - config: {get_resource: cfn_signal}
 
   # do NOT use "_" (underscore) in the Nova server name
   # it creates a mismatch between the generated Nova name and its hostname
-- 
GitLab