Skip to content

Commit 50cbd58

Browse files
achauhan-ybvpatibandla-yb
authored andcommitted
[PLAT-3207] Install yb-controller during universe creation behind enableYbc feature flag
Summary: This commit adds enableYbc feature flag and installs yb-controller on DB nodes accordingly. On enabling enableYbc feature flag, YBC package path field will appear on create universe page below DB version field. This commit will download ybc package from location specified in YBC package path and try to install it on DB nodes. If YBC package path field is left empty or it specifies a wrong path, then yb-controller will not be installed on nodes. Note: For this to work, YBC package path should have same source as DB package. For example, if DB releases is in S3 then YBC package path should be a S3 URI. {F24443} {F24444} Test Plan: Manual. Additional scenarios tested manually: 1. Add Read replica 2. Add node 3. Edit universe 4. Pause/resume/rolling restart Steps: Go to /features and enable the enableYbc feature flag. Go to create universe, fill details and also pass Ybc package path. Each node in universe should have yb-controller installed on it. dev-itest-pipeline run: https://jenkins.dev.yugabyte.com/job/dev-itest-pipeline/810 Reviewers: vkumar, asathyan, lsangappa, cpadinjareveettil, kkg, sanketh, kkannan, vbansal, vpatibandla, amalyshev Reviewed By: kkannan, vbansal, amalyshev Subscribers: amalyshev, yshchetinin, nbhatia, jenkins-bot, yugaware Differential Revision: https://phabricator.dev.yugabyte.com/D15953
1 parent 0f804e6 commit 50cbd58

File tree

30 files changed

+958
-112
lines changed

30 files changed

+958
-112
lines changed

managed/build.sbt

+1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ runPlatform := {
379379
}
380380

381381
libraryDependencies += "org.yb" % "yb-client" % "0.8.20-SNAPSHOT"
382+
libraryDependencies += "org.yb" % "ybc-client" % "0.0.1"
382383

383384
libraryDependencies ++= Seq(
384385
// We wont use swagger-ui jar since we want to change some of the assets:

managed/devops/configure-cluster-server.yml

+3
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@
1818
- role: install_package
1919
symlink_folders: "{{ yb_process_type | default(['master', 'tserver']) }}"
2020
when: package is defined
21+
22+
- role: configure-ybc-server
23+
when: configure_ybc

managed/devops/opscli/ybops/cloud/common/command.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def __init__(self):
7070
super(ControlInstanceCommand, self).__init__("control")
7171
self.commands_per_server_type = {
7272
"master": self.MASTER_COMMANDS,
73-
"tserver": self.BASE_COMMANDS
73+
"tserver": self.BASE_COMMANDS,
74+
"yb-controller": self.BASE_COMMANDS
7475
}
7576

7677
def add_subcommands(self):

managed/devops/opscli/ybops/cloud/common/method.py

+47-1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ def add_extra_args(self):
161161
action="store_true",
162162
default=False,
163163
help="check if systemd services is set")
164+
self.parser.add_argument("--configure_ybc",
165+
action="store_true",
166+
default=False,
167+
help="configure yb-controller on node.")
164168
self.parser.add_argument("--machine_image",
165169
required=False,
166170
help="The machine image (e.g. an AMI on AWS) to install, "
@@ -690,6 +694,7 @@ def callback(self, args):
690694
self.extra_vars["use_chrony"] = args.use_chrony
691695
self.extra_vars.update({"systemd_option": args.systemd_services})
692696
self.extra_vars.update({"instance_type": args.instance_type})
697+
self.extra_vars.update({"configure_ybc": args.configure_ybc})
693698
self.extra_vars["device_names"] = self.cloud.get_device_names(args)
694699

695700
self.cloud.setup_ansible(args).run("yb-server-provision.yml", self.extra_vars, host_info)
@@ -947,11 +952,13 @@ def prepare(self):
947952
self.parser.add_argument('--package', default=None)
948953
self.parser.add_argument('--num_releases_to_keep', type=int,
949954
help="Number of releases to keep after upgrade.")
955+
self.parser.add_argument('--ybc_package', default=None)
950956
self.parser.add_argument('--yb_process_type', default=None,
951957
choices=self.VALID_PROCESS_TYPES)
952958
self.parser.add_argument('--extra_gflags', default=None)
953959
self.parser.add_argument('--gflags', default=None)
954960
self.parser.add_argument('--gflags_to_remove', default=None)
961+
self.parser.add_argument('--ybc_flags', default=None)
955962
self.parser.add_argument('--master_addresses_for_tserver')
956963
self.parser.add_argument('--master_addresses_for_master')
957964
self.parser.add_argument('--server_broadcast_addresses')
@@ -1037,6 +1044,7 @@ def callback(self, args):
10371044
self.supported_types))
10381045

10391046
self.extra_vars["systemd_option"] = args.systemd_services
1047+
self.extra_vars["configure_ybc"] = args.configure_ybc
10401048

10411049
# Make sure we set server_type so we pick the right configure.
10421050
self.update_ansible_vars_with_args(args)
@@ -1051,6 +1059,11 @@ def callback(self, args):
10511059

10521060
if args.num_releases_to_keep is not None:
10531061
self.extra_vars["num_releases_to_keep"] = args.num_releases_to_keep
1062+
if args.ybc_package is not None:
1063+
self.extra_vars["ybc_package"] = args.ybc_package
1064+
1065+
if args.ybc_flags is not None:
1066+
self.extra_vars["ybc_flags"] = args.ybc_flags
10541067

10551068
if args.extra_gflags is not None:
10561069
self.extra_vars["extra_gflags"] = json.loads(args.extra_gflags)
@@ -1104,7 +1117,14 @@ def callback(self, args):
11041117
raise YBOpsRuntimeError("{} is not a valid s3 URI. Must match {}"
11051118
.format(args.package, s3_uri_pattern))
11061119

1120+
if args.ybc_package is not None:
1121+
match = re.match(s3_uri_pattern, args.ybc_package)
1122+
if not match:
1123+
raise YBOpsRuntimeError("{} is not a valid s3 URI. Must match {}"
1124+
.format(args.ybc_package, s3_uri_pattern))
1125+
11071126
self.extra_vars['s3_package_path'] = args.package
1127+
self.extra_vars['s3_ybc_package_path'] = args.ybc_package
11081128
self.extra_vars['aws_access_key'] = aws_access_key
11091129
self.extra_vars['aws_secret_key'] = aws_secret_key
11101130
logging.info(
@@ -1125,7 +1145,14 @@ def callback(self, args):
11251145
raise YBOpsRuntimeError("{} is not a valid gs URI. Must match {}"
11261146
.format(args.package, gcs_uri_pattern))
11271147

1148+
if args.ybc_package is not None:
1149+
match = re.match(gcs_uri_pattern, args.ybc_package)
1150+
if not match:
1151+
raise YBOpsRuntimeError("{} is not a valid gs URI. Must match {}"
1152+
.format(args.ybc_package, gcs_uri_pattern))
1153+
11281154
self.extra_vars['gcs_package_path'] = args.package
1155+
self.extra_vars['gcs_ybc_package_path'] = args.ybc_package
11291156
self.extra_vars['gcs_credentials_json'] = gcs_credentials_json
11301157
logging.info(
11311158
"Variables to download {} directly on the remote host added."
@@ -1139,13 +1166,19 @@ def callback(self, args):
11391166

11401167
# Remove query string part from http url.
11411168
self.extra_vars["package"] = match.group(1)
1142-
11431169
# Pass the complete http url to download the package.
11441170
self.extra_vars['http_package_path'] = match.group(0)
11451171
self.extra_vars['http_package_checksum'] = args.http_package_checksum
11461172
logging.info(
11471173
"Variables to download {} directly on the remote host added."
11481174
.format(args.package))
1175+
1176+
match = re.match(http_url_pattern, args.ybc_package)
1177+
if not match:
1178+
raise YBOpsRuntimeError("{} is not a valid HTTP URL. Must match {}"
1179+
.format(args.ybc_package, http_url_pattern))
1180+
self.extra_vars["http_ybc_package"] = match.group(0)
1181+
11491182
elif args.itest_s3_package_path and args.type == self.YB_SERVER_TYPE:
11501183
itest_extra_vars = self.extra_vars.copy()
11511184
itest_extra_vars["itest_s3_package_path"] = args.itest_s3_package_path
@@ -1168,6 +1201,19 @@ def callback(self, args):
11681201
logging.info("[app] Copying package {} to {} took {:.3f} sec".format(
11691202
args.package, args.search_pattern, time.time() - start_time))
11701203

1204+
if args.ybc_package is not None:
1205+
ybc_package_path = args.ybc_package
1206+
if os.path.isfile(ybc_package_path):
1207+
start_time = time.time()
1208+
scp_to_tmp(
1209+
ybc_package_path,
1210+
self.extra_vars["private_ip"],
1211+
self.extra_vars["ssh_user"],
1212+
self.extra_vars["ssh_port"],
1213+
args.private_key_file)
1214+
logging.info("[app] Copying package {} to {} took {:.3f} sec".format(
1215+
ybc_package_path, args.search_pattern, time.time() - start_time))
1216+
11711217
logging.info("Configuring Instance: {}".format(args.search_pattern))
11721218
ssh_options = {
11731219
# TODO: replace with args.ssh_user when it's setup in the flow

managed/devops/roles/configure-cluster-server/templates/yb-server-ctl.sh.j2

+17-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Usage: ${0##*/} <daemon> <command> OR
3131
Daemons:
3232
master
3333
tserver
34+
yb-controller
3435
Commands:
3536
create - Start the YB process on this node in cluster creation node (only applicable for
3637
master)
@@ -188,6 +189,12 @@ case "$daemon" in
188189
exit 1
189190
fi
190191
;;
192+
yb-controller)
193+
if [ "$command" == "create" ]; then
194+
echo "create command is not valid for yb-controller"
195+
exit 1
196+
fi
197+
;;
191198
*)
192199
echo "Invalid Daemon: $daemon"
193200
print_help
@@ -196,9 +203,16 @@ esac
196203

197204
daemon_home="{{ yb_home_dir }}/$daemon"
198205
daemon_logs_dir="$daemon_home/logs"
199-
daemon_binary="$daemon_home/bin/yb-$daemon"
200-
daemon_conf="$daemon_home/conf/server.conf"
201-
daemon_pid_file="$daemon_logs_dir/yb-$daemon.pid"
206+
if [[ $daemon == yb-controller ]]; then
207+
daemon_binary="$daemon_home/bin/$daemon-server"
208+
daemon_conf="$daemon_home/conf/$daemon.conf"
209+
daemon_pid_file="$daemon_logs_dir/$daemon.pid"
210+
else
211+
daemon_binary="$daemon_home/bin/yb-$daemon"
212+
daemon_conf="$daemon_home/conf/server.conf"
213+
daemon_pid_file="$daemon_logs_dir/yb-$daemon.pid"
214+
fi
215+
202216

203217
case "$command" in
204218
create|start)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2019 YugaByte, Inc. and Contributors
2+
#
3+
# Licensed under the Polyform Free Trial License 1.0.0 (the "License"); you
4+
# may not use this file except in compliance with the License. You
5+
# may obtain a copy of the License at
6+
#
7+
# https://github.com/YugaByte/yugabyte-db/blob/master/licenses/POLYFORM-FREE-TRIAL-LICENSE-1.0.0.txt
8+
9+
yb_home_dir: "/home/{{ user_name }}"
10+
yb_bin_dir: "{{ yb_home_dir }}/bin"
11+
ybc_conf_file: "{{ yb_home_dir }}/yb-controller/conf/yb-controller.conf"
12+
ybc_logs_dir: "{{ yb_home_dir }}/yb-controller/logs"
13+
configure_ybc: false
14+
systemd_option: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
- assert:
2+
that:
3+
- user_name is defined
4+
- systemd_option is defined
5+
6+
- block:
7+
- name: Setup | Create yb-controller logs directory
8+
file:
9+
path: "{{ ybc_logs_dir }}"
10+
state: directory
11+
mode: 0755
12+
owner: "{{ user_name }}"
13+
group: "{{ user_name }}"
14+
15+
- name: Remove existing ybc conf file
16+
file:
17+
path: "{{ ybc_conf_file }}"
18+
state: absent
19+
tags:
20+
- override_gflags
21+
when: ybc_flags is defined
22+
23+
- name: Configure | Set ybc flags
24+
lineinfile:
25+
dest: "{{ ybc_conf_file }}"
26+
regexp: "^--{{ item.key }}=(.*)"
27+
line: "--{{item.key}}={{item.value}}"
28+
create: yes
29+
with_dict: "{{ ybc_flags }}"
30+
tags:
31+
- override_gflags
32+
when: ybc_flags is defined
33+
34+
- block:
35+
# Cronjob approach for starting yb-controller
36+
- name: Setup cron to check liveness of yb-controller
37+
cron:
38+
name: "Check liveness of yb-controller"
39+
minute: "*/1"
40+
user: "{{ user_name }}"
41+
job: >
42+
{{ yb_bin_dir }}/yb-server-ctl.sh yb-controller cron-check ||
43+
{{ yb_bin_dir }}/yb-server-ctl.sh yb-controller start
44+
register: cron_result
45+
failed_when:
46+
- cron_result is failed
47+
- cloud_type != "onprem"
48+
when: not systemd_option
49+
tags: yb-prebuilt-ami
50+
51+
- block:
52+
# Remove old cron job and its tasks that start yb-controller
53+
- name: Remove old cron job that starts yb-controller (for upgrades)
54+
cron:
55+
name: "Check liveness of yb-controller"
56+
user: "yugabyte"
57+
state: absent
58+
59+
- name: User mode systemd
60+
block:
61+
- name: Stop existing running yb-controller
62+
systemd:
63+
name: yb-controller
64+
state: stopped
65+
scope: user
66+
67+
- name: Reload systemd user daemon
68+
systemd:
69+
daemon_reload: yes
70+
scope: user
71+
72+
# User units need to be linked if waiting on system units
73+
- name: Link network-online.target
74+
shell:
75+
cmd: "systemctl --user link /lib/systemd/system/network-online.target"
76+
77+
- name: Start network-online.target
78+
systemd:
79+
name: network-online.target
80+
state: started
81+
enabled: yes
82+
scope: user
83+
84+
- name: Enabling and starting yb-controller
85+
systemd:
86+
name: yb-controller
87+
state: started
88+
enabled: yes
89+
scope: user
90+
91+
- name: System (RHEL7) systemd units
92+
block:
93+
- name: Stop existing running yb-controller
94+
shell:
95+
cmd: "sudo systemctl stop yb-controller"
96+
97+
# Systemd daemon-reload for yb-controller service files
98+
- name: Perform daemon-reload for the new services
99+
shell:
100+
cmd: "sudo systemctl daemon-reload"
101+
102+
- name: Enable yb-controller service
103+
shell:
104+
cmd: "sudo systemctl enable yb-controller"
105+
106+
- name: Run yb-controller.service to start the yb-controller
107+
shell:
108+
cmd: "sudo systemctl start yb-controller"
109+
tags:
110+
- override_gflags
111+
- systemd_upgrade
112+
when: systemd_option

managed/devops/roles/install_package/defaults/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ yb_software_dir: "{{ yb_home_dir }}/yb-software"
1111
itest_s3_package_path: ""
1212
num_retries: 5
1313
retry_delay: 10
14+
configure_ybc: false

0 commit comments

Comments
 (0)