From ab233216711680aec8f34d14278d96fb1574f566 Mon Sep 17 00:00:00 2001 From: liubo Date: Mon, 8 Apr 2019 18:21:54 +0800 Subject: [PATCH] cherry-pick from master to 2.1 (#728) * Update OS version requirements (#663) * Update OS version requirements * Update operating system limits * Update operating system limits * Update operating system limits * Set rolling update limits * Liubo/check os version (#726) * Fix OS check * Fix OS check * fix yaml format --- roles/check_system_static/tasks/main.yml | 24 +++++- rolling_update.yml | 16 ++++ scripts/check/check_cpufreq.py | 0 scripts/check/epoll_chk.cc | 100 +++++++++++++++++++++++ scripts/check/epollexclusive | Bin 0 -> 8920 bytes 5 files changed, 137 insertions(+), 3 deletions(-) mode change 100644 => 100755 scripts/check/check_cpufreq.py create mode 100644 scripts/check/epoll_chk.cc create mode 100755 scripts/check/epollexclusive diff --git a/roles/check_system_static/tasks/main.yml b/roles/check_system_static/tasks/main.yml index 832fd9980..54432335e 100644 --- a/roles/check_system_static/tasks/main.yml +++ b/roles/check_system_static/tasks/main.yml @@ -13,8 +13,26 @@ - name: Preflight check - Linux OS family and distribution version fail: - msg: "Red Hat Enterprise Linux/CentOS 6 is deprecated. Please use CentOS 7.3 and above. See https://github.com/pingcap/docs/blob/master/op-guide/recommendation.md" - when: "ansible_os_family == 'RedHat' and ansible_distribution_major_version == '6'" + msg: "System versions lower than Red Hat Enterprise Linux / CentOS 7.3 have been deprecated. Please use CentOS 7.3 and above. See https://github.com/pingcap/docs/blob/master/op-guide/recommendation.md" + when: + - ansible_os_family == 'RedHat' + - ansible_distribution != 'Amazon' + - ansible_distribution_version < '7.3' + +- name: Deploy epollexclusive script + copy: src="{{ script_dir }}/check/epollexclusive" dest="{{ deploy_dir }}/epollexclusive" mode=0755 + +- name: Preflight check - Check if the operating system supports EPOLLEXCLUSIVE + shell: "{{ deploy_dir }}/epollexclusive" + register: epollexclusive_check + +- name: Clean epollexclusive script + file: path={{ deploy_dir }}/epollexclusive state=absent + +- name: Preflight check - Fail when epollexclusive is unavailable + fail: + msg: "The current machine may be a docker virtual machine, and the corresponding physical machine operating system does not support epollexclusive" + when: epollexclusive_check.stdout.find("True") == -1 - name: Deploy check_cpufreq script copy: src="{{ script_dir }}/check/check_cpufreq.py" dest="{{ deploy_dir }}/check_cpufreq.py" mode=0755 @@ -29,7 +47,7 @@ - name: Preflight check - Fail when CPU frequency governor is not set to performance mode fail: - msg: To achieve maximum performance, it is recommended to set The CPU frequency governor to performance mode, see https://github.com/pingcap/docs/blob/master/op-guide/ansible-deployment.md#step-7-configure-the-cpufreq-governor-mode-on-the-target-machine + msg: "To achieve maximum performance, it is recommended to set The CPU frequency governor to performance mode, see https://github.com/pingcap/docs/blob/master/op-guide/ansible-deployment.md#step-7-configure-the-cpufreq-governor-mode-on-the-target-machine" when: - cpufreq_available_governors.stdout.find("performance") != -1 - cpufreq_current_governor.stdout.find("performance") == -1 diff --git a/rolling_update.yml b/rolling_update.yml index 54cce4ca0..f23945389 100644 --- a/rolling_update.yml +++ b/rolling_update.yml @@ -38,6 +38,22 @@ roles: - check_config_dynamic +- name: Pre-check for rolling update + hosts: tidb_servers + any_errors_fatal: true + serial: 1 + tags: + - always + tasks: + - shell: "{{ deploy_dir }}/bin/tidb-server -V" + register: current_version + + - name: Check whether can perform rolling update + fail: + msg: "Rolling update from {{ current_version.stdout_lines[0].replace(' ','').split(':')[1] }} to {{ tidb_version }} is forbidden" + when: + - current_version.stdout_lines[0].replace(' ','').split(':')[1] <= "v2.0.1" + - tidb_version >= "v2.1.0" or tidb_version == "latest" - name: rolling update PD cluster hosts: pd_servers diff --git a/scripts/check/check_cpufreq.py b/scripts/check/check_cpufreq.py old mode 100644 new mode 100755 diff --git a/scripts/check/epoll_chk.cc b/scripts/check/epoll_chk.cc new file mode 100644 index 000000000..5f6e99813 --- /dev/null +++ b/scripts/check/epoll_chk.cc @@ -0,0 +1,100 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include + +#ifndef EPOLLEXCLUSIVE +#define EPOLLEXCLUSIVE (1 << 28) +#endif + +/* This polling engine is only relevant on linux kernels supporting epoll() */ +bool grpc_is_epollexclusive_available(void) { + static bool logged_why_not = false; + + int fd = epoll_create1(EPOLL_CLOEXEC); + if (fd < 0) { + if (!logged_why_not) { + printf( + "epoll_create1 failed with error: %d. Not using epollex polling " + "engine.", + fd); + logged_why_not = true; + } + return false; + } + int evfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); + if (evfd < 0) { + if (!logged_why_not) { + printf( + "eventfd failed with error: %d. Not using epollex polling " + "engine.", + fd); + logged_why_not = true; + } + close(fd); + return false; + } + struct epoll_event ev; + /* choose events that should cause an error on + EPOLLEXCLUSIVE enabled kernels - specifically the combination of + EPOLLONESHOT and EPOLLEXCLUSIVE */ + ev.events = (uint32_t)(EPOLLET | EPOLLIN | EPOLLEXCLUSIVE | EPOLLONESHOT); + ev.data.ptr = NULL; + if (epoll_ctl(fd, EPOLL_CTL_ADD, evfd, &ev) != 0) { + if (errno != EINVAL) { + if (!logged_why_not) { + printf( + "epoll_ctl with EPOLLEXCLUSIVE | EPOLLONESHOT failed with error: " + "%d. Not using epollex polling engine.", + errno); + logged_why_not = true; + } + close(fd); + close(evfd); + return false; + } + } else { + if (!logged_why_not) { + printf( + "epoll_ctl with EPOLLEXCLUSIVE | EPOLLONESHOT succeeded. This is " + "evidence of no EPOLLEXCLUSIVE support. Not using " + "epollex polling engine."); + logged_why_not = true; + } + close(fd); + close(evfd); + return false; + } + close(evfd); + close(fd); + return true; +} + +int main() { + if (grpc_is_epollexclusive_available()) { + printf("True: epollexclusive is available\n"); + return 0; + } else { + printf("False: epollexclusive is NOT available\n"); + return 1; + } +} diff --git a/scripts/check/epollexclusive b/scripts/check/epollexclusive new file mode 100755 index 0000000000000000000000000000000000000000..f8d73a4c917210c5c6dcf0226693f6c9c7d25a49 GIT binary patch literal 8920 zcmeHMZERcB89uh-B>liiODRdaHCL=fp;Amf+7b$k>m+V(klSXd!?LdFjbq=$27g5M zb(^rkD!J_%b)}iKiD-aSG;QjBOk&eO(SFdBOf5|N5jL?uo3_FzOA2V6fXa+g?|sib z@AdVKEjpoTe|D04-}64_{W_mM=iKl31G}6K2czUH=?6Rj0;E}&KLbUF>7(<$=|(JvV=BT5k>MSsO4i>yJPTWzpJ z8Iw4GdKhcHhqFM3d4^~}#L*`x=^=}H%|fqP=n-8Iff1$pVcqZv3VT7P3>@+@64t}t zMT)YR`mX2^%qy!n3smMAq7ND{BT9N-13irMR#UwY>=*tjwaYb8Kca$V_r_x*JGR{$ zkF>;N$?QbSMCXo{9oxK_l((JN8||a)?!5!t6SboR9LBs39vlN${)b;Z-}UfMPhDIH zA9{D|$0NVZC7x+SU3wsU%jr&#Tw6vOo3k8_ahAh(R=`^;;Cn0J!+=Zh*i$nA<^0MO za0cxi#^&9@#9JIjX@@nyBTO4l#p7yNkF#(*mC=Y# zYav~012r_KX7o^6R}-OF5|FV(Dk%_^?GE&Ib*t^(`_0^aX08Len9AF|+p%U&@#g}H z{p*IltK$7f%3DeIIRU}r_X{z#muDS z-mg_oxf3fTrW~Ks-HXpck&^pO?YtpU*ggV9g)I?y*EPwILq3XyOP33fwj4kntG=|r z`F`ZF%1d*ce*}4~>e7px??N7{xOA5DJCVn#ElqR29eJ$M(oxQDMIM`XX`J(~u8`R1 zH1IsNeb77g#vx_uZ6){4wZ35QrMbQpGE**HxLk|m(u+VAp8>^>M(dh-7@Hk~h8R#< zhJh%#yhoY3a>O|_Ka0k&0X`Z!k41&cbxlVRn?;V~FXUYyuS~tFT)6tM;#g4L$Y(+M z*C?nQ|2-%xQx^^Ww}t-Ehq4ea%dQy!&Bd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