Skip to content

Commit

Permalink
[PLAT-15156] Pass pg_max_mem_mb during configure phase
Browse files Browse the repository at this point in the history
Summary: We moved the systemd configuration to configure phase, where in we missed passing `pg_max_mem_mb` flag that sets up cgroups for postgres

Test Plan:
Manually created cluster.
Verified that cgroups are correctly configured

Reviewers: nbhatia, nsingh

Reviewed By: nbhatia

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D37967
  • Loading branch information
Vars-07 committed Sep 13, 2024
1 parent 0a738ee commit a0e2c4a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions managed/devops/opscli/ybops/cloud/common/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,8 @@ def prepare(self):
self.parser.add_argument('--gcs_remote_download', action="store_true")
self.parser.add_argument('--gcs_credentials_json')
self.parser.add_argument('--http_remote_download', action="store_true")
self.parser.add_argument("--pg_max_mem_mb", type=int, default=0,
help="Max memory for postgress process.")
self.parser.add_argument('--http_package_checksum', default='')
self.parser.add_argument('--install_third_party_packages',
action="store_true",
Expand Down Expand Up @@ -1309,6 +1311,9 @@ def callback(self, args):

if args.yb_process_type:
self.extra_vars["yb_process_type"] = args.yb_process_type.lower()

if args.pg_max_mem_mb:
self.extra_vars.update({"pg_max_mem_mb": args.pg_max_mem_mb})
else:
raise YBOpsRuntimeError("Supported types for this command are only: {}".format(
self.supported_types))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ public SubTaskGroup createConfigureServerTasks(
universe.getUniverseDetails().clusters);
}
}
params.cgroupSize = getCGroupSize(node);
// Create the Ansible task to get the server info.
AnsibleConfigureServers task = createTask(AnsibleConfigureServers.class);
task.initialize(params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public static class Params extends NodeTaskParams {
public AuditLogConfig auditLogConfig = null;
public Map<String, String> ybcGflags = new HashMap<>();
public boolean overrideNodePorts = false;
// Amount of memory to limit the postgres process to via the ysql cgroup (in megabytes)
public int cgroupSize = 0;
// Supplier for master addresses override which is invoked only when the subtask starts
// execution.
@JsonIgnore @Nullable public Supplier<String> masterAddrsOverride;
Expand Down
3 changes: 3 additions & 0 deletions managed/src/main/java/com/yugabyte/yw/common/NodeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,9 @@ && imdsv2required(arch, userIntent, provider)) {
commandArgs.add("--local_package_path");
commandArgs.add(localPackagePath);
}

commandArgs.add("--pg_max_mem_mb");
commandArgs.add(Integer.toString(taskParam.cgroupSize));
break;
}
case List:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,10 @@ private List<String> nodeCommand(
if (type == NodeManager.NodeCommandType.Create) {
expectedCommand.add("--as_json");
}
if (type == NodeManager.NodeCommandType.Configure) {
expectedCommand.add("--pg_max_mem_mb");
expectedCommand.add("0");
}
expectedCommand.add("--remote_tmp_dir");
expectedCommand.add("/tmp");
expectedCommand.add(params.nodeName);
Expand Down Expand Up @@ -2061,7 +2065,7 @@ public void testConfigureNodeCommandWithAccessKey() {
"/path/to/private.key",
"--custom_ssh_port",
"3333");
expectedCommand.addAll(expectedCommand.size() - 7, accessKeyCommand);
expectedCommand.addAll(expectedCommand.size() - 9, accessKeyCommand);
reset(shellProcessHandler);
nodeManager.nodeCommand(NodeManager.NodeCommandType.Configure, params);
verify(shellProcessHandler, times(1))
Expand Down

0 comments on commit a0e2c4a

Please sign in to comment.