This repository has been archived by the owner on Jun 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 276
Check config before deploy or rolling_update #917
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
|
||
- name: Load PD vars | ||
include_vars: file={{ playbook_dir }}/roles/pd/defaults/main.yml | ||
|
||
- name: "Load customized config: tidb-ansible/conf/pd.yml" | ||
include_vars: file={{ playbook_dir }}/conf/pd.yml name=pd_conf_custom | ||
|
||
- name: Load default config | ||
include_vars: file={{ playbook_dir }}/roles/pd/vars/default.yml name=pd_conf_default | ||
|
||
- name: Generate dynamic config | ||
set_fact: | ||
pd_conf_generated: | ||
replication: | ||
location-labels: "{{ location_labels }}" | ||
security: | ||
cacert-path: >- | ||
{%- if enable_tls|default(false) -%}{{ pd_cert_dir }}/ca.pem{%- else -%}{%- endif -%} | ||
cert-path: >- | ||
{%- if enable_tls|default(false) -%}{{ pd_cert_dir }}/pd-server-{{ pd_host }}.pem{%- else -%}{%- endif -%} | ||
key-path: >- | ||
{%- if enable_tls|default(false) -%}{{ pd_cert_dir }}/pd-server-{{ pd_host }}-key.pem{%- else -%}{%- endif -%} | ||
|
||
- name: Generate final config | ||
set_fact: | ||
pd_conf: "{{ pd_conf_custom | with_default_dicts(pd_conf_generated, pd_conf_default) }}" | ||
|
||
- name: Create configuration file | ||
template: src={{ playbook_dir }}/roles/pd/templates/pd.toml.j2 dest={{ tidb_check_dir }}/pd.toml mode=0644 backup=yes | ||
register: pd_conf_st | ||
|
||
- name: Deploy PD binary | ||
copy: src="{{ resources_dir }}/bin/pd-server" dest="{{ tidb_check_dir }}/" mode=0755 backup=yes | ||
|
||
- name: Check PD config | ||
shell: cd {{ tidb_check_dir }} && ./pd-server -config ./pd.toml -config-check | ||
register: pd_check_result | ||
|
||
- name: Check result | ||
fail: | ||
msg: "PD config error" | ||
when: "'successful' not in pd_check_result.stdout" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
|
||
- name: Load TiDB vars | ||
include_vars: file={{ playbook_dir }}/roles/tidb/defaults/main.yml | ||
|
||
- name: "Load customized config: tidb-ansible/conf/tidb.yml" | ||
include_vars: file={{ playbook_dir }}/conf/tidb.yml name=tidb_conf_custom | ||
|
||
- name: Load default config | ||
include_vars: file={{ playbook_dir }}/roles/tidb/vars/default.yml name=tidb_conf_default | ||
|
||
- name: generate dynamic config | ||
set_fact: | ||
tidb_conf_generated: | ||
security: | ||
cluster-ssl-ca: >- | ||
{%- if enable_tls|default(false) -%}{{ tidb_cert_dir }}/ca.pem{%- else -%}{%- endif -%} | ||
cluster-ssl-cert: >- | ||
{%- if enable_tls|default(false) -%}{{ tidb_cert_dir }}/tidb-server-{{ tidb_host }}.pem{%- else -%}{%- endif -%} | ||
cluster-ssl-key: >- | ||
{%- if enable_tls|default(false) -%}{{ tidb_cert_dir }}/tidb-server-{{ tidb_host }}-key.pem{%- else -%}{%- endif -%} | ||
|
||
- name: Generate final config | ||
set_fact: | ||
tidb_conf: "{{ tidb_conf_custom | with_default_dicts(tidb_conf_generated, tidb_conf_default) }}" | ||
|
||
- name: Create configuration file | ||
template: src={{ playbook_dir }}/roles/tidb/templates/tidb.toml.j2 dest={{ tidb_check_dir }}/tidb.toml mode=0644 backup=yes | ||
|
||
- name: Deploy TiDB binary | ||
copy: src="{{ resources_dir }}/bin/tidb-server" dest="{{ tidb_check_dir }}/" mode=0755 backup=yes | ||
|
||
- name: Check TiDB config | ||
shell: cd {{ tidb_check_dir }} && ./tidb-server -config ./tidb.toml -config-check | ||
register: tidb_check_result | ||
|
||
- name: Check result | ||
fail: | ||
msg: "TiDB config error" | ||
when: "'successful' not in tidb_check_result.stdout" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
|
||
- name: Load TiKV vars | ||
include_vars: file={{ playbook_dir }}/roles/tikv/defaults/main.yml | ||
|
||
- name: "Load customized config: tidb-ansible/conf/tikv.yml" | ||
include_vars: file={{ playbook_dir }}/conf/tikv.yml name=tikv_conf_custom | ||
|
||
- name: Load default config | ||
include_vars: file={{ playbook_dir }}/roles/tikv/vars/default.yml name=tikv_conf_default | ||
|
||
- name: generate dynamic config | ||
set_fact: | ||
tikv_conf_generated: | ||
server: | ||
labels: "{{ labels }}" | ||
rocksdb: | ||
wal-dir: "{{ wal_dir }}" | ||
raftstore: | ||
raftdb-path: "{{ raftdb_path }}" | ||
security: | ||
ca-path: >- | ||
{%- if enable_tls|default(false) -%}{{ tikv_cert_dir }}/ca.pem{%- else -%}{%- endif -%} | ||
cert-path: >- | ||
{%- if enable_tls|default(false) -%}{{ tikv_cert_dir }}/tikv-server-{{ tikv_host }}.pem{%- else -%}{%- endif -%} | ||
key-path: >- | ||
{%- if enable_tls|default(false) -%}{{ tikv_cert_dir }}/tikv-server-{{ tikv_host }}-key.pem{%- else -%}{%- endif -%} | ||
|
||
- name: Generate final config | ||
set_fact: | ||
tikv_conf: "{{ tikv_conf_custom | with_default_dicts(tikv_conf_generated, tikv_conf_default) }}" | ||
|
||
- name: Create configuration file | ||
template: src={{ playbook_dir }}/roles/tikv/templates/tikv.toml.j2 dest={{ tidb_check_dir }}/tikv.toml mode=0644 backup=yes | ||
|
||
- name: Deploy TiKV binary | ||
copy: src="{{ resources_dir }}/bin/tikv-server" dest="{{ tidb_check_dir }}/" mode=0755 backup=yes | ||
|
||
- name: Check TiKV config | ||
shell: cd {{ tidb_check_dir }} && ./tikv-server --pd-endpoints pd:port --config ./tikv.toml --config-check | ||
register: tikv_check_result | ||
|
||
- name: Check result | ||
fail: | ||
msg: "TiKV config error" | ||
when: "'successful' not in tikv_check_result.stdout" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
|
||
- set_fact: | ||
tidb_check_dir: "/tmp/tidb_check_config" | ||
|
||
- name: Create temporary check directory | ||
file: name={{ tidb_check_dir }} state=directory | ||
|
||
- name: Check PD config | ||
include_tasks: check_pd_config.yml | ||
|
||
- name: Check TiKV config | ||
include_tasks: check_tikv_config.yml | ||
|
||
- name: Check TiDB config | ||
include_tasks: check_tidb_config.yml | ||
|
||
- name: Delete temporary check directory | ||
file: name={{ tidb_check_dir }} state=absent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this run after deploy new binary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check run before deployment. If errors are checked after deployment, the configuration needs to be reupdated after modification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it have some error because the old version did not have the check command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not happen, this check is to distribute the new binary and configuration files to a temporary directory to check