Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
update config check and fix generate config error (#1013)
Browse files Browse the repository at this point in the history
* Modify config_check: each service to check separately. (#1012)

* Modify config_check: each service to check separately.

* fix generate config err
  • Loading branch information
liubo0127 authored Nov 1, 2019
1 parent 56f191f commit f820ebe
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 37 deletions.
20 changes: 17 additions & 3 deletions deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,26 @@
roles:
- check_config_dynamic

- name: Pre-check for configuration
- name: Pre-check PD configuration
hosts: pd_servers[0]
tags:
- check_config
- pd
roles:
- check_config_pd

- name: Pre-check TiKV configuration
hosts: tikv_servers[0]
tags:
- tikv
roles:
- check_config_tikv

- name: Pre-check TiDB configuration
hosts: tidb_servers[0]
tags:
- tidb
roles:
- check_config
- check_config_tidb

- name: deploying node_exporter
hosts: monitored_servers
Expand Down
20 changes: 17 additions & 3 deletions excessive_rolling_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,26 @@
- current_version.stdout_lines[0].replace(' ','').split(':')[1] < "v2.0.1"
- tidb_version >= "v2.1.0" or tidb_version == "latest"

- name: Pre-check for configuration
- name: Pre-check PD configuration
hosts: pd_servers[0]
tags:
- check_config
- pd
roles:
- check_config_pd

- name: Pre-check TiKV configuration
hosts: tikv_servers[0]
tags:
- tikv
roles:
- check_config_tikv

- name: Pre-check TiDB configuration
hosts: tidb_servers[0]
tags:
- tidb
roles:
- check_config
- check_config_tidb

- hosts: pd_servers[0]
any_errors_fatal: true
Expand Down
7 changes: 7 additions & 0 deletions filter_plugins/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def with_default_dicts(d, *args):
ret.update([(k, arg[k]) for k in arg if k not in ret])
return ret

def update_default_dicts(d):
ret = copy.deepcopy(d) or {}
if ret:
ret.update([(k, update_default_dicts(ret[k])) for k in ret if isinstance(ret[k], (dict, type(None)))])
return ret

def dictsort_by_value_type(d):
vals = list(d.items())
return sorted(vals, key=lambda p: (isinstance(p[1], dict), p[0], p[1]))
Expand All @@ -37,6 +43,7 @@ def filters(self):
return {
'epoch_time_diff': epoch_time_diff,
'with_default_dicts': with_default_dicts,
'update_default_dicts': update_default_dicts,
'dictsort_by_value_type': dictsort_by_value_type,
'tikv_server_labels_format': tikv_server_labels_format,
}
19 changes: 0 additions & 19 deletions roles/check_config/tasks/main.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
---

- set_fact:
tidb_check_dir: "/tmp/tidb_check_config"

- name: Create temporary check directory
file: name={{ tidb_check_dir }} state=directory

- name: Load PD vars
include_vars: file={{ playbook_dir }}/roles/pd/defaults/main.yml name=pd_vars_check

Expand All @@ -24,7 +30,7 @@
- name: Generate final config
set_fact:
pd_conf: "{{ pd_conf_custom_check | with_default_dicts(pd_conf_generated_check, pd_conf_default_check) }}"
pd_conf: "{{ pd_conf_custom_check | with_default_dicts(pd_conf_generated_check, pd_conf_default_check) | update_default_dicts }}"

- name: Create configuration file
template: src={{ playbook_dir }}/roles/pd/templates/pd.toml.j2 dest={{ tidb_check_dir }}/pd.toml mode=0644 backup=yes
Expand All @@ -36,6 +42,9 @@
shell: cd {{ tidb_check_dir }} && ./pd-server -config ./pd.toml -config-check
register: pd_check_result

- name: Delete temporary check directory
file: name={{ tidb_check_dir }} state=absent

- name: Check result
fail:
msg: "PD config error"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
---

- set_fact:
tidb_check_dir: "/tmp/tidb_check_config"

- name: Create temporary check directory
file: name={{ tidb_check_dir }} state=directory

- name: Load TiDB default vars
include_vars: file={{ playbook_dir }}/roles/tidb/defaults/main.yml name=tidb_vars_check

Expand All @@ -25,7 +31,7 @@
- name: Generate final config
set_fact:
tidb_conf: "{{ tidb_conf_custom_check | with_default_dicts(tidb_conf_generated_check, tidb_conf_default_check) }}"
tidb_conf: "{{ tidb_conf_custom_check | with_default_dicts(tidb_conf_generated_check, tidb_conf_default_check) | update_default_dicts }}"

- name: Create configuration file
template: src={{ playbook_dir }}/roles/tidb/templates/tidb.toml.j2 dest={{ tidb_check_dir }}/tidb.toml mode=0644 backup=yes
Expand All @@ -37,6 +43,9 @@
shell: cd {{ tidb_check_dir }} && ./tidb-server -config ./tidb.toml -config-check
register: tidb_check_result

- name: Delete temporary check directory
file: name={{ tidb_check_dir }} state=absent

- name: Check result
fail:
msg: "TiDB config error"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
---

- set_fact:
tidb_check_dir: "/tmp/tidb_check_config"

- name: Create temporary check directory
file: name={{ tidb_check_dir }} state=directory

- set_fact:
tikv_log_dir: "{{ deploy_dir }}/log"

Expand Down Expand Up @@ -31,7 +37,7 @@
- name: Generate final config
set_fact:
tikv_conf: "{{ tikv_conf_custom_check | with_default_dicts(tikv_conf_generated_check, tikv_conf_default_check) }}"
tikv_conf: "{{ tikv_conf_custom_check | with_default_dicts(tikv_conf_generated_check, tikv_conf_default_check) | update_default_dicts }}"

- name: Create configuration file
template: src={{ playbook_dir }}/roles/tikv/templates/tikv.toml.j2 dest={{ tidb_check_dir }}/tikv.toml mode=0644 backup=yes
Expand All @@ -43,6 +49,9 @@
shell: cd {{ tidb_check_dir }} && ./tikv-server --pd-endpoints pd:port --config ./tikv.toml --config-check
register: tikv_check_result

- name: Delete temporary check directory
file: name={{ tidb_check_dir }} state=absent

- name: Check result
fail:
msg: "TiKV config error"
Expand Down
2 changes: 1 addition & 1 deletion roles/pd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
- name: generate final config
set_fact:
pd_conf: "{{ pd_conf_custom | with_default_dicts(pd_conf_generated, pd_conf_default) }}"
pd_conf: "{{ pd_conf_custom | with_default_dicts(pd_conf_generated, pd_conf_default) | update_default_dicts }}"

- debug: var=pd_conf

Expand Down
2 changes: 1 addition & 1 deletion roles/pump/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
- name: generate final config
set_fact:
pump_conf: "{{ pump_conf_custom | with_default_dicts(pump_conf_generated, pump_conf_default) }}"
pump_conf: "{{ pump_conf_custom | with_default_dicts(pump_conf_generated, pump_conf_default) | update_default_dicts }}"

- debug: var=pump_conf

Expand Down
2 changes: 1 addition & 1 deletion roles/tidb/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
- name: combine final config
set_fact:
tidb_conf: "{{ tidb_conf_generated | with_default_dicts(tidb_conf_custom, tidb_conf_default) }}"
tidb_conf: "{{ tidb_conf_generated | with_default_dicts(tidb_conf_custom, tidb_conf_default) | update_default_dicts }}"

- debug: var=tidb_conf

Expand Down
2 changes: 1 addition & 1 deletion roles/tidb_lightning/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

- name: generate tidb-lightning final config
set_fact:
tidb_lightning_conf: "{{ tidb_lightning_conf_custom | with_default_dicts(tidb_lightning_conf_generated, tidb_lightning_conf_default) }}"
tidb_lightning_conf: "{{ tidb_lightning_conf_custom | with_default_dicts(tidb_lightning_conf_generated, tidb_lightning_conf_default) | update_default_dicts }}"

- debug: var=tidb_lightning_conf

Expand Down
2 changes: 1 addition & 1 deletion roles/tikv/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
- name: generate final config
set_fact:
tikv_conf: "{{ tikv_conf_custom | with_default_dicts(tikv_conf_generated, tikv_conf_default) }}"
tikv_conf: "{{ tikv_conf_custom | with_default_dicts(tikv_conf_generated, tikv_conf_default) | update_default_dicts }}"

- debug: var=tikv_conf

Expand Down
2 changes: 1 addition & 1 deletion roles/tikv_importer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- name: generate tikv-importer final config
set_fact:
tikv_importer_conf: "{{ tikv_importer_conf_custom | with_default_dicts(tikv_importer_conf_generated, tikv_importer_conf_default) }}"
tikv_importer_conf: "{{ tikv_importer_conf_custom | with_default_dicts(tikv_importer_conf_generated, tikv_importer_conf_default) | update_default_dicts }}"

- debug: var=tikv_importer_conf

Expand Down
20 changes: 17 additions & 3 deletions rolling_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,26 @@
- current_version.stdout_lines[0].replace(' ','').split(':')[1] < "v2.0.1"
- tidb_version >= "v2.1.0" or tidb_version == "latest"

- name: Pre-check for configuration
- name: Pre-check PD configuration
hosts: pd_servers[0]
tags:
- check_config
- pd
roles:
- check_config_pd

- name: Pre-check TiKV configuration
hosts: tikv_servers[0]
tags:
- tikv
roles:
- check_config_tikv

- name: Pre-check TiDB configuration
hosts: tidb_servers[0]
tags:
- tidb
roles:
- check_config
- check_config_tidb

- hosts: pd_servers[0]
any_errors_fatal: true
Expand Down

0 comments on commit f820ebe

Please sign in to comment.