Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Zookeeper (to version 3.5.8) #1897

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-0.9.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- [#1854](https://github.com/epiphany-platform/epiphany/issues/1854) - Upgrade RabbitMQ to the latest version (3.8.9)
- [#1137](https://github.com/epiphany-platform/epiphany/issues/1137) - Upgrade Kafka to 2.6.0
- [#1855](https://github.com/epiphany-platform/epiphany/issues/1855) - Upgrade Docker to v19.03.14
- [#1853](https://github.com/epiphany-platform/epiphany/issues/1853) - Upgrade Zookeeper to 3.5.8

### Breaking changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ https://github.com/danielqsj/kafka_exporter/releases/download/v1.2.0/kafka_expor
https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz
https://github.com/prometheus/prometheus/releases/download/v2.10.0/prometheus-2.10.0.linux-amd64.tar.gz
https://github.com/prometheus/alertmanager/releases/download/v0.17.0/alertmanager-0.17.0.linux-amd64.tar.gz
https://archive.apache.org/dist/zookeeper/zookeeper-3.4.12/zookeeper-3.4.12.tar.gz
https://archive.apache.org/dist/zookeeper/zookeeper-3.5.8/apache-zookeeper-3.5.8-bin.tar.gz
https://archive.apache.org/dist/ignite/2.7.6/apache-ignite-2.7.6-bin.zip
https://releases.hashicorp.com/vault/1.4.0/vault_1.4.0_linux_amd64.zip
https://get.helm.sh/helm-v3.2.0-linux-amd64.tar.gz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ https://github.com/danielqsj/kafka_exporter/releases/download/v1.2.0/kafka_expor
https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz
https://github.com/prometheus/prometheus/releases/download/v2.10.0/prometheus-2.10.0.linux-amd64.tar.gz
https://github.com/prometheus/alertmanager/releases/download/v0.17.0/alertmanager-0.17.0.linux-amd64.tar.gz
https://archive.apache.org/dist/zookeeper/zookeeper-3.4.12/zookeeper-3.4.12.tar.gz
https://archive.apache.org/dist/zookeeper/zookeeper-3.5.8/apache-zookeeper-3.5.8-bin.tar.gz
https://archive.apache.org/dist/ignite/2.7.6/apache-ignite-2.7.6-bin.zip
https://releases.hashicorp.com/vault/1.4.0/vault_1.4.0_linux_amd64.zip
https://get.helm.sh/helm-v3.2.0-linux-amd64.tar.gz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ kubernetes-cni 0.8.6-00
[files]
https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.14.0/jmx_prometheus_javaagent-0.14.0.jar
https://archive.apache.org/dist/kafka/2.6.0/kafka_2.12-2.6.0.tgz
https://archive.apache.org/dist/zookeeper/zookeeper-3.4.12/zookeeper-3.4.12.tar.gz
https://archive.apache.org/dist/zookeeper/zookeeper-3.5.8/apache-zookeeper-3.5.8-bin.tar.gz
https://github.com/danielqsj/kafka_exporter/releases/download/v1.2.0/kafka_exporter-1.2.0.linux-amd64.tar.gz
https://github.com/prometheus/alertmanager/releases/download/v0.17.0/alertmanager-0.17.0.linux-amd64.tar.gz
https://github.com/prometheus/haproxy_exporter/releases/download/v0.10.0/haproxy_exporter-0.10.0.linux-amd64.tar.gz
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: Include defaults from zookeeper role
include_vars:
file: roles/zookeeper/defaults/main.yml
name: zookeeper_defaults

- name: Include pre-flight checks
include_tasks: zookeeper/preflight-check.yml

- name: Get installed Zookeeper's version
stat:
path: /opt/zookeeper
to-bar marked this conversation as resolved.
Show resolved Hide resolved
register: linked_zookeeper

- name: Set installed Zookeeper version as fact
set_fact:
before_upgrade_zookeeper_version: "{{ linked_zookeeper.stat.lnk_target | regex_search('[\\d+]\\.[\\d+]\\.[\\d+]') }}"
to-bar marked this conversation as resolved.
Show resolved Hide resolved

- name: Upgrade Zookeeper if newer version is available
block:
- name: Stop Zookeeper service
service:
name: zookeeper
state: stopped

- name: Include upgrade Zookeeper task
include_tasks: zookeeper/install-upgrade.yml
when:
- before_upgrade_zookeeper_version is version( zookeeper_defaults.zookeeper_version, '<' )
to-bar marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---

- name: Download Zookeeper binaries
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first three tasks are the same as in zookeeper role. This can be done in the future but I would opt for reusing common tasks (as we have for example for Docker).

include_role:
name: download
tasks_from: download_file
vars:
file_name: "{{ zookeeper_defaults.zookeeper_bin_filename }}"

- name: Create Zookeeper directories
become: yes
file:
path: "/opt/zookeeper-{{ zookeeper_defaults.zookeeper_version }}"
recurse: yes
owner: "{{ zookeeper_defaults.zookeeper_user }}"
group: "{{ zookeeper_defaults.zookeeper_group }}"
mode: u=rwx,g=rx,o=rx
state: directory

- name: Uncompress Zookeeper installation file
unarchive:
remote_src: yes
src: "{{ download_directory }}/{{ zookeeper_defaults.zookeeper_bin_filename }}"
dest: /opt/zookeeper-{{ zookeeper_defaults.zookeeper_version }}
creates: "/opt/zookeeper-{{ zookeeper_defaults.zookeeper_version }}/bin"
extra_opts: [--strip-components=1]
mode: u=rwx,g=rx,o=rx
owner: "{{ zookeeper_defaults.zookeeper_user }}"
group: "{{ zookeeper_defaults.zookeeper_group }}"

- name: Copy configuration from previous version
copy:
remote_src: yes
src: /opt/zookeeper/conf/
dest: /opt/zookeeper-{{ zookeeper_defaults.zookeeper_version }}/conf
mode: preserve

- name: Link /opt/zookeeper to recently installed version
file:
dest: /opt/zookeeper
state: link
src: /opt/zookeeper-{{ zookeeper_defaults.zookeeper_version }}
force: yes

- name: Remove previous version binaries
file:
path: /opt/zookeeper-{{ before_upgrade_zookeeper_version }}
state: absent

- name: Improve Zookeeper service and run zookeeper service using symbolic link instead of versioned path
to-bar marked this conversation as resolved.
Show resolved Hide resolved
lineinfile:
path: /lib/systemd/system/zookeeper.service
state: present
regexp: '^ExecStart=/opt/zookeeper-.*'
line: "ExecStart=/opt/zookeeper/bin/zkServer.sh start-foreground"

- name: Check if any snapshots exists in data dir what is necessary in order to run zookeeper after upgrade
find:
paths: "{{ zookeeper_defaults.zookeeper_data_dir }}/version-2"
patterns: 'snapshot*.'
to-bar marked this conversation as resolved.
Show resolved Hide resolved
use_regex: yes
register: snapshot_exists

# From 3.5.5 version, ZooKeeper is not able to start when no snapshot files present, what is valid scenario in 3.4.X version. Empty snapshot downloaded from Zookeeper's Jira ticket.
- name: Copy empty snapshot if not exists
copy:
dest: "{{ zookeeper_defaults.zookeeper_data_dir }}/version-2"
src: roles/zookeeper/files/snapshot.0
to-bar marked this conversation as resolved.
Show resolved Hide resolved
mode: u=rw,g=r,o=r
owner: "{{ zookeeper_defaults.zookeeper_user }}"
group: "{{ zookeeper_defaults.zookeeper_group }}"
when: snapshot_exists.matched == 0

- name: Start Zookeeper service
systemd:
name: zookeeper
state: started
daemon-reload: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: Check if Zookeeper is installed in default location
stat:
path: /opt/zookeeper/bin/zkServer.sh
to-bar marked this conversation as resolved.
Show resolved Hide resolved
register: zookeeper_exec_file

- name: Assert Zookeeper location
assert:
that:
- zookeeper_exec_file.stat.exists
fail_msg: Zookeeper not found in /opt/zookeeper (Epiphany default) - check your configuration
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---

zookeeper_version: 3.5.8
zookeeper_bin_filename: "apache-zookeeper-3.5.8-bin.tar.gz"

zookeeper_hosts: "{{ groups['zookeeper'] }}"

zookeeper_data_dir: /var/lib/zookeeper
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
# Zookeeper tasks - resides on masters

- name: Create Zookeeper group
group:
Expand Down Expand Up @@ -30,19 +29,18 @@
path: "{{ prometheus_jmx_path }}"
register: exporter

- name: Set zookeeper variable with version name
- name: Set Zookeeper variable with version name
set_fact:
zookeeper_name: "zookeeper-{{ specification.version }}"
zookeeper_name: "zookeeper-{{ zookeeper_version }}"
changed_when: false

- name: Set zookeeper install dir for {{ zookeeper_name }}
- name: Set Zookeeper install dir for {{ zookeeper_name }}
set_fact:
zookeeper_install_dir: "/opt/{{ zookeeper_name }}"
changed_when: false

- name: Set Zookeeper file name to install
set_fact:
zookeeper_file_name: "{{ specification.file_name }}"
zookeeper_file_name: "{{ zookeeper_bin_filename }}"

- name: Download Zookeeper binaries
include_role:
Expand All @@ -58,7 +56,7 @@
recurse: yes
owner: "{{ zookeeper_user }}"
group: "{{ zookeeper_group }}"
mode: 0750
mode: u=rwx,g=rx,o=
state: directory
with_items:
- "{{ zookeeper_install_dir }}"
Expand All @@ -71,7 +69,7 @@
dest: "{{ zookeeper_install_dir }}"
creates: "{{ zookeeper_install_dir }}/bin"
extra_opts: [--strip-components=1]
mode: 0755
mode: u=rwx,g=rx,o=rx
owner: "{{ zookeeper_user }}"
group: "{{ zookeeper_group }}"
check_mode: false
Expand All @@ -88,7 +86,7 @@
- "{{ zookeeper_install_dir }}/conf"
- "/etc/zookeeper/conf"

- name: Create zookeeper service
- name: Create Zookeeper service
template:
src: zookeeper.service.j2
dest: /lib/systemd/system/zookeeper.service
Expand Down Expand Up @@ -116,14 +114,11 @@
- name: Link /opt/zookeeper to the right version
file: path=/opt/zookeeper state=link src="{{ zookeeper_install_dir }}"

# - name: Link /etc/zookeeper/conf to /opt/zookeeper/config
# file: path=/etc/zookeeper/conf state=link src=/opt/zookeeper/conf

- name: Add Zookeeper's bin dir to the PATH
copy:
content: "export PATH=$PATH:/opt/zookeeper/bin"
dest: "/etc/profile.d/zookeeper_path.sh"
mode: 0755
mode: u=rwx,g=rx,o=rx

- name: Update the log4j config with saner production values
template:
Expand All @@ -145,4 +140,3 @@

- include_tasks: metrics.yml
when: exporter.stat.exists

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Group={{ zookeeper_group }}
{% if exporter.stat.exists %}
Environment="SERVER_JVMFLAGS=-javaagent:{{ prometheus_jmx_path }}={{ prometheus_jmx_exporter_web_listen_port }}:{{ prometheus_jmx_config }}"
{% endif %}
ExecStart={{zookeeper_install_dir}}/bin/zkServer.sh start-foreground
ExecStart=/opt/zookeeper/bin/zkServer.sh start-foreground
Restart=always
RestartSec=3

Expand Down
Empty file.
9 changes: 9 additions & 0 deletions core/src/epicli/data/common/ansible/playbooks/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@
name: upgrade
tasks_from: kibana

- hosts: zookeeper
serial: 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required?

become: true
become_method: sudo
tasks:
- import_role:
name: upgrade
tasks_from: zookeeper

- hosts: kafka
serial: 1
become: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kind: configuration/jmx-exporter
title: "JMX exporter"
name: default
specification:
file_name: "jmx_prometheus_javaagent-0.12.0.jar"
file_name: "jmx_prometheus_javaagent-0.14.0.jar"
jmx_path: /opt/jmx-exporter/jmx_prometheus_javaagent.jar # Changing it requires also change for same variable in Kafka and Zookeeper configs. # Todo Zookeeper and Kafka to use this variable
jmx_jars_directory: /opt/jmx-exporter/jars
jmx_exporter_user: jmx-exporter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
kind: configuration/zookeeper
title: "Zookeeper"
name: default
specification:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic! 👍😍

version: 3.4.12
file_name: "zookeeper-3.4.12.tar.gz"
specification: {}
2 changes: 1 addition & 1 deletion docs/home/COMPONENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Note that versions are default versions and can be changed in certain cases thro
| Flannel | 0.12.0 | https://github.com/coreos/flannel/ | [Apache License](https://www.apache.org/licenses/LICENSE-1.0) |
| Canal | 3.15.0 | https://github.com/projectcalico/calico | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
| Kafka | 2.6.0 | https://github.com/apache/kafka | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
| Zookeeper | 3.4.12 | https://github.com/apache/zookeeper | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
| Zookeeper | 3.5.8 | https://github.com/apache/zookeeper | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
| RabbitMQ | 3.8.9 | https://github.com/rabbitmq/rabbitmq-server | [Mozilla Public License](https://www.mozilla.org/en-US/MPL/) |
| Docker CE | 19.03.14 | https://github.com/docker/docker-ce/ | [Apache License](https://www.apache.org/licenses/LICENSE-1.0) |
| KeyCloak | 9.0.0 | https://github.com/keycloak/keycloak | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
Expand Down