Skip to content

Commit bb02c5e

Browse files
committed
HPCC-33710 Add engine Sasha access support
Signed-off-by: Jake Smith <[email protected]>
1 parent ddc729e commit bb02c5e

File tree

7 files changed

+30
-5
lines changed

7 files changed

+30
-5
lines changed

common/thorhelper/enginecontext.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ interface IEngineContext
4343
virtual StringBuffer &getQueryId(StringBuffer &result, bool isShared) const = 0;
4444
virtual void onTermination(QueryTermCallback callback, const char *key, bool isShared) const = 0;
4545
virtual void getManifestFiles(const char *type, StringArray &files) const = 0;
46+
virtual bool allowSashaAccess() const = 0;
4647
};
4748

4849
#endif // ENGINECONTEXT_HPP

ecl/eclagent/eclagent.ipp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ public:
566566
return ::getGlobalUniqueIds(num, &foreignNode);
567567
}
568568
virtual bool allowDaliAccess() const { return true; }
569+
virtual bool allowSashaAccess() const { return true; }
569570
virtual StringBuffer &getQueryId(StringBuffer &result, bool isShared) const
570571
{
571572
result.append("workunit"); // No distinction between global, workunit and query scopes for eclagent

helm/hpcc/templates/eclagent.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ data:
6161
labels:
6262
{{- include "hpcc.addStandardLabels" (dict "root" $ "component" $apptype "name" "eclagent" "instance" $appJobName "instanceOf" (printf "%s-job" .me.name)) | indent 12 }}
6363
accessDali: "yes"
64+
accessSasha: "yes"
6465
accessEsp: "yes"
6566
{{- include "hpcc.generateHelmVersion" . | nindent 12 }}
6667
{{- if hasKey .me "labels" }}
@@ -138,6 +139,7 @@ spec:
138139
{{- include "hpcc.addStandardLabels" (dict "root" $ "component" $apptype "name" "eclagent" "instance" .name) | indent 8 }}
139140
run: {{ .name | quote }}
140141
accessDali: "yes"
142+
accessSasha: {{ .useChildProcesses | default false | ternary "yes" "no" | quote }}
141143
accessEsp: {{ .useChildProcesses | default false | ternary "yes" "no" | quote }}
142144
{{- include "hpcc.generateHelmVersion" . | nindent 8 }}
143145
{{- if hasKey . "labels" }}

helm/hpcc/templates/thor.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ data:
8787
metadata:
8888
labels:
8989
accessDali: "yes"
90+
accessSasha: "yes"
9091
accessEsp: "yes"
9192
{{- include "hpcc.generateHelmVersion" . | nindent 12 }}
9293
{{- include "hpcc.addStandardLabels" (dict "root" $ "component" "eclagent" "name" "thor" "instance" $eclAgentJobName "instanceOf" (printf "%s-job" .eclAgentName)) | indent 12 }}
@@ -217,6 +218,7 @@ data:
217218
metadata:
218219
labels:
219220
accessDali: "yes"
221+
accessSasha: "yes"
220222
accessEsp: "yes"
221223
app: "thor"
222224
component: "thorworker"
@@ -351,6 +353,7 @@ spec:
351353
metadata:
352354
labels:
353355
accessDali: "yes"
356+
accessSasha: {{ $commonCtx.eclAgentUseChildProcesses | ternary "yes" "no" | quote }}
354357
accessEsp: {{ $commonCtx.eclAgentUseChildProcesses | ternary "yes" "no" | quote }}
355358
app: "thor"
356359
component: "thor-eclagent"

plugins/workunitservices/workunitservices.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,16 @@ namespace nsWorkunitservices {
179179
IPluginContext * parentCtx = NULL;
180180

181181

182-
static void getSashaWUArchiveNodes(SocketEndpointArray &epa)
182+
static void getSashaWUArchiveNodes(SocketEndpointArray &epa, ICodeContext *ctx)
183183
{
184+
IEngineContext *engineCtx = ctx->queryEngineContext();
185+
if (engineCtx && !engineCtx->allowSashaAccess())
186+
{
187+
Owned<IException> e = makeStringException(-1, "workunitservices cannot access Sasha in this context - this normally means it is being called from a thor worker");
188+
EXCLOG(e, NULL);
189+
throw e.getClear();
190+
}
191+
184192
#ifdef _CONTAINERIZED
185193
StringBuffer service;
186194
getService(service, "wu-archiver", true);
@@ -206,7 +214,7 @@ static IWorkUnitFactory * getWorkunitFactory(ICodeContext * ctx)
206214
IEngineContext *engineCtx = ctx->queryEngineContext();
207215
if (engineCtx && !engineCtx->allowDaliAccess())
208216
{
209-
Owned<IException> e = MakeStringException(-1, "workunitservices cannot access Dali in this context - this normally means it is being called from a thor slave");
217+
Owned<IException> e = MakeStringException(-1, "workunitservices cannot access Dali in this context - this normally means it is being called from a thor worker");
210218
EXCLOG(e, NULL);
211219
throw e.getClear();
212220
}
@@ -368,7 +376,7 @@ WORKUNITSERVICES_API void wsWorkunitList(
368376
MemoryBuffer mb;
369377
if (archived) {
370378
SocketEndpointArray sashaeps;
371-
getSashaWUArchiveNodes(sashaeps);
379+
getSashaWUArchiveNodes(sashaeps, ctx);
372380
ForEachItemIn(i,sashaeps) {
373381
Owned<ISashaCommand> cmd = createSashaCommand();
374382
cmd->setAction(SCA_WORKUNIT_SERVICES_GET);
@@ -500,7 +508,7 @@ WORKUNITSERVICES_API bool wsWorkunitExists(ICodeContext *ctx, const char *wuid,
500508
if (archived)
501509
{
502510
SocketEndpointArray sashaeps;
503-
getSashaWUArchiveNodes(sashaeps);
511+
getSashaWUArchiveNodes(sashaeps, ctx);
504512
ForEachItemIn(i,sashaeps) {
505513
Owned<ISashaCommand> cmd = createSashaCommand();
506514
cmd->setAction(SCA_LIST);

roxie/ccd/ccdcontext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,10 @@ class CRoxieServerContext : public CRoxieContextBase, implements IRoxieServerCon
30763076
Owned<IRoxieDaliHelper> dali = ::connectToDali();
30773077
return dali != nullptr;
30783078
}
3079+
virtual bool allowSashaAccess() const
3080+
{
3081+
return nullptr != workUnit; // allow if dynamic query only
3082+
}
30793083
virtual StringBuffer &getQueryId(StringBuffer &result, bool isShared) const
30803084
{
30813085
if (workUnit)

thorlcr/graph/thgraphslave.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,13 @@ class CThorCodeContextSlave : public CThorCodeContextBase, implements IEngineCon
16621662
virtual bool allowDaliAccess() const
16631663
{
16641664
// NB. includes access to foreign Dalis.
1665-
return jobChannel.queryJob().getOptBool("slaveDaliClient");
1665+
// slaveDaliClient option deprecated, but maintained for compatibility
1666+
return jobChannel.queryJob().getOptBool("allowDaliAccess", jobChannel.queryJob().getOptBool("slaveDaliClient"));
1667+
}
1668+
virtual bool allowSashaAccess() const
1669+
{
1670+
bool defaultAccess = isContainerized() ? false : true; // BM had access before, but not sure it should - kept for backwards compatibility
1671+
return jobChannel.queryJob().getOptBool("allowSashaAccess", defaultAccess);
16661672
}
16671673
virtual StringBuffer &getQueryId(StringBuffer &result, bool isShared) const
16681674
{

0 commit comments

Comments
 (0)