From 66b29a3d014a48017af3364f780fafe563aacefd Mon Sep 17 00:00:00 2001 From: wangkx Date: Wed, 13 Sep 2023 16:12:41 -0400 Subject: [PATCH] HPCC-30218 Use default spray target if not specified in cloud Signed-off-by: wangkx --- ecl/eclagent/eclagent.cpp | 7 +++++-- esp/services/ws_fs/ws_fsService.cpp | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ecl/eclagent/eclagent.cpp b/ecl/eclagent/eclagent.cpp index 3a3d715041b..26d86be7056 100644 --- a/ecl/eclagent/eclagent.cpp +++ b/ecl/eclagent/eclagent.cpp @@ -3128,8 +3128,11 @@ char * EclAgent::getClusterName() char * EclAgent::getGroupName() { #ifdef _CONTAINERIZED - // in a containerized setup, the group is moving.. - return strdup("unknown"); + // In containerized there is no associated cluster group. + // Return an empty result instead, which if used for destinationGroup + // via Thorlib.group() as part of a fileservices call, will be interpreted + // as targeting the default data plane + return strdup(""); #else StringBuffer groupName; if (!isStandAloneExe) diff --git a/esp/services/ws_fs/ws_fsService.cpp b/esp/services/ws_fs/ws_fsService.cpp index 9f59f53b92a..7fabceabbd2 100644 --- a/esp/services/ws_fs/ws_fsService.cpp +++ b/esp/services/ws_fs/ws_fsService.cpp @@ -2083,15 +2083,24 @@ static void checkValidDfuQueue(const char * dfuQueue) #endif } +static const char* getSprayDestGroup(const char* groupReq, StringBuffer& groupOut) +{ + if (!isEmptyString(groupReq)) + groupOut.append(groupReq); + else if (isContainerized()) + getDefaultStoragePlane(groupOut); + return groupOut.str(); +} + bool CFileSprayEx::onSprayFixed(IEspContext &context, IEspSprayFixed &req, IEspSprayFixedResponse &resp) { try { context.ensureFeatureAccess(FILE_SPRAY_URL, SecAccess_Write, ECLWATCH_FILE_SPRAY_ACCESS_DENIED, "Failed to do Spray. Permission denied."); - StringBuffer destFolder, destTitle, defaultFolder, defaultReplicateFolder; + StringBuffer destFolder, destTitle, defaultFolder, defaultReplicateFolder, groupStr; - const char* destNodeGroup = req.getDestGroup(); + const char* destNodeGroup = getSprayDestGroup(req.getDestGroup(), groupStr); if (isEmptyString(destNodeGroup)) throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "Destination node group not specified."); @@ -2246,9 +2255,9 @@ bool CFileSprayEx::onSprayVariable(IEspContext &context, IEspSprayVariable &req, { context.ensureFeatureAccess(FILE_SPRAY_URL, SecAccess_Write, ECLWATCH_FILE_SPRAY_ACCESS_DENIED, "Failed to do Spray. Permission denied."); - StringBuffer destFolder, destTitle, defaultFolder, defaultReplicateFolder; + StringBuffer destFolder, destTitle, defaultFolder, defaultReplicateFolder, groupStr; - const char* destNodeGroup = req.getDestGroup(); + const char* destNodeGroup = getSprayDestGroup(req.getDestGroup(), groupStr); if (isEmptyString(destNodeGroup)) throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "Destination node group not specified.");