Add upgrade stuff for Redis
Add upgrade stuff for Redis to support common OpenStack way
for services upgrade from Pike to Queens, since Redis is bumping from
3 to 5 version.
Related-Prod: PROD-34434
Change-Id: I0eb3fc21197ce08dec3059fee959ac2dab95b15b
diff --git a/redis/meta/salt.yml b/redis/meta/salt.yml
new file mode 100644
index 0000000..16651f4
--- /dev/null
+++ b/redis/meta/salt.yml
@@ -0,0 +1,5 @@
+orchestration:
+ upgrade:
+ applications:
+ redis:
+ priority: 1800
\ No newline at end of file
diff --git a/redis/server.sls b/redis/server.sls
index 23707f4..c511d8e 100755
--- a/redis/server.sls
+++ b/redis/server.sls
@@ -26,5 +26,7 @@
- name: {{ server.service }}
- watch:
- file: {{ server.conf_dir }}/redis.conf
+ - require:
+ - pkg: redis_packages
{%- endif %}
diff --git a/redis/upgrade/pkgs_latest.sls b/redis/upgrade/pkgs_latest.sls
new file mode 100644
index 0000000..20d226d
--- /dev/null
+++ b/redis/upgrade/pkgs_latest.sls
@@ -0,0 +1,19 @@
+{%- from "redis/map.jinja" import server with context %}
+{%- from "redis/map.jinja" import cluster with context %}
+
+redis_task_pkgs_latest:
+ test.show_notification:
+ - name: "dump_message_pkgs_latest"
+ - text: "Running redis.upgrade.pkg_latest"
+
+{%- if server.enabled %}
+redis_server_latest_packages:
+ pkg.latest:
+ - names: {{ server.pkgs }}
+{%- endif %}
+
+{%- if server.enabled %}
+redis_cluster_latest_packages:
+ pkg.latest:
+ - names: {{ cluster.pkgs }}
+{%- endif %}
diff --git a/redis/upgrade/post/init.sls b/redis/upgrade/post/init.sls
new file mode 100644
index 0000000..8f3f8dc
--- /dev/null
+++ b/redis/upgrade/post/init.sls
@@ -0,0 +1,5 @@
+
+redis_post:
+ test.show_notification:
+ - name: "dump_message_post-upgrade"
+ - text: "Running redis.upgrade.post"
diff --git a/redis/upgrade/pre/init.sls b/redis/upgrade/pre/init.sls
new file mode 100644
index 0000000..0917804
--- /dev/null
+++ b/redis/upgrade/pre/init.sls
@@ -0,0 +1,5 @@
+
+redis_pre:
+ test.show_notification:
+ - name: "dump_message_pre-upgrade"
+ - text: "Running redis.upgrade.pre"
diff --git a/redis/upgrade/service_stopped.sls b/redis/upgrade/service_stopped.sls
new file mode 100644
index 0000000..352f3cf
--- /dev/null
+++ b/redis/upgrade/service_stopped.sls
@@ -0,0 +1,25 @@
+{%- from "redis/map.jinja" import server with context %}
+{%- from "redis/map.jinja" import cluster with context %}
+
+redis_task_service_stopped:
+ test.show_notification:
+ - name: "dump_message_service_stopped_redis"
+ - text: "Running redis.upgrade.service_stopped"
+
+{# Stop services only in case major Redis version upgrade #}
+{%- set currentVer = salt['cmd.run']("redis-cli -v | awk '{print $2}'") %}
+{%- if not currentVer.startswith(server.version|string) %}
+ {%- if server.get('enabled') %}
+redis_server_stopped:
+ service.dead:
+ - enable: false
+ - name: {{ server.service }}
+ {%- endif %}
+
+ {%- if cluster.get('enabled') %}
+redis_cluster_stopped:
+ service.dead:
+ - enable: false
+ - name: {{ cluster.service }}
+ {%- endif %}
+{%- endif %}
\ No newline at end of file
diff --git a/redis/upgrade/upgrade/init.sls b/redis/upgrade/upgrade/init.sls
new file mode 100644
index 0000000..76f372a
--- /dev/null
+++ b/redis/upgrade/upgrade/init.sls
@@ -0,0 +1,12 @@
+{%- from "redis/map.jinja" import server with context %}
+{%- from "redis/map.jinja" import cluster with context %}
+
+redis_upgrade:
+ test.show_notification:
+ - name: "dump_message_upgrade_redis"
+ - text: "Running redis.upgrade.upgrade"
+
+include:
+ - redis.upgrade.service_stopped
+ - redis.upgrade.pkgs_latest
+ - redis
\ No newline at end of file
diff --git a/redis/upgrade/verify/init.sls b/redis/upgrade/verify/init.sls
new file mode 100644
index 0000000..f0e82b1
--- /dev/null
+++ b/redis/upgrade/verify/init.sls
@@ -0,0 +1,4 @@
+redis_upgrade_verify:
+ test.show_notification:
+ - name: "dump_message_upgrade_redis_verify"
+ - text: "Running redis.upgrade.verify"
diff --git a/tests/pip_requirements.txt b/tests/pip_requirements.txt
new file mode 100644
index 0000000..37b4d97
--- /dev/null
+++ b/tests/pip_requirements.txt
@@ -0,0 +1,2 @@
+jsonschema
+setuptools<45.0.0
\ No newline at end of file
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 4a7ce6e..7fd7c65 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -47,7 +47,6 @@
virtualenv $VENV_DIR
source ${VENV_DIR}/bin/activate
python -m pip install salt${PIP_SALT_VERSION}
- python -m pip install jsonschema
if [[ -f ${CURDIR}/pip_requirements.txt ]]; then
python -m pip install -r ${CURDIR}/pip_requirements.txt
fi