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

Support Inject cluster topology information for am and grafana to etcd in pd #1124

Merged
merged 29 commits into from
Feb 25, 2020

Conversation

mapleFU
Copy link
Contributor

@mapleFU mapleFU commented Jan 18, 2020

This pr is related to this technical design: https://docs.google.com/document/d/10YvHeWeXyWbCIbqXJ_TsGV5pwPXJOaOjE8whd4JSJVE/edit

It want to write address of tidb/grafana/tikv into pd using etcd v3 api. It will be done in start and rolling_update phase.

@@ -168,6 +168,12 @@
pd_cert_dir: "{{ pd_cert_dir }}"
when: pd_leader_name == pd_name

- name: init pd cluster topology
delegate_to: localhost
shell: "python init-pd-topo.py --pd_host {{ pd_host }} --pd_port {{ pd_port }} --tidb_host {{ tidb_host }} --tidb_port {{ tidb_port }} --grafana_host {{ grafana_host }} --grafana_port {{ grafana_port }} --alertmanager_host {{ alertmanager_host }} --alertmanager_port {{ alertmanager_port }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

In this way, no information other than the pd node can be obtained.

@liubo0127
Copy link
Contributor

Does it need to delete related information from PD through API when deleting nodes?

@mapleFU
Copy link
Contributor Author

mapleFU commented Jan 19, 2020

Does it need to delete related information from PD through API when deleting nodes?

  • If the server is down or close, it will not change.
  • If you call ansible-playbook rolling_update.yml or redeploy it, it will change the nodes.

@mapleFU mapleFU changed the title Support Inject cluster information to etcd in pd [DNM] Support Inject cluster information to etcd in pd Jan 19, 2020
@liubo0127
Copy link
Contributor

Does it need to delete related information from PD through API when deleting nodes?

  • If the server is down or close, it will not change.
  • If you call ansible-playbook rolling_update.yml or redeploy it, it will change the nodes.

How to delete the information stored in PD if a node is deleted from the cluster.

@mapleFU
Copy link
Contributor Author

mapleFU commented Jan 19, 2020

Does it need to delete related information from PD through API when deleting nodes?

  • If the server is down or close, it will not change.
  • If you call ansible-playbook rolling_update.yml or redeploy it, it will change the nodes.

How to delete the information stored in PD if a node is deleted from the cluster.

Because the messages will be store in etcd api, we can visit and find it in dashboard. Ansible may not need to care about it.

start.yml Outdated Show resolved Hide resolved
@mapleFU mapleFU changed the title [DNM] Support Inject cluster information to etcd in pd Support Inject cluster information to etcd in pd Feb 5, 2020
@mapleFU
Copy link
Contributor Author

mapleFU commented Feb 5, 2020

I have tested this pr, and it can write value into pd's etcd now. You may see it in 172.16.6.62. Just visit it using:

ETCDCTL_API=3 etcdctl --endpoints="172.16.6.62:2379" get /topo/alertmanager

It's available.

"key": encoded_key,
"value": encoded_value,
})
req = urllib2.Request('http://' + etcd_url + '/v3/kv/put',
Copy link
Member

Choose a reason for hiding this comment

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

Will this break TLS deployment?

Copy link
Contributor

Choose a reason for hiding this comment

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

At present, this script does not support TLS, and it needs to be optimized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@breeswish @liubo0127 maybe we have 2 ways:

  • install etcd in pip and get it.
  • Using https.

roles/init_pd_topo/tasks/main.yml Outdated Show resolved Hide resolved
- name: generate init_pd_topo script
template:
src: "init_pd_topo.sh.j2"
dest: "{{ playbook_dir }}/scripts/init-pd-topo.sh"
Copy link
Member

Choose a reason for hiding this comment

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

Should this file being ignored?

Copy link
Contributor

Choose a reason for hiding this comment

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

It can't be ignored, it will be executed during start, rolling_update operation.

Copy link
Member

Choose a reason for hiding this comment

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

I mean should we put it in .gitignore since it is generated?

Copy link
Contributor

Choose a reason for hiding this comment

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

This script is generated when the cluster is deployed. I think it does not need to be added to .gitignore

{% set tidb_ip = hostvars[host].ansible_host | default(hostvars[host].inventory_hostname) -%}
{% set tidb_port = hostvars[host].tidb_port -%}
{% set tidb_path = hostvars[host].deploy_dir -%}
{% set _ = all_tidb.append("%s:%s%s" % (tidb_ip, tidb_port, tidb_path)) -%}
Copy link
Member

Choose a reason for hiding this comment

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

how would you parse the string when you put these together?

Copy link
Contributor

Choose a reason for hiding this comment

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

Parameter values are strings separated by ,.

roles/init_pd_topo/templates/init_pd_topo.sh.j2 Outdated Show resolved Hide resolved
mapleFU and others added 4 commits February 17, 2020 16:35
Signed-off-by: mapleFU <1506118561@qq.com>
Signed-off-by: mapleFU <1506118561@qq.com>

# Conflicts:
#	roles/dashboard-topo/templates/init_pd_topo.sh.j2
Signed-off-by: mapleFU <1506118561@qq.com>
# Conflicts:
#	excessive_rolling_update.yml
#	rolling_update.yml
Signed-off-by: mapleFU <1506118561@qq.com>
Signed-off-by: mapleFU <1506118561@qq.com>
Signed-off-by: mapleFU <1506118561@qq.com>
@mapleFU
Copy link
Contributor Author

mapleFU commented Feb 24, 2020

I've test it in "172.16.5.34"
the inventory.ini can be seen here: https://paste.ubuntu.com/p/DNmR53tHhx/

Signed-off-by: mapleFU <1506118561@qq.com>
Signed-off-by: mapleFU <1506118561@qq.com>
@mapleFU
Copy link
Contributor Author

mapleFU commented Feb 24, 2020

Now:

➜  ~ ETCDCTL_API=3 etcdctl --endpoints="172.16.5.34:2312" get /topology --prefix=true 
/topology/alertmanager
{"ip": "172.16.5.34", "binary_path": "/home/pingcap/mapleFU/data", "port": 9093}
/topology/grafana
{"ip": "172.16.5.34", "binary_path": "/home/pingcap/mapleFU/data", "port": 3000}

start.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@liubo0127 liubo0127 left a comment

Choose a reason for hiding this comment

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

LGTM

@mapleFU mapleFU changed the title Support Inject cluster information to etcd in pd Support Inject cluster topology information for am and grafana to etcd in pd Feb 25, 2020
@mapleFU mapleFU merged commit 4164929 into pingcap:master Feb 25, 2020
liubo0127 added a commit to liubo0127/tidb-ansible that referenced this pull request Mar 5, 2020
…d in pd (pingcap#1124)

* [Init] Initialize pr and create scripts for sending request to pd

* [ADD] adding scripts to yml

* [Replace] replacing with shell arguments

* [Try] trying to testing ansible

* [Update] Updating script

* update

* [FIX] fix wrong api

* Add deploy path

* [ADD] adding another logic loading

* [ADD] adding net/deploy

* add all pd info

* [Update] Change directory name and update etcd write path.

Signed-off-by: mapleFU <1506118561@qq.com>

* change init-pd-topo to dashboart topo

* [Update] Support `port` field.

Signed-off-by: mapleFU <1506118561@qq.com>

* [Fix] Fixing errors on scripts.

Signed-off-by: mapleFU <1506118561@qq.com>

* [Final] Trying to fix all the problems

Signed-off-by: mapleFU <1506118561@qq.com>

* [Update] update port type.

Signed-off-by: mapleFU <1506118561@qq.com>

* [FIX] fix bugs for tidb-anisble deploy dir

Signed-off-by: mapleFU <1506118561@qq.com>

* [Update] Wait until testing.

Signed-off-by: mapleFU <1506118561@qq.com>

* [Revert] Revert unnescessary changes.

Signed-off-by: mapleFU <1506118561@qq.com>

* [DONE] Finish dev.

Signed-off-by: mapleFU <1506118561@qq.com>

* Update start.yml

* Update start.yml

Co-authored-by: liubo <liubo0127@qq.com>
liubo0127 added a commit that referenced this pull request Mar 12, 2020
…rafana to etcd in pd (#1196)

* Support Inject cluster topology information for am and grafana to etcd in pd (#1124)

* [Init] Initialize pr and create scripts for sending request to pd

* [ADD] adding scripts to yml

* [Replace] replacing with shell arguments

* [Try] trying to testing ansible

* [Update] Updating script

* update

* [FIX] fix wrong api

* Add deploy path

* [ADD] adding another logic loading

* [ADD] adding net/deploy

* add all pd info

* [Update] Change directory name and update etcd write path.

Signed-off-by: mapleFU <1506118561@qq.com>

* change init-pd-topo to dashboart topo

* [Update] Support `port` field.

Signed-off-by: mapleFU <1506118561@qq.com>

* [Fix] Fixing errors on scripts.

Signed-off-by: mapleFU <1506118561@qq.com>

* [Final] Trying to fix all the problems

Signed-off-by: mapleFU <1506118561@qq.com>

* [Update] update port type.

Signed-off-by: mapleFU <1506118561@qq.com>

* [FIX] fix bugs for tidb-anisble deploy dir

Signed-off-by: mapleFU <1506118561@qq.com>

* [Update] Wait until testing.

Signed-off-by: mapleFU <1506118561@qq.com>

* [Revert] Revert unnescessary changes.

Signed-off-by: mapleFU <1506118561@qq.com>

* [DONE] Finish dev.

Signed-off-by: mapleFU <1506118561@qq.com>

* Update start.yml

* Update start.yml

Co-authored-by: liubo <liubo0127@qq.com>

* Support Prometheus in for dashboard topology (#1195)

* [Support] change tidb-ansible script in tidb-ansible.

Signed-off-by: mapleFU <1506118561@qq.com>

* [ADD] Adding supports in roles.

Signed-off-by: mapleFU <1506118561@qq.com>

* [Multiple] pass the first when there is multiple arguments.

Co-authored-by: mwish <1506118561@qq.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants