Skip to content

Commit 7ece035

Browse files
committed
[PLAT-15273]Remote files download bug fix
Summary: This diff has the fix for a bug where we assume the same tmp directory for the YBA and the db nodes. As a result support bundle creation fails when we set `yb.filepaths.TmpDirectory` to any path which is absent on the db nodes. Fix for both the python script and the node agent flow. Test Plan: Manually verified that support bundle creation succeeds when the tmp directory is changed on either YBA or the db nodes via gflags. Reviewers: nsingh, skurapati Reviewed By: nsingh Subscribers: yugaware Differential Revision: https://phorge.dev.yugabyte.com/D39722
1 parent 316cda5 commit 7ece035

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

managed/devops/bin/run_node_action.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ def add_download_file_subparser(subparsers, command, parent):
163163
parser.add_argument('--source_node_files_path', type=str,
164164
help='File containing source files to download (separated by new line)',
165165
required=True)
166+
parser.add_argument('--remote_node_files_path', type=str,
167+
help='File containing source files to download on the remote server',
168+
required=True)
166169
parser.add_argument('--target_local_file', type=str,
167170
help='Target file to save source to',
168171
required=True)
@@ -171,11 +174,11 @@ def add_download_file_subparser(subparsers, command, parent):
171174
def download_file_node(args, client):
172175
# Name is irrelevant as long as it doesn't already exist
173176
tar_file_name = args.node_name + "-" + str(uuid.uuid4()) + ".tar.gz"
174-
target_node_files_path = args.source_node_files_path
177+
target_node_files_path = args.remote_node_files_path
175178

176179
# "node_utils.sh/create_tar_file" file takes parameters:
177180
# [home_dir, tar_file_name, file_list_text_path]
178-
cmd = [args.source_node_files_path]
181+
cmd = [target_node_files_path]
179182
client.put_file(args.source_node_files_path, target_node_files_path)
180183
cmd.insert(0, tar_file_name)
181184
cmd.insert(0, args.yb_home_dir)

managed/src/main/java/com/yugabyte/yw/common/NodeActionRunner.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ public void downloadFile(
136136
NodeDetails node,
137137
String ybHomeDir,
138138
String fileListFilepath,
139+
String targetNodeFilesPath,
139140
String targetLocalFile,
140141
ShellProcessContext context) {
141142
String user = context.getSshUser();
142143
Duration timeout = context.getTimeout();
143144
String tarFilename = String.format("%s-%s.tar.gz", node.getNodeName(), UUID.randomUUID());
144-
String targetNodeFilesPath = fileListFilepath;
145145
// Upload the files to be downloaded.
146146
nodeAgentClient.uploadFile(nodeAgent, fileListFilepath, targetNodeFilesPath, user, 0, timeout);
147147
Path scriptPath =
@@ -150,7 +150,7 @@ public void downloadFile(
150150
scriptParams.add("create_tar_file");
151151
scriptParams.add(ybHomeDir);
152152
scriptParams.add(tarFilename);
153-
scriptParams.add(fileListFilepath);
153+
scriptParams.add(targetNodeFilesPath);
154154
String scriptOutput =
155155
nodeAgentClient
156156
.executeScript(nodeAgent, scriptPath, scriptParams, context)
@@ -189,11 +189,6 @@ public void downloadFile(
189189
*/
190190
public void copyFile(
191191
NodeAgent nodeAgent, String remoteFile, String localFile, ShellProcessContext context) {
192-
Path localFilepath = Paths.get(localFile);
193-
Path localFileDir = localFilepath.getParent().toAbsolutePath();
194-
nodeAgentClient
195-
.executeCommand(nodeAgent, Arrays.asList("mkdir", "-p", localFileDir.toString()), context)
196-
.processErrors();
197192
nodeAgentClient.downloadFile(nodeAgent, remoteFile, localFile);
198193
}
199194

managed/src/main/java/com/yugabyte/yw/common/NodeUniverseManager.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,28 @@ public void downloadNodeFile(
139139
List<String> sourceNodeFiles,
140140
String targetLocalFile) {
141141
universeLock.acquireLock(universe.getUniverseUUID());
142-
String filesListFilePath = "";
142+
String filesListFilePath = "", remoteFilesListPath = "";
143143
try {
144144
filesListFilePath = createTempFileWithSourceFiles(sourceNodeFiles);
145145
if (filesListFilePath == null) {
146146
throw new RuntimeException(
147147
"Could not create temp file while downloading node file for universe "
148148
+ universe.getUniverseUUID());
149149
}
150+
remoteFilesListPath =
151+
getRemoteTmpDir(node, universe)
152+
+ "/"
153+
+ Paths.get(filesListFilePath).getFileName().toString();
150154
Optional<NodeAgent> optional = maybeGetNodeAgent(universe, node, true /*check feature flag*/);
151155
if (optional.isPresent()) {
152156
nodeActionRunner.downloadFile(
153-
optional.get(), node, ybHomeDir, filesListFilePath, targetLocalFile, DEFAULT_CONTEXT);
157+
optional.get(),
158+
node,
159+
ybHomeDir,
160+
filesListFilePath,
161+
remoteFilesListPath,
162+
targetLocalFile,
163+
DEFAULT_CONTEXT);
154164
} else {
155165
List<String> actionArgs = new ArrayList<>();
156166
// yb_home_dir denotes a custom starting directory for the remote file. (Eg: ~/, /mnt/d0,
@@ -159,6 +169,8 @@ public void downloadNodeFile(
159169
actionArgs.add(ybHomeDir);
160170
actionArgs.add("--source_node_files_path");
161171
actionArgs.add(filesListFilePath);
172+
actionArgs.add("--remote_node_files_path");
173+
actionArgs.add(remoteFilesListPath);
162174
actionArgs.add("--target_local_file");
163175
actionArgs.add(targetLocalFile);
164176
executeNodeAction(

0 commit comments

Comments
 (0)