Vonng / pigsty

Free RDS for PostgreSQL —— Pigsty
https://pigsty.io
GNU Affero General Public License v3.0
3.38k stars 258 forks source link

Recommended to add a fool-proof design for node checking to control unnecessary operations #402

Closed AdamYLK closed 4 months ago

AdamYLK commented 5 months ago

For example, when executing the creation of a PGSQL node or cluster, due to the personnel quality issues of the R&D and operation and maintenance teams of small and medium-sized enterprises, it is very likely that the creation will not be completed before adding the nodes involved in the operation to pigsty for management. PGSQL or cluster, resulting in components such as pgbouncer not being created with business components first, which in turn caused the subsequent pgbouncer_exporter business to fail to be created.

Yes, you are right, i'm the guy just make this mistake

Vonng commented 5 months ago

There are two options for this purpose:

  1. also init node during bin/pgsql-add
  2. leave a mark file after node.yml and check it in pgsql.yml
Vonng commented 4 months ago

Will be implemented via an extra check in task pg_check:

#--------------------------------------------------------------#
# Check PostgreSQL Exists                             [pg_check]
#--------------------------------------------------------------#
- name: check postgres exists
  tags: pg_check
  block:

    # check node is managed by pigsty by the existence of ca.crt
    - name: check if node is managed by pigsty
      stat: path=/etc/pki/ca.crt
      register: check_ca_crt_result

    - name: ABORT due to install on unmanaged node
      when: not check_ca_crt_result.stat.exists
      connection: local
      any_errors_fatal: true
      ignore_errors: false
      fail:
        msg: >-
          Abort because the node {{ inventory_hostname }} seems not managed by pigsty, use ./node.yml to init node first.  

When run pgsql.yml on a node that is not inited by Pigsty, The result would be like:

fatal: [10.10.10.41]: FAILED! => {"changed": false, "msg": "Abort because the node 10.10.10.41 seems not managed by pigsty, use ./node.yml to init node first.  "}