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_filesystem.yml
60 lines (51 loc) · 2.2 KB
/
check_filesystem.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
- name: Get ansible_mounts fact
setup:
gather_subset: hardware
filter: ansible_mounts
- name: Determine which mountpoint that tikv data dir exists on
shell: "df {{ tikv_data_dir }} | tail -n1 | awk '{print $NF}'"
register: deploy_partition
changed_when: False
- set_fact:
xfs_filesystem: "true"
when:
- item.mount == deploy_partition.stdout
- item.fstype == 'xfs'
with_items: "{{ ansible_mounts }}"
- name: Preflight check - Check bug if filesystem is xfs
shell: cd {{ tikv_data_dir }} && fallocate -n -o 0 -l 9192 tidb_test && printf 'a%.0s' {1..5000} > tidb_test && truncate -s 5000 tidb_test && fallocate -p -n -o 5000 -l 4192 tidb_test && LANG=en_US.UTF-8 stat tidb_test |awk 'NR==2{print $2}'
register: xfs_result
when:
- xfs_filesystem is defined
- xfs_filesystem
- name: Clean check file for xfs filesystem
file: path={{ tikv_data_dir }}/tidb_test state=absent
when:
- xfs_filesystem is defined
- xfs_filesystem
- set_fact:
ext4_filesystem_alert: "true"
when:
- item.mount == deploy_partition.stdout
- item.fstype == 'ext4'
- item.options.find("nodelalloc") == -1
with_items: "{{ ansible_mounts }}"
- name: Preflight check - Does tikv data dir meet ext4 file system requirement
fail:
msg: "You don't mount the file system of {{ deploy_partition.stdout }} with ext4 nodelalloc option. See https://github.com/pingcap/docs/blob/master/online-deployment-using-ansible.md#step-8-mount-the-data-disk-ext4-filesystem-with-options-on-the-target-machines."
when:
- ext4_filesystem_alert is defined
- ext4_filesystem_alert
- name: Preflight check - Set fssystem_check_result fact
set_fact:
fssystem_check_result: true
when: "(item.mount == deploy_partition.stdout and item.fstype == 'ext4') or (xfs_filesystem is defined and xfs_filesystem and xfs_result.stdout|int == 5000)"
with_items: "{{ ansible_mounts }}"
- name: Preflight check - Does tikv data dir meet ext4 or xfs file system requirement
fail:
msg: 'The file system mounted at {{ item.mount }} does not meet ext4 or xfs file system requirement'
when:
- item.mount == deploy_partition.stdout
- fssystem_check_result is not defined
with_items: "{{ ansible_mounts }}"