Skip to content

Commit

Permalink
Updates to fix PGSQL for PGSM (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumar-vs authored Dec 19, 2024
1 parent 19ea786 commit 204660f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions pmm_qa/pdpgsql_pgsm_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
client_version: "{{ lookup('vars', 'extra_client_version', default=lookup('env','CLIENT_VERSION') | default('3-dev-latest', true) ) }}"
admin_password: "{{ lookup('vars', 'extra_admin_password', default=lookup('env','ADMIN_PASSWORD') | default('admin', true) ) }}"
pmm_qa_branch: "{{ lookup('vars', 'extra_pmm_qa_branch', default=lookup('env','PMM_QA_GIT_BRANCH') | default('main', true) ) }}"
pgstat_monitor_branch: "{{ lookup('vars', 'extra_pgstat_monitor_branch', default=lookup('env','PGSTAT_MONITOR_BRANCH') | default('1.1.1', true) ) }}"
pgstat_monitor_branch: "{{ lookup('vars', 'extra_pgstat_monitor_branch', default=lookup('env','PGSTAT_MONITOR_BRANCH') | default('2.1.0', true) ) }}"
pgstat_monitor_repo: "{{ lookup('vars', 'extra_pgstat_monitor_repo', default=lookup('env','PGSTAT_MONITOR_REPO') | default('percona/pg_stat_monitor', true) ) }}"
use_socket: "{{ lookup('vars', 'extra_pdpgsql_version', default=lookup('env','USE_SOCKET') | default('', true) ) }}"
distribution: "{{ lookup('vars', 'extra_pdpgsql_distribution', default=lookup('env','DISTRIBUTION') | default('PPG', true) ) }}"

tasks:
- name: cleanup container for client and DB setup
Expand Down Expand Up @@ -45,7 +46,7 @@
- name: Execute Setup script inside the pdpgsql pdpgsql_pgsm_container
shell: "{{ item }}"
with_items:
- docker exec {{ pdpgsql_pgsm_container }} bash -xe ./pg_stat_monitor_setup.sh --distribution PPG --pgsql_version {{ pdpgsql_version }} --pgstat_monitor_branch {{ pgstat_monitor_branch }} --pgstat_monitor_repo {{ pgstat_monitor_repo }} > setup_pdpgsql_pgsm_{{ pdpgsql_version }}.log
- docker exec {{ pdpgsql_pgsm_container }} bash -xe ./pg_stat_monitor_setup.sh --distribution {{ distribution }} --pgsql_version {{ pdpgsql_version }} --pgstat_monitor_branch {{ pgstat_monitor_branch }} --pgstat_monitor_repo {{ pgstat_monitor_repo }} > setup_pdpgsql_pgsm_{{ pdpgsql_version }}.log

- name: Install pmm2-client on the pdpgsql_pgsm_container
shell: "{{ item }}"
Expand Down
2 changes: 1 addition & 1 deletion pmm_qa/pg_stat_monitor_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fi
# If branch/tag is not provided then it will default to main branch
if [ -z "$pgstat_monitor_branch" ]
then
export pgstat_monitor_branch="1.1.1"
export pgstat_monitor_branch="2.1.0"
fi

# If repo is not provided then it will default to percona PGSM repository
Expand Down
9 changes: 6 additions & 3 deletions pmm_qa/pmm-framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def setup_pdpgsql(db_type, db_version=None, db_config=None, args=None):
'CLIENT_VERSION': get_value('CLIENT_VERSION', db_type, args, db_config),
'USE_SOCKET': get_value('USE_SOCKET', db_type, args, db_config),
'ADMIN_PASSWORD': os.getenv('ADMIN_PASSWORD') or args.pmm_server_password or 'admin',
'DISTRIBUTION': '',
'PMM_QA_GIT_BRANCH': os.getenv('PMM_QA_GIT_BRANCH') or 'v3'
}

Expand Down Expand Up @@ -335,17 +336,19 @@ def setup_pgsql(db_type, db_version=None, db_config=None, args=None):

# Define environment variables for playbook
env_vars = {
'PGSQL_VERSION': pgsql_version,
'PDPGSQL_VERSION': pgsql_version,
'PGSTAT_MONITOR_BRANCH': 'main',
'PMM_SERVER_IP': args.pmm_server_ip or container_name or '127.0.0.1',
'PGSQL_PGSS_CONTAINER': 'pgsql_pgss_pmm_' + str(pgsql_version),
'PDPGSQL_PGSM_CONTAINER': 'pgsql_pgsm_pmm_' + str(pgsql_version),
'CLIENT_VERSION': get_value('CLIENT_VERSION', db_type, args, db_config),
'USE_SOCKET': get_value('USE_SOCKET', db_type, args, db_config),
'ADMIN_PASSWORD': os.getenv('ADMIN_PASSWORD') or args.pmm_server_password or 'admin',
'DISTRIBUTION': 'PGDG',
'PMM_QA_GIT_BRANCH': os.getenv('PMM_QA_GIT_BRANCH') or 'v3'
}

# Ansible playbook filename
playbook_filename = 'pgsql_pgss_setup.yml'
playbook_filename = 'pdpgsql_pgsm_setup.yml'

# Call the function to run the Ansible playbook
run_ansible_playbook(playbook_filename, env_vars, args)
Expand Down

0 comments on commit 204660f

Please sign in to comment.