From bbb9626eef7b0b882f4f987e8b8e98a8ff5c034c Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 5 Feb 2024 16:29:30 -0600 Subject: [PATCH 01/11] Revert "Build vites is the last exec is not clean" This reverts commit d50c1ed41d47f853bfab8975e04d58334f401ec8. --- ansible/roles/vitess_build/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/roles/vitess_build/tasks/main.yml b/ansible/roles/vitess_build/tasks/main.yml index b7fe13af5..769528a92 100644 --- a/ansible/roles/vitess_build/tasks/main.yml +++ b/ansible/roles/vitess_build/tasks/main.yml @@ -22,7 +22,7 @@ - name: Update Vitess become: yes become_user: root - when: commit_previous_exec != vitess_git_version or not clean_previous_exec | bool + when: commit_previous_exec != vitess_git_version block: - name: Fetch Updated Vitess include_tasks: install_vitess.yml From c34d5c4b909903fac453cb64024f409c633eded1 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 5 Feb 2024 16:29:40 -0600 Subject: [PATCH 02/11] Revert "Revert async" This reverts commit 38819c6590972944f96aa5e7657b0fb4cc6669e0. --- ansible/roles/vtgate/tasks/main.yml | 43 ++++++++- ansible/roles/vttablet/tasks/main.yml | 125 +++++++++++++++++++++++++- 2 files changed, 164 insertions(+), 4 deletions(-) diff --git a/ansible/roles/vtgate/tasks/main.yml b/ansible/roles/vtgate/tasks/main.yml index db015f3f7..0974193f9 100644 --- a/ansible/roles/vtgate/tasks/main.yml +++ b/ansible/roles/vtgate/tasks/main.yml @@ -35,11 +35,50 @@ name: "vtgate" tasks_from: systemd -- name: install config files - include_tasks: vtgate.yml +- name: ensure vtgate directory + become: yes + become_user: root + loop: '{{ gateways }}' + loop_control: + loop_var: gateway + async: 600 + poll: 0 + file: + state: directory + path: '{{ vitess_root }}/tmp/vtgate-{{ gateway.id }}' + owner: '{{ vitess_user }}' + group: '{{ vitess_group }}' + +- name: install config + become: yes + become_user: root loop: '{{ gateways }}' loop_control: loop_var: gateway + async: 600 + poll: 0 + template: + src: 'vtgate.conf.j2' + dest: '/etc/vitess/conf/vtgate-{{ gateway.id }}.conf' + owner: '{{ vitess_user }}' + group: '{{ vitess_group }}' + mode: '0644' + +- name: start vtgate + become: yes + become_user: root + loop: '{{ gateways }}' + loop_control: + loop_var: gateway + async: 600 + poll: 0 + when: + - enable_vtgate | bool + service: + name: 'vtgate@{{ gateway.id }}' + enabled: yes + state: started + changed_when: false - name: Turn on loadbalancing vars: diff --git a/ansible/roles/vttablet/tasks/main.yml b/ansible/roles/vttablet/tasks/main.yml index 94a140e2c..ea674ca83 100644 --- a/ansible/roles/vttablet/tasks/main.yml +++ b/ansible/roles/vttablet/tasks/main.yml @@ -33,9 +33,130 @@ - name: install systemd units include_tasks: systemd.yml -- name: Install config files - include_tasks: vttablet.yml +- name: ensure vttablet directory + become: yes + become_user: root + loop: '{{ tablets }}' + loop_control: + loop_var: tablet + async: 600 + poll: 0 + file: + state: directory + path: '{{ vitess_root }}/tmp/vttablet-{{ tablet.id }}' + owner: '{{ vitess_user }}' + group: '{{ vitess_group }}' + +- name: install vttablet config + become: yes + become_user: root loop: '{{ tablets }}' loop_control: loop_var: tablet + async: 600 + poll: 0 + template: + src: 'vttablet.conf.j2' + dest: '/etc/vitess/conf/vttablet-{{ tablet.id }}.conf' + owner: '{{ vitess_user }}' + group: '{{ vitess_group }}' + mode: '0644' +- name: install extra cnf config + become: yes + become_user: root + loop: '{{ tablets }}' + loop_control: + loop_var: tablet + async: 600 + poll: 0 + template: + src: 'extra_my.cnf.j2' + dest: '/etc/vitess/extra_my{{ tablet.id }}.cnf' + owner: '{{ vitess_user }}' + group: '{{ vitess_group }}' + mode: '0644' + +- name: start mysqlctld + become: yes + become_user: root + loop: '{{ tablets }}' + loop_control: + loop_var: tablet + async: 600 + poll: 0 + when: + - enable_vttablet | bool + service: + name: 'mysqlctld@{{ tablet.id }}' + enabled: yes + state: started + changed_when: false + +- name: start mysqld exporter + become: yes + become_user: root + loop: '{{ tablets }}' + loop_control: + loop_var: tablet + async: 600 + poll: 0 + when: + - enable_vttablet | bool + service: + name: 'mysqld_exporter@{{ tablet.id }}' + enabled: yes + state: started + changed_when: false + +- name: wait for mysql socket + become: yes + become_user: root + loop: '{{ tablets }}' + loop_control: + loop_var: tablet + async: 600 + poll: 0 + when: + - enable_vttablet | bool + wait_for: + path: '{{ vitess_root }}/socket/mysql{{ tablet.id }}.sock' + delay: 5 + timeout: 60 + state: present + msg: "mysql socket needs to be present {{ vitess_root }}/socket/mysql{{ tablet.id }}.sock" + ignore_errors: true + +- name: wait for mysqlctl socket + become: yes + become_user: root + loop: '{{ tablets }}' + loop_control: + loop_var: tablet + async: 600 + poll: 0 + when: + - enable_vttablet | bool + wait_for: + path: '{{ vitess_root }}/socket/mysqlctl{{ tablet.id }}.sock' + delay: 5 + timeout: 60 + state: present + msg: "mysqlctl socket needs to be present at {{ vitess_root }}/socket/mysqlctl{{ tablet.id }}.sock" + ignore_errors: true + +- name: start vttablet + become: yes + become_user: root + loop: '{{ tablets }}' + loop_control: + loop_var: tablet + async: 600 + poll: 0 + when: + - enable_vttablet | bool + service: + name: 'vttablet@{{ tablet.id }}' + enabled: yes + state: started + changed_when: false \ No newline at end of file From d8a4e3583c38b139c193a1d57dc596ca63553951 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 5 Feb 2024 16:29:48 -0600 Subject: [PATCH 03/11] Revert "Remove unrequired loop" This reverts commit af9560f0edfef79dcb1580a60a4272bfd319b624. --- ansible/roles/vttablet/tasks/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ansible/roles/vttablet/tasks/main.yml b/ansible/roles/vttablet/tasks/main.yml index ea674ca83..deb349504 100644 --- a/ansible/roles/vttablet/tasks/main.yml +++ b/ansible/roles/vttablet/tasks/main.yml @@ -55,6 +55,9 @@ loop_var: tablet async: 600 poll: 0 + with_items: + - s: extra_my.cnf + d: '/etc/vitess/extra_my{{ tablet.id }}.cnf' template: src: 'vttablet.conf.j2' dest: '/etc/vitess/conf/vttablet-{{ tablet.id }}.conf' From 1fec025090caf0a8138c3b41f8ce86cc1b25ad8b Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 5 Feb 2024 16:29:54 -0600 Subject: [PATCH 04/11] Revert "Move step with file outside of play create_cluster" This reverts commit 1755663ad7d03fe09cc3d5db42d5c4c4563a8849. --- ansible/create_cluster.yml | 10 ++++++++++ ansible/roles/vitess_build/tasks/main.yml | 9 --------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ansible/create_cluster.yml b/ansible/create_cluster.yml index 29246a410..29988292b 100644 --- a/ansible/create_cluster.yml +++ b/ansible/create_cluster.yml @@ -31,6 +31,16 @@ vars: - etcd_launch: True +- hosts: all + name: ensure vitess tmp directory + become: yes + become_user: root + file: + state: directory + path: '{{ vitess_root }}/tmp' + owner: '{{ vitess_user }}' + group: '{{ vitess_group }}' + - hosts: vtctld roles: - role: vtctld diff --git a/ansible/roles/vitess_build/tasks/main.yml b/ansible/roles/vitess_build/tasks/main.yml index 769528a92..16ae07226 100644 --- a/ansible/roles/vitess_build/tasks/main.yml +++ b/ansible/roles/vitess_build/tasks/main.yml @@ -10,15 +10,6 @@ # limitations under the License. --- -- name: ensure vitess tmp directory - become: yes - become_user: root - file: - state: directory - path: '{{ vitess_root }}/tmp' - owner: '{{ vitess_user }}' - group: '{{ vitess_group }}' - - name: Update Vitess become: yes become_user: root From 3fa6c7d2a2664a977ed933f14454abf2f46c188f Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 5 Feb 2024 16:30:00 -0600 Subject: [PATCH 05/11] Revert "Remove loops inside loops" This reverts commit 712099dabbbec6152b6138043df0192122a739b0. --- ansible/create_cluster.yml | 10 ---- ansible/roles/vtgate/tasks/main.yml | 26 +++++---- ansible/roles/vttablet/tasks/main.yml | 81 ++++++++++----------------- 3 files changed, 46 insertions(+), 71 deletions(-) diff --git a/ansible/create_cluster.yml b/ansible/create_cluster.yml index 29988292b..29246a410 100644 --- a/ansible/create_cluster.yml +++ b/ansible/create_cluster.yml @@ -31,16 +31,6 @@ vars: - etcd_launch: True -- hosts: all - name: ensure vitess tmp directory - become: yes - become_user: root - file: - state: directory - path: '{{ vitess_root }}/tmp' - owner: '{{ vitess_user }}' - group: '{{ vitess_group }}' - - hosts: vtctld roles: - role: vtctld diff --git a/ansible/roles/vtgate/tasks/main.yml b/ansible/roles/vtgate/tasks/main.yml index 0974193f9..a6dac6ef8 100644 --- a/ansible/roles/vtgate/tasks/main.yml +++ b/ansible/roles/vtgate/tasks/main.yml @@ -35,17 +35,20 @@ name: "vtgate" tasks_from: systemd -- name: ensure vtgate directory +- name: ensure vtgate directories become: yes become_user: root loop: '{{ gateways }}' loop_control: loop_var: gateway - async: 600 - poll: 0 + async: 600 # Maximum time to wait for all tasks to complete in seconds + poll: 0 # Polling interval, 0 means don't poll and wait for completion + with_items: + - '{{ vitess_root }}/tmp' + - '{{ vitess_root }}/tmp/vtgate-{{ gateway.id }}' file: state: directory - path: '{{ vitess_root }}/tmp/vtgate-{{ gateway.id }}' + path: '{{ item }}' owner: '{{ vitess_user }}' group: '{{ vitess_group }}' @@ -55,11 +58,14 @@ loop: '{{ gateways }}' loop_control: loop_var: gateway - async: 600 - poll: 0 + async: 600 # Maximum time to wait for all tasks to complete in seconds + poll: 0 # Polling interval, 0 means don't poll and wait for completion + with_items: + - s: vtgate.conf + d: '/etc/vitess/conf/vtgate-{{ gateway.id }}.conf' template: - src: 'vtgate.conf.j2' - dest: '/etc/vitess/conf/vtgate-{{ gateway.id }}.conf' + src: '{{ item.s }}.j2' + dest: '{{ item.d }}' owner: '{{ vitess_user }}' group: '{{ vitess_group }}' mode: '0644' @@ -70,8 +76,8 @@ loop: '{{ gateways }}' loop_control: loop_var: gateway - async: 600 - poll: 0 + async: 600 # Maximum time to wait for all tasks to complete in seconds + poll: 0 # Polling interval, 0 means don't poll and wait for completion when: - enable_vtgate | bool service: diff --git a/ansible/roles/vttablet/tasks/main.yml b/ansible/roles/vttablet/tasks/main.yml index deb349504..94713b2e3 100644 --- a/ansible/roles/vttablet/tasks/main.yml +++ b/ansible/roles/vttablet/tasks/main.yml @@ -33,83 +33,60 @@ - name: install systemd units include_tasks: systemd.yml -- name: ensure vttablet directory +- name: ensure vttablet directories become: yes become_user: root loop: '{{ tablets }}' loop_control: loop_var: tablet - async: 600 - poll: 0 + async: 600 # Maximum time to wait for all tasks to complete in seconds + poll: 0 # Polling interval, 0 means don't poll and wait for completion + with_items: + - '{{ vitess_root }}/tmp/' + - '{{ vitess_root }}/tmp/vttablet-{{ tablet.id }}' file: state: directory - path: '{{ vitess_root }}/tmp/vttablet-{{ tablet.id }}' + path: '{{ item }}' owner: '{{ vitess_user }}' group: '{{ vitess_group }}' -- name: install vttablet config +- name: install configs become: yes become_user: root loop: '{{ tablets }}' loop_control: loop_var: tablet - async: 600 - poll: 0 + async: 600 # Maximum time to wait for all tasks to complete in seconds + poll: 0 # Polling interval, 0 means don't poll and wait for completion with_items: + - s: vttablet.conf + d: '/etc/vitess/conf/vttablet-{{ tablet.id }}.conf' - s: extra_my.cnf d: '/etc/vitess/extra_my{{ tablet.id }}.cnf' template: - src: 'vttablet.conf.j2' - dest: '/etc/vitess/conf/vttablet-{{ tablet.id }}.conf' + src: '{{ item.s }}.j2' + dest: '{{ item.d }}' owner: '{{ vitess_user }}' group: '{{ vitess_group }}' mode: '0644' -- name: install extra cnf config +- name: start mysql become: yes become_user: root loop: '{{ tablets }}' loop_control: loop_var: tablet - async: 600 - poll: 0 - template: - src: 'extra_my.cnf.j2' - dest: '/etc/vitess/extra_my{{ tablet.id }}.cnf' - owner: '{{ vitess_user }}' - group: '{{ vitess_group }}' - mode: '0644' - -- name: start mysqlctld - become: yes - become_user: root - loop: '{{ tablets }}' - loop_control: - loop_var: tablet - async: 600 - poll: 0 + async: 600 # Maximum time to wait for all tasks to complete in seconds + poll: 0 # Polling interval, 0 means don't poll and wait for completion when: - enable_vttablet | bool service: - name: 'mysqlctld@{{ tablet.id }}' - enabled: yes - state: started - changed_when: false - -- name: start mysqld exporter - become: yes - become_user: root - loop: '{{ tablets }}' - loop_control: - loop_var: tablet - async: 600 - poll: 0 - when: - - enable_vttablet | bool - service: - name: 'mysqld_exporter@{{ tablet.id }}' + name: '{{ item }}' enabled: yes state: started + with_items: + - 'mysqlctld@{{ tablet.id }}' + - 'mysqld_exporter@{{ tablet.id }}' changed_when: false - name: wait for mysql socket @@ -118,8 +95,8 @@ loop: '{{ tablets }}' loop_control: loop_var: tablet - async: 600 - poll: 0 + async: 600 # Maximum time to wait for all tasks to complete in seconds + poll: 0 # Polling interval, 0 means don't poll and wait for completion when: - enable_vttablet | bool wait_for: @@ -136,8 +113,8 @@ loop: '{{ tablets }}' loop_control: loop_var: tablet - async: 600 - poll: 0 + async: 600 # Maximum time to wait for all tasks to complete in seconds + poll: 0 # Polling interval, 0 means don't poll and wait for completion when: - enable_vttablet | bool wait_for: @@ -154,12 +131,14 @@ loop: '{{ tablets }}' loop_control: loop_var: tablet - async: 600 - poll: 0 + async: 600 # Maximum time to wait for all tasks to complete in seconds + poll: 0 # Polling interval, 0 means don't poll and wait for completion when: - enable_vttablet | bool service: - name: 'vttablet@{{ tablet.id }}' + name: '{{ item }}' enabled: yes state: started + with_items: + - 'vttablet@{{ tablet.id }}' changed_when: false \ No newline at end of file From c12ebfa5215cb1b2231639fb39a5ec67ce533473 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 5 Feb 2024 16:30:11 -0600 Subject: [PATCH 06/11] Revert "Fix async poll" This reverts commit 55af9b06f09cc45de4e7811c1708c47c3d04a439. --- ansible/roles/vtgate/tasks/clean.yml | 2 + ansible/roles/vtgate/tasks/main.yml | 47 +---------- ansible/roles/vttablet/tasks/clean.yml | 2 + ansible/roles/vttablet/tasks/main.yml | 105 +------------------------ 4 files changed, 8 insertions(+), 148 deletions(-) diff --git a/ansible/roles/vtgate/tasks/clean.yml b/ansible/roles/vtgate/tasks/clean.yml index 775b3e1ed..00a90cf1e 100644 --- a/ansible/roles/vtgate/tasks/clean.yml +++ b/ansible/roles/vtgate/tasks/clean.yml @@ -18,6 +18,8 @@ loop: '{{ gateways }}' loop_control: loop_var: gateway + async: 600 # Maximum time to wait for all tasks to complete in seconds + poll: 0 # Polling interval, 0 means don't poll and wait for completion - name: remove old config become: yes diff --git a/ansible/roles/vtgate/tasks/main.yml b/ansible/roles/vtgate/tasks/main.yml index a6dac6ef8..926c66ddb 100644 --- a/ansible/roles/vtgate/tasks/main.yml +++ b/ansible/roles/vtgate/tasks/main.yml @@ -35,56 +35,13 @@ name: "vtgate" tasks_from: systemd -- name: ensure vtgate directories - become: yes - become_user: root - loop: '{{ gateways }}' - loop_control: - loop_var: gateway - async: 600 # Maximum time to wait for all tasks to complete in seconds - poll: 0 # Polling interval, 0 means don't poll and wait for completion - with_items: - - '{{ vitess_root }}/tmp' - - '{{ vitess_root }}/tmp/vtgate-{{ gateway.id }}' - file: - state: directory - path: '{{ item }}' - owner: '{{ vitess_user }}' - group: '{{ vitess_group }}' - -- name: install config - become: yes - become_user: root - loop: '{{ gateways }}' - loop_control: - loop_var: gateway - async: 600 # Maximum time to wait for all tasks to complete in seconds - poll: 0 # Polling interval, 0 means don't poll and wait for completion - with_items: - - s: vtgate.conf - d: '/etc/vitess/conf/vtgate-{{ gateway.id }}.conf' - template: - src: '{{ item.s }}.j2' - dest: '{{ item.d }}' - owner: '{{ vitess_user }}' - group: '{{ vitess_group }}' - mode: '0644' - -- name: start vtgate - become: yes - become_user: root +- name: install config files + include_tasks: vtgate.yml loop: '{{ gateways }}' loop_control: loop_var: gateway async: 600 # Maximum time to wait for all tasks to complete in seconds poll: 0 # Polling interval, 0 means don't poll and wait for completion - when: - - enable_vtgate | bool - service: - name: 'vtgate@{{ gateway.id }}' - enabled: yes - state: started - changed_when: false - name: Turn on loadbalancing vars: diff --git a/ansible/roles/vttablet/tasks/clean.yml b/ansible/roles/vttablet/tasks/clean.yml index 85584718b..c0baadebf 100644 --- a/ansible/roles/vttablet/tasks/clean.yml +++ b/ansible/roles/vttablet/tasks/clean.yml @@ -18,6 +18,8 @@ loop: '{{ all_tablets }}' loop_control: loop_var: tablet + async: 600 # Maximum time to wait for all tasks to complete in seconds + poll: 0 # Polling interval, 0 means don't poll and wait for completion - name: remove old config become: yes diff --git a/ansible/roles/vttablet/tasks/main.yml b/ansible/roles/vttablet/tasks/main.yml index 94713b2e3..80076b5ea 100644 --- a/ansible/roles/vttablet/tasks/main.yml +++ b/ansible/roles/vttablet/tasks/main.yml @@ -33,112 +33,11 @@ - name: install systemd units include_tasks: systemd.yml -- name: ensure vttablet directories - become: yes - become_user: root - loop: '{{ tablets }}' - loop_control: - loop_var: tablet - async: 600 # Maximum time to wait for all tasks to complete in seconds - poll: 0 # Polling interval, 0 means don't poll and wait for completion - with_items: - - '{{ vitess_root }}/tmp/' - - '{{ vitess_root }}/tmp/vttablet-{{ tablet.id }}' - file: - state: directory - path: '{{ item }}' - owner: '{{ vitess_user }}' - group: '{{ vitess_group }}' - -- name: install configs - become: yes - become_user: root - loop: '{{ tablets }}' - loop_control: - loop_var: tablet - async: 600 # Maximum time to wait for all tasks to complete in seconds - poll: 0 # Polling interval, 0 means don't poll and wait for completion - with_items: - - s: vttablet.conf - d: '/etc/vitess/conf/vttablet-{{ tablet.id }}.conf' - - s: extra_my.cnf - d: '/etc/vitess/extra_my{{ tablet.id }}.cnf' - template: - src: '{{ item.s }}.j2' - dest: '{{ item.d }}' - owner: '{{ vitess_user }}' - group: '{{ vitess_group }}' - mode: '0644' - -- name: start mysql - become: yes - become_user: root +- name: Install config files + include_tasks: vttablet.yml loop: '{{ tablets }}' loop_control: loop_var: tablet async: 600 # Maximum time to wait for all tasks to complete in seconds poll: 0 # Polling interval, 0 means don't poll and wait for completion - when: - - enable_vttablet | bool - service: - name: '{{ item }}' - enabled: yes - state: started - with_items: - - 'mysqlctld@{{ tablet.id }}' - - 'mysqld_exporter@{{ tablet.id }}' - changed_when: false -- name: wait for mysql socket - become: yes - become_user: root - loop: '{{ tablets }}' - loop_control: - loop_var: tablet - async: 600 # Maximum time to wait for all tasks to complete in seconds - poll: 0 # Polling interval, 0 means don't poll and wait for completion - when: - - enable_vttablet | bool - wait_for: - path: '{{ vitess_root }}/socket/mysql{{ tablet.id }}.sock' - delay: 5 - timeout: 60 - state: present - msg: "mysql socket needs to be present {{ vitess_root }}/socket/mysql{{ tablet.id }}.sock" - ignore_errors: true - -- name: wait for mysqlctl socket - become: yes - become_user: root - loop: '{{ tablets }}' - loop_control: - loop_var: tablet - async: 600 # Maximum time to wait for all tasks to complete in seconds - poll: 0 # Polling interval, 0 means don't poll and wait for completion - when: - - enable_vttablet | bool - wait_for: - path: '{{ vitess_root }}/socket/mysqlctl{{ tablet.id }}.sock' - delay: 5 - timeout: 60 - state: present - msg: "mysqlctl socket needs to be present at {{ vitess_root }}/socket/mysqlctl{{ tablet.id }}.sock" - ignore_errors: true - -- name: start vttablet - become: yes - become_user: root - loop: '{{ tablets }}' - loop_control: - loop_var: tablet - async: 600 # Maximum time to wait for all tasks to complete in seconds - poll: 0 # Polling interval, 0 means don't poll and wait for completion - when: - - enable_vttablet | bool - service: - name: '{{ item }}' - enabled: yes - state: started - with_items: - - 'vttablet@{{ tablet.id }}' - changed_when: false \ No newline at end of file From d7675e752944675410e9c4710fc1ebfb8aa45599 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 5 Feb 2024 16:30:19 -0600 Subject: [PATCH 07/11] Revert "Various improvements" This reverts commit 76cc4cbe3d65cb4d90853394e85d7aadff6ac540. --- ansible/create_cluster.yml | 3 ++ ansible/macrobench.yml | 2 +- ansible/roles/etcd/tasks/main.yml | 2 + ansible/roles/macrobench/tasks/main.yml | 5 ++ ansible/roles/sysbench/tasks/install.yml | 59 +++++++++++------------- ansible/roles/vtctld/tasks/main.yml | 1 + ansible/roles/vtgate/tasks/clean.yml | 2 - ansible/roles/vtgate/tasks/main.yml | 2 - ansible/roles/vttablet/tasks/clean.yml | 2 - ansible/roles/vttablet/tasks/main.yml | 5 +- 10 files changed, 41 insertions(+), 42 deletions(-) diff --git a/ansible/create_cluster.yml b/ansible/create_cluster.yml index 29246a410..506cebd6a 100644 --- a/ansible/create_cluster.yml +++ b/ansible/create_cluster.yml @@ -70,3 +70,6 @@ - name: Apply VSchema shell: | vtctlclient --server {{ groups['vtctld'][0] }}:15999 ApplyVSchema -- --vschema="$(cat /tmp/vschema_sysbench.json)" main + + - name: Print go version + debug: msg="VSchema is applied." \ No newline at end of file diff --git a/ansible/macrobench.yml b/ansible/macrobench.yml index a9aa1c52c..5ed71c749 100644 --- a/ansible/macrobench.yml +++ b/ansible/macrobench.yml @@ -43,7 +43,7 @@ gateway_targets: "{% set targets = [] -%}{% for host in groups['vtgate'] -%}{% for gateway in hostvars[host]['gateways'] -%}{{ targets.append( hostvars[host]['ansible_default_ipv4']['address']+':'+ (gateway.port | default(15001) | string )) }}{% endfor -%}{% endfor -%}{{ targets }}" vtctld_targets: "{% set targets = [] -%}{% for host in groups['vtctld'] -%}{{ targets.append( hostvars[host]['ansible_default_ipv4']['address']+':'+ (vtctld_port | default(15000) | string )) }}{% endfor -%}{{ targets }}" node_targets: "{% set targets= [] -%}{% for host in groups['all'] -%}{{ targets.append( hostvars[host]['ansible_default_ipv4']['address']+':9100' ) }}{% endfor -%}{{ targets }}" - prometheus_skip_install: true + prometheus_skip_install: false prometheus_version: 2.49.1 prometheus_global: scrape_interval: 15s diff --git a/ansible/roles/etcd/tasks/main.yml b/ansible/roles/etcd/tasks/main.yml index b5a2d39c9..20544eb42 100644 --- a/ansible/roles/etcd/tasks/main.yml +++ b/ansible/roles/etcd/tasks/main.yml @@ -10,6 +10,8 @@ # limitations under the License. --- +- include_tasks: clean.yml + - include_tasks: install.yml when: not etcd_launch | bool diff --git a/ansible/roles/macrobench/tasks/main.yml b/ansible/roles/macrobench/tasks/main.yml index 187c8fcaf..ea0001560 100644 --- a/ansible/roles/macrobench/tasks/main.yml +++ b/ansible/roles/macrobench/tasks/main.yml @@ -14,6 +14,11 @@ become: yes become_user: root block: + - name: Remove old arewefastyet + shell: | + rm -Rf /go/src/github.com/vitessio/arewefastyet + changed_when: false + - name: git clone arewefastyet git: repo: "{{ arewefastyet_git_repo }}" diff --git a/ansible/roles/sysbench/tasks/install.yml b/ansible/roles/sysbench/tasks/install.yml index b75b62624..069143a6e 100644 --- a/ansible/roles/sysbench/tasks/install.yml +++ b/ansible/roles/sysbench/tasks/install.yml @@ -10,36 +10,33 @@ # limitations under the License. --- -- name: Install Sysbench - when: install_sysbench is defined - block: - - name: Update Sysbench - become: yes - become_user: root - git: - repo: https://github.com/planetscale/sysbench - dest: /src/sysbench - version: master - depth: 1 - force: 1 +- name: Update Sysbench + become: yes + become_user: root + git: + repo: https://github.com/planetscale/sysbench + dest: /src/sysbench + version: master + depth: 1 + force: 1 - - name: Build sysbench - become: yes - become_user: root - shell: | - cd /src/sysbench - ./autogen.sh - ./configure - make -j - make install - changed_when: false +- name: Build sysbench + become: yes + become_user: root + shell: | + cd /src/sysbench + ./autogen.sh + ./configure + make -j + make install + changed_when: false - - name: Get tpcc - become: yes - become_user: root - git: - repo: https://github.com/planetscale/sysbench-tpcc - dest: /src/sysbench-tpcc - version: master - depth: 1 - force: 1 +- name: Get tpcc + become: yes + become_user: root + git: + repo: https://github.com/planetscale/sysbench-tpcc + dest: /src/sysbench-tpcc + version: master + depth: 1 + force: 1 diff --git a/ansible/roles/vtctld/tasks/main.yml b/ansible/roles/vtctld/tasks/main.yml index 5237b8332..582fef0d9 100644 --- a/ansible/roles/vtctld/tasks/main.yml +++ b/ansible/roles/vtctld/tasks/main.yml @@ -16,6 +16,7 @@ name: "vtctld" tasks_from: "clean" + - name: ensure vitess directories become: yes become_user: root diff --git a/ansible/roles/vtgate/tasks/clean.yml b/ansible/roles/vtgate/tasks/clean.yml index 00a90cf1e..775b3e1ed 100644 --- a/ansible/roles/vtgate/tasks/clean.yml +++ b/ansible/roles/vtgate/tasks/clean.yml @@ -18,8 +18,6 @@ loop: '{{ gateways }}' loop_control: loop_var: gateway - async: 600 # Maximum time to wait for all tasks to complete in seconds - poll: 0 # Polling interval, 0 means don't poll and wait for completion - name: remove old config become: yes diff --git a/ansible/roles/vtgate/tasks/main.yml b/ansible/roles/vtgate/tasks/main.yml index 926c66ddb..db015f3f7 100644 --- a/ansible/roles/vtgate/tasks/main.yml +++ b/ansible/roles/vtgate/tasks/main.yml @@ -40,8 +40,6 @@ loop: '{{ gateways }}' loop_control: loop_var: gateway - async: 600 # Maximum time to wait for all tasks to complete in seconds - poll: 0 # Polling interval, 0 means don't poll and wait for completion - name: Turn on loadbalancing vars: diff --git a/ansible/roles/vttablet/tasks/clean.yml b/ansible/roles/vttablet/tasks/clean.yml index c0baadebf..85584718b 100644 --- a/ansible/roles/vttablet/tasks/clean.yml +++ b/ansible/roles/vttablet/tasks/clean.yml @@ -18,8 +18,6 @@ loop: '{{ all_tablets }}' loop_control: loop_var: tablet - async: 600 # Maximum time to wait for all tasks to complete in seconds - poll: 0 # Polling interval, 0 means don't poll and wait for completion - name: remove old config become: yes diff --git a/ansible/roles/vttablet/tasks/main.yml b/ansible/roles/vttablet/tasks/main.yml index 80076b5ea..7c51b70de 100644 --- a/ansible/roles/vttablet/tasks/main.yml +++ b/ansible/roles/vttablet/tasks/main.yml @@ -33,11 +33,8 @@ - name: install systemd units include_tasks: systemd.yml -- name: Install config files +- name: install config files include_tasks: vttablet.yml loop: '{{ tablets }}' loop_control: loop_var: tablet - async: 600 # Maximum time to wait for all tasks to complete in seconds - poll: 0 # Polling interval, 0 means don't poll and wait for completion - From a1e00ac51c8cfffd7fcc84a61f0d31898c1ae4f6 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 5 Feb 2024 16:30:26 -0600 Subject: [PATCH 08/11] Revert "Do not fetch and build vitess if it is the same commit as the previous execution" This reverts commit d5473f2121fc875239c153a01a2aa5c060c1fc0e. --- ansible/roles/vitess_build/tasks/main.yml | 2 -- go/exec/exec.go | 16 ++++++++-------- go/infra/ansible/vars.go | 3 --- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/ansible/roles/vitess_build/tasks/main.yml b/ansible/roles/vitess_build/tasks/main.yml index 16ae07226..8e5bf5b9b 100644 --- a/ansible/roles/vitess_build/tasks/main.yml +++ b/ansible/roles/vitess_build/tasks/main.yml @@ -13,7 +13,6 @@ - name: Update Vitess become: yes become_user: root - when: commit_previous_exec != vitess_git_version block: - name: Fetch Updated Vitess include_tasks: install_vitess.yml @@ -53,7 +52,6 @@ changed_when: false - name: Disbale AppArmor - when: not clean_previous_exec | bool block: - name: link apparmor file: diff --git a/go/exec/exec.go b/go/exec/exec.go index 0d1794a52..497950937 100644 --- a/go/exec/exec.go +++ b/go/exec/exec.go @@ -142,11 +142,10 @@ type Exec struct { vitessSchemaPath string - // We always fetch the previous execution to let Ansible skip certain steps of the benchmark - // execution. Like cleaning up at the start of the execution, this is not required when the - // previous execution was clean and did not fail. Moreover, we can skip the fetch and build - // of Vitess if the previous execution share the same commit as the current execution. - previousExecution *Exec + // cleanPreviousExecution is set to true when the previous execution in the database is marked + // as "finished", meaning it has executed normally. In this case, Ansible doesn't need to clean up + // the execution server at the start of the execution to save time. + cleanPreviousExecution bool } const ( @@ -266,7 +265,9 @@ func (e *Exec) Prepare() error { if err != nil { return err } - e.previousExecution = previousExec + if previousExec.Status == StatusFinished { + e.cleanPreviousExecution = true + } // insert new exec in SQL if _, err = e.clientDB.Insert( @@ -394,8 +395,7 @@ func (e *Exec) prepareAnsibleForExecution() error { e.AnsibleConfig.AddExtraVar(ansible.KeyGoVersion, e.GolangVersion) // previous execution - e.AnsibleConfig.AddExtraVar(ansible.KeyCleanPreviousExec, e.previousExecution.Status == StatusFinished) - e.AnsibleConfig.AddExtraVar(ansible.KeyCommitPreviousExec, e.previousExecution.GitRef) + e.AnsibleConfig.AddExtraVar(ansible.KeyCleanPreviousExec, e.cleanPreviousExecution) // stats database related values e.statsRemoteDBConfig.AddToAnsible(&e.AnsibleConfig) diff --git a/go/infra/ansible/vars.go b/go/infra/ansible/vars.go index 3b4d91b92..79cb714b4 100644 --- a/go/infra/ansible/vars.go +++ b/go/infra/ansible/vars.go @@ -95,9 +95,6 @@ const ( // this is useful when doing optimization to skip certain steps of the setup KeyCleanPreviousExec = "clean_previous_exec" - // KeyCommitPreviousExec is the commit SHA of the previous execution. - KeyCommitPreviousExec = "commit_previous_exec" - // Stats database related keys // KeyStatsDBHost corresponding value in the map is the hostname for the stats From 3ac808ba989f70af52da6bca6f46aefd90a64d32 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 5 Feb 2024 16:30:32 -0600 Subject: [PATCH 09/11] Revert "Remove redundant step in vitess_build/main that calls clean.yml" This reverts commit e6c46acb9c0c5a31cf3084af93158297100c05bf. --- ansible/roles/vitess_build/tasks/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ansible/roles/vitess_build/tasks/main.yml b/ansible/roles/vitess_build/tasks/main.yml index 8e5bf5b9b..9cd85effd 100644 --- a/ansible/roles/vitess_build/tasks/main.yml +++ b/ansible/roles/vitess_build/tasks/main.yml @@ -10,6 +10,9 @@ # limitations under the License. --- +- name: Stop existing Vitess to build a new one + include_tasks: clean.yml + - name: Update Vitess become: yes become_user: root From 4031aad154630f8730dac6fe7a7505e19bb2e504 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 5 Feb 2024 16:30:38 -0600 Subject: [PATCH 10/11] Revert "Skip Clean Pre Macrobench if the previous execution was clean" This reverts commit 821df6dc0dded812c7deb471e4e5928af65780c3. --- ansible/create_cluster.yml | 3 +- go/exec/exec.go | 98 ++++++++++++++++++++++---------------- go/infra/ansible/vars.go | 6 --- 3 files changed, 58 insertions(+), 49 deletions(-) diff --git a/ansible/create_cluster.yml b/ansible/create_cluster.yml index 506cebd6a..461ab543b 100644 --- a/ansible/create_cluster.yml +++ b/ansible/create_cluster.yml @@ -10,8 +10,7 @@ # limitations under the License. --- -- name: Clean Pre Macrobench - when: not clean_previous_exec | bool +- name: Clean Post Macrobench import_playbook: clean_macrobench.yml - name: Build Vitess diff --git a/go/exec/exec.go b/go/exec/exec.go index 497950937..252603ffe 100644 --- a/go/exec/exec.go +++ b/go/exec/exec.go @@ -141,11 +141,6 @@ type Exec struct { vitessConfig vitessConfig vitessSchemaPath string - - // cleanPreviousExecution is set to true when the previous execution in the database is marked - // as "finished", meaning it has executed normally. In this case, Ansible doesn't need to clean up - // the execution server at the start of the execution to save time. - cleanPreviousExecution bool } const ( @@ -260,15 +255,6 @@ func (e *Exec) Prepare() error { return err } - // get previous benchmark - previousExec, err := getPreviousExecution(e.clientDB) - if err != nil { - return err - } - if previousExec.Status == StatusFinished { - e.cleanPreviousExecution = true - } - // insert new exec in SQL if _, err = e.clientDB.Insert( "INSERT INTO execution(uuid, status, source, git_ref, type, pull_nb, go_version) VALUES(?, ?, ?, ?, ?, ?, ?)", @@ -394,9 +380,6 @@ func (e *Exec) prepareAnsibleForExecution() error { // runtime related values e.AnsibleConfig.AddExtraVar(ansible.KeyGoVersion, e.GolangVersion) - // previous execution - e.AnsibleConfig.AddExtraVar(ansible.KeyCleanPreviousExec, e.cleanPreviousExecution) - // stats database related values e.statsRemoteDBConfig.AddToAnsible(&e.AnsibleConfig) return nil @@ -438,29 +421,6 @@ func (e *Exec) defineVersionNameOfVitess() error { return nil } -func getPreviousExecution(client storage.SQLClient) (*Exec, error) { - query := "SELECT uuid, status, git_ref, started_at, finished_at, source, type, pull_nb, go_version FROM execution ORDER BY started_at DESC LIMIT 1" - result, err := client.Select(query) - if err != nil { - return nil, err - } - defer result.Close() - - var eUUID string - exec := &Exec{} - if result.Next() { - err = result.Scan(&eUUID, &exec.Status, &exec.GitRef, &exec.StartedAt, &exec.FinishedAt, &exec.Source, &exec.TypeOf, &exec.PullNB, &exec.GolangVersion) - if err != nil { - return nil, err - } - exec.UUID, err = uuid.Parse(eUUID) - if err != nil { - return nil, err - } - } - return exec, nil -} - func GetRecentExecutions(client storage.SQLClient) ([]*Exec, error) { var res []*Exec query := "SELECT uuid, status, git_ref, started_at, finished_at, source, type, pull_nb, go_version FROM execution ORDER BY started_at DESC LIMIT 50" @@ -564,6 +524,23 @@ func GetPreviousFromSourceMacrobenchmark(client storage.SQLClient, source, typeO return } +// GetLatestDailyJobForMicrobenchmarks will fetch and return the commit sha for which +// the last daily job for microbenchmarks was run +func GetLatestDailyJobForMicrobenchmarks(client storage.SQLClient) (gitSha string, err error) { + query := "select git_ref from execution where source = \"cron\" and status = \"finished\" and type = \"micro\" order by started_at desc limit 1" + rows, err := client.Select(query) + if err != nil { + return "", err + } + + defer rows.Close() + for rows.Next() { + err = rows.Scan(&gitSha) + return gitSha, err + } + return "", nil +} + // GetLatestDailyJobForMacrobenchmarks will fetch and return the commit sha for which // the last daily job for macrobenchmarks was run func GetLatestDailyJobForMacrobenchmarks(client storage.SQLClient) (gitSha string, err error) { @@ -601,6 +578,45 @@ func ExistsMacrobenchmark(client storage.SQLClient, gitRef, source, typeOf, stat return result.Next(), nil } +func ExistsMacrobenchmarkStartedToday(client storage.SQLClient, gitRef, source, typeOf, planner, status string) (bool, error) { + query := fmt.Sprintf("SELECT uuid FROM execution e, macrobenchmark m WHERE e.status = '%s' AND e.git_ref = ? AND e.type = ? AND e.source = ? AND m.vtgate_planner_version = ? AND e.uuid = m.exec_uuid AND e.started_at >= CURDATE()", status) + result, err := client.Select(query, gitRef, typeOf, source, planner) + if err != nil { + return false, err + } + exists := result.Next() + result.Close() + if exists { + return true, nil + } + query = fmt.Sprintf("SELECT uuid FROM execution e WHERE e.status = '%s' AND e.git_ref = ? AND e.type = ? AND e.source = ? AND e.started_at >= CURDATE()", status) + result, err = client.Select(query, gitRef, typeOf, source) + if err != nil { + return false, err + } + defer result.Close() + for result.Next() { + var exec_uuid string + err = result.Scan(&exec_uuid) + if err != nil { + return false, err + } + query = "SELECT exec_uuid FROM macrobenchmark m WHERE m.exec_uuid = ?" + resultMacro, err := client.Select(query, exec_uuid) + if err != nil { + return false, err + } + defer resultMacro.Close() + + next := resultMacro.Next() + resultMacro.Close() + if !next { + return true, nil + } + } + return false, nil +} + func DeleteExecution(client storage.SQLClient, gitRef, UUID, source string) error { query := fmt.Sprintf("DELETE FROM execution WHERE uuid LIKE '%%%s%%' AND git_ref LIKE '%%%s%%' AND source = '%s'", UUID, gitRef, source) _, err := client.Select(query) @@ -608,4 +624,4 @@ func DeleteExecution(client storage.SQLClient, gitRef, UUID, source string) erro return err } return nil -} +} \ No newline at end of file diff --git a/go/infra/ansible/vars.go b/go/infra/ansible/vars.go index 79cb714b4..dcda54074 100644 --- a/go/infra/ansible/vars.go +++ b/go/infra/ansible/vars.go @@ -89,12 +89,6 @@ const ( // the execution of the benchmark. KeyGoVersion = "golang_gover" - // Previous execution keys - - // KeyCleanPreviousExec tells whether the previous execution was a clean benchmark or not - // this is useful when doing optimization to skip certain steps of the setup - KeyCleanPreviousExec = "clean_previous_exec" - // Stats database related keys // KeyStatsDBHost corresponding value in the map is the hostname for the stats From 42b74cc72a564b44ef943af1ed38e3747b6a9c0e Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 5 Feb 2024 16:30:44 -0600 Subject: [PATCH 11/11] Revert "remove duplicated create users tasks" This reverts commit 6bb67a7e0823164dcda7dce082ab64b135ad4b0e. --- ansible/roles/vtctld/tasks/main.yml | 5 +++++ ansible/roles/vtgate/tasks/main.yml | 5 +++++ ansible/roles/vttablet/tasks/main.yml | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/ansible/roles/vtctld/tasks/main.yml b/ansible/roles/vtctld/tasks/main.yml index 582fef0d9..619dcb66f 100644 --- a/ansible/roles/vtctld/tasks/main.yml +++ b/ansible/roles/vtctld/tasks/main.yml @@ -10,6 +10,11 @@ # limitations under the License. --- +- name: Create users + include_role: + name: "vitess_build" + tasks_from: create_users + - name: make sure vtctld is stopped when: clean_vtctld | bool include_role: diff --git a/ansible/roles/vtgate/tasks/main.yml b/ansible/roles/vtgate/tasks/main.yml index db015f3f7..9811115a7 100644 --- a/ansible/roles/vtgate/tasks/main.yml +++ b/ansible/roles/vtgate/tasks/main.yml @@ -16,6 +16,11 @@ name: "vtgate" tasks_from: clean +- name: Create users + include_role: + name: "vitess_build" + tasks_from: create_users + - name: ensure vitess directories become: yes become_user: root diff --git a/ansible/roles/vttablet/tasks/main.yml b/ansible/roles/vttablet/tasks/main.yml index 7c51b70de..1513910c0 100644 --- a/ansible/roles/vttablet/tasks/main.yml +++ b/ansible/roles/vttablet/tasks/main.yml @@ -16,6 +16,11 @@ name: "vttablet" tasks_from: "clean" +- name: Create users + include_role: + name: "vitess_build" + tasks_from: create_users + - name: ensure vitess directories become: yes become_user: root