Skip to content

Commit

Permalink
Merge pull request #17790 from ghalliday/issue29544
Browse files Browse the repository at this point in the history
HPCC-29544 Remove configuration of the global-id header field name

Reviewed-By: Rodrigo Pastrana <[email protected]>
Reviewed-By: Anthony Fishbeck <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Sep 27, 2023
2 parents 69d8686 + ed1a669 commit 7800de0
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 227 deletions.
8 changes: 4 additions & 4 deletions common/thorhelper/thorsoapcall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1913,11 +1913,11 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo
#endif
if (!isEmptyString(master->logctx.queryGlobalId()))
{
if (!httpHeaderBlockContainsHeader(httpheaders, master->logctx.queryGlobalIdHttpHeaderName()))
request.append(master->logctx.queryGlobalIdHttpHeaderName()).append(": ").append(master->logctx.queryGlobalId()).append("\r\n");
if (!httpHeaderBlockContainsHeader(httpheaders, kGlobalIdHttpHeaderName))
request.append(kGlobalIdHttpHeaderName).append(": ").append(master->logctx.queryGlobalId()).append("\r\n");

if (!isEmptyString(master->logctx.queryLocalId()) && !httpHeaderBlockContainsHeader(httpheaders, master->logctx.queryCallerIdHttpHeaderName()))
request.append(master->logctx.queryCallerIdHttpHeaderName()).append(": ").append(master->logctx.queryLocalId()).append("\r\n"); //our localId is reciever's callerId
if (!isEmptyString(master->logctx.queryLocalId()) && !httpHeaderBlockContainsHeader(httpheaders, kCallerIdHttpHeaderName))
request.append(kCallerIdHttpHeaderName).append(": ").append(master->logctx.queryLocalId()).append("\r\n"); //our localId is reciever's callerId
}

if (master->wscType == STsoap)
Expand Down
3 changes: 0 additions & 3 deletions ecl/eclagent/eclagent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2130,9 +2130,6 @@ void EclAgent::runProcess(IEclProcess *process)
assertex(rowManager==NULL);
allocatorMetaCache.setown(createRowAllocatorCache(this));

if (agentTopology->hasProp("@httpGlobalIdHeader"))
updateDummyContextLogger().setHttpIdHeaderNames(agentTopology->queryProp("@httpGlobalIdHeader"), agentTopology->queryProp("@httpCallerIdHeader"));

if (queryWorkUnit()->hasDebugValue("GlobalId"))
{
SCMStringBuffer globalId;
Expand Down
4 changes: 4 additions & 0 deletions esp/bindings/http/platform/httptransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1942,9 +1942,13 @@ void CHttpRequest::updateContext()
m_context->setAcceptLanguage(acceptLanguage.str());
StringBuffer callerId, globalId;
getHeader(HTTP_HEADER_HPCC_GLOBAL_ID, globalId);
if (globalId.isEmpty())
getHeader("hpcc-global-id", globalId);
if(globalId.length())
m_context->setGlobalId(globalId);
getHeader(HTTP_HEADER_HPCC_CALLER_ID, callerId);
if (callerId.isEmpty())
getHeader("hpcc-caller-id", callerId);
if(callerId.length())
m_context->setCallerId(callerId);
}
Expand Down
23 changes: 6 additions & 17 deletions esp/services/ws_ecl/ws_ecl_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,6 @@ bool CWsEclService::init(const char * name, const char * type, IPropertyTree * c
else
workunitTimeout = WAIT_FOREVER;

const char *headerName = serviceTree->queryProp("HttpGlobalIdHeader");
if (headerName && *headerName && !streq(headerName, "Global-Id") && !streq(headerName, "HPCC-Global-Id")) //defaults will be checked anyway
globalIdHttpHeader.set(headerName);
headerName = serviceTree->queryProp("HttpCallerIdHeader");
if (headerName && *headerName && !streq(headerName, "Caller-Id") && !streq(headerName, "HPCC-Caller-Id")) //defaults will be checked anyway
callerIdHttpHeader.set(headerName);

Owned<IPropertyTreeIterator> cfgTargets = serviceTree->getElements("Targets/Target");
ForEach(*cfgTargets)
targets.append(cfgTargets->query().queryProp(NULL));
Expand Down Expand Up @@ -2003,18 +1996,15 @@ int CWsEclBinding::submitWsEclWorkunit(IEspContext & context, WsEclWuInfo &wsinf
if (httpreq)
{
StringBuffer globalId, callerId;
StringAttr globalIdHeader, callerIdHeader;
wsecl->getHttpGlobalIdHeader(httpreq, globalId, globalIdHeader);
wsecl->getHttpCallerIdHeader(httpreq, callerId, callerIdHeader);
wsecl->getHttpGlobalIdHeader(httpreq, globalId);
wsecl->getHttpCallerIdHeader(httpreq, callerId);
if (globalId.length())
{
workunit->setDebugValue("GlobalId", globalId.str(), true);
workunit->setDebugValue("GlobalIdHeader", globalIdHeader.str(), true); //use same header received

StringBuffer localId;
appendGloballyUniqueId(localId);
workunit->setDebugValue("CallerId", localId.str(), true); //our localId becomes caller id for the next hop
workunit->setDebugValue("CallerIdHeader", callerIdHeader.str(), true); //use same header received
DBGLOG("GlobalId: %s, CallerId: %s, LocalId: %s, Wuid: %s", globalId.str(), callerId.str(), localId.str(), wuid.str());
}
IProperties *params = httpreq->queryParameters();
Expand Down Expand Up @@ -2103,19 +2093,18 @@ void CWsEclBinding::sendRoxieRequest(const char *target, StringBuffer &req, Stri
if (httpreq)
{
StringBuffer globalId, callerId;
StringAttr globalIdHeader, callerIdHeader;
wsecl->getHttpGlobalIdHeader(httpreq, globalId, globalIdHeader);
wsecl->getHttpCallerIdHeader(httpreq, callerId, callerIdHeader);
wsecl->getHttpGlobalIdHeader(httpreq, globalId);
wsecl->getHttpCallerIdHeader(httpreq, callerId);

if (globalId.length())
{
headers.setown(createProperties());
headers->setProp(globalIdHeader, globalId);
headers->setProp(kGlobalIdHttpHeaderName, globalId);

StringBuffer localId;
appendGloballyUniqueId(localId);
if (localId.length())
headers->setProp(callerIdHeader, localId);
headers->setProp(kCallerIdHttpHeaderName, localId);
DBGLOG("GlobalId: %s, CallerId: %s, LocalId: %s", globalId.str(), callerId.str(), localId.str());
}

Expand Down
37 changes: 7 additions & 30 deletions esp/services/ws_ecl/ws_ecl_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ class CWsEclService : public CInterface,
StringArray targets;
StringAttr auth_method;
StringAttr portal_URL;
StringAttr globalIdHttpHeader;
StringAttr callerIdHttpHeader;
unsigned roxieTimeout;
unsigned workunitTimeout;

Expand All @@ -111,50 +109,29 @@ class CWsEclService : public CInterface,
virtual bool init(const char * name, const char * type, IPropertyTree * cfg, const char * process);
virtual void setContainer(IEspContainer * container){}

inline bool getHttpIdHeader(CHttpRequest *request, const char *header, StringBuffer &value, StringAttr &nameused)
inline bool getHttpIdHeader(CHttpRequest *request, const char *header, StringBuffer &value)
{
if (!header || !*header)
return false;

request->getHeader(header, value.clear());
if (value.length())
{
nameused.set(header);
return true;
}
return false;
}

StringBuffer &getHttpGlobalIdHeader(CHttpRequest *request, StringBuffer &value, StringAttr &nameused)
StringBuffer &getHttpGlobalIdHeader(CHttpRequest *request, StringBuffer &value)
{
if (!getHttpIdHeader(request, globalIdHttpHeader, value, nameused))
{
if (!getHttpIdHeader(request, "Global-Id", value, nameused))
getHttpIdHeader(request, "HPCC-Global-Id", value, nameused);
}
if (!getHttpIdHeader(request, kGlobalIdHttpHeaderName, value))
getHttpIdHeader(request, kLegacyGlobalIdHttpHeaderName, value);
return value;
}
StringBuffer &getHttpCallerIdHeader(CHttpRequest *request, StringBuffer &value, StringAttr &nameused)
StringBuffer &getHttpCallerIdHeader(CHttpRequest *request, StringBuffer &value)
{
if (!getHttpIdHeader(request, callerIdHttpHeader, value, nameused))
{
if (!getHttpIdHeader(request, "Caller-Id", value, nameused))
getHttpIdHeader(request, "HPCC-Caller-Id", value, nameused);
}
if (!getHttpIdHeader(request, kCallerIdHttpHeaderName, value))
getHttpIdHeader(request, kLegacyCallerIdHttpHeaderName, value);
return value;
}
const char *queryGlobalIdHeaderName()
{
if (!globalIdHttpHeader.isEmpty())
return globalIdHttpHeader;
return "HPCC-Global-Id"; //HPCC default
}
const char *queryCallerIdHeaderName()
{
if (!callerIdHttpHeader.isEmpty())
return callerIdHttpHeader;
return "HPCC-Caller-Id"; //HPCC default
}

bool unsubscribeServiceFromDali() override {return true;}
bool subscribeServiceToDali() override {return false;}
Expand Down
10 changes: 0 additions & 10 deletions helm/hpcc/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1740,16 +1740,6 @@
"minimum": 0,
"description": "Timeout (in ms) before high priority requests are resent to agents"
},
"httpCallerIdHeader": {
"type": "string",
"default": "HPCC-Caller-Id",
"description": "HTTP Header field to use for sending and receiving CallerId"
},
"httpGlobalIdHeader": {
"type": "string",
"default": "HPCC-Global-Id",
"description": "HTTP Header field to use for sending and receiving GlobalId"
},
"ignoreOrphans": {
"type": "boolean",
"default": true,
Expand Down
14 changes: 0 additions & 14 deletions roxie/ccd/ccd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,6 @@ class ContextLogger : implements IRoxieContextLogger, public CInterface
start = msTick();
channel = 0;
aborted = false;
if ( topology && topology->hasProp("@httpGlobalIdHeader"))
setHttpIdHeaderNames(topology->queryProp("@httpGlobalIdHeader"), topology->queryProp("@httpCallerIdHeader"));
}

void outputXML(IXmlStreamFlusher &out)
Expand Down Expand Up @@ -764,18 +762,6 @@ class ContextLogger : implements IRoxieContextLogger, public CInterface
{
return logTrace.queryLocalId();
}
virtual void setHttpIdHeaderNames(const char *global, const char *caller) override
{
logTrace.setHttpIdHeaderNames(global, caller);
}
virtual const char *queryGlobalIdHttpHeaderName() const override
{
return logTrace.queryGlobalIdHTTPHeaderName();
}
virtual const char *queryCallerIdHttpHeaderName() const override
{
return logTrace.queryCallerIdHTTPHeaderName();
}
virtual const CRuntimeStatisticCollection & queryStats() const override
{
return stats;
Expand Down
12 changes: 0 additions & 12 deletions roxie/ccd/ccdcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,18 +1399,6 @@ class CRoxieContextBase : implements IRoxieAgentContext, implements ICodeContext
{
return logctx.queryLocalId();
}
virtual void setHttpIdHeaderNames(const char *global, const char *caller) override
{
const_cast<IRoxieContextLogger&>(logctx).setHttpIdHeaderNames(global, caller);
}
virtual const char *queryGlobalIdHttpHeaderName() const override
{
return logctx.queryGlobalIdHttpHeaderName();
}
virtual const char *queryCallerIdHttpHeaderName() const override
{
return logctx.queryCallerIdHttpHeaderName();
}
virtual const CRuntimeStatisticCollection & queryStats() const override
{
return logctx.queryStats();
Expand Down
26 changes: 8 additions & 18 deletions roxie/ccd/ccdprotocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1687,27 +1687,19 @@ class RoxieSocketWorker : public ProtocolQueryWorker
return id;
}

const char *queryRequestGlobalIdHeader(HttpHelper &httpHelper, IContextLogger &logctx, StringAttr &headerused)
const char *queryRequestGlobalIdHeader(HttpHelper &httpHelper, IContextLogger &logctx)
{
const char *id = queryRequestIdHeader(httpHelper, logctx.queryGlobalIdHttpHeaderName(), headerused);
const char *id = httpHelper.queryRequestHeader(kGlobalIdHttpHeaderName);
if (!id || !*id)
{
id = queryRequestIdHeader(httpHelper, "Global-Id", headerused);
if (!id || !*id)
id = queryRequestIdHeader(httpHelper, "HPCC-Global-Id", headerused);
}
id = httpHelper.queryRequestHeader(kLegacyGlobalIdHttpHeaderName); // Backward compatibility - passed on as global-id
return id;
}

const char *queryRequestCallerIdHeader(HttpHelper &httpHelper, IContextLogger &logctx, StringAttr &headerused)
const char *queryRequestCallerIdHeader(HttpHelper &httpHelper, IContextLogger &logctxheaderused)
{
const char *id = queryRequestIdHeader(httpHelper, logctx.queryCallerIdHttpHeaderName(), headerused);
const char *id = httpHelper.queryRequestHeader(kCallerIdHttpHeaderName);
if (!id || !*id)
{
id = queryRequestIdHeader(httpHelper, "Caller-Id", headerused);
if (!id || !*id)
id = queryRequestIdHeader(httpHelper, "HPCC-Caller-Id", headerused);
}
id = httpHelper.queryRequestHeader(kLegacyCallerIdHttpHeaderName); // Backward compatibility - passed on as caller-id
return id;
}

Expand Down Expand Up @@ -1804,10 +1796,8 @@ class RoxieSocketWorker : public ProtocolQueryWorker
mlResponseFmt = httpHelper.queryResponseMlFormat();
mlRequestFmt = httpHelper.queryRequestMlFormat();

StringAttr globalIdHeader, callerIdHeader;
const char *globalId = queryRequestGlobalIdHeader(httpHelper, logctx, globalIdHeader);
const char *callerId = queryRequestCallerIdHeader(httpHelper, logctx, callerIdHeader);
logctx.setHttpIdHeaderNames(globalIdHeader, callerIdHeader);
const char *globalId = queryRequestGlobalIdHeader(httpHelper, logctx);
const char *callerId = queryRequestCallerIdHeader(httpHelper, logctx);
if (globalId && *globalId)
msgctx->setTransactionId(globalId, callerId, true); //logged and forwarded through SOAPCALL/HTTPCALL
else if (callerId && *callerId)
Expand Down
25 changes: 0 additions & 25 deletions roxie/ccd/ccdserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,6 @@ class IndirectAgentContext : implements IRoxieAgentContext, public CInterface
{
return ctx->queryLocalId();
}
virtual void setHttpIdHeaderNames(const char *global, const char *caller)
{
ctx->setHttpIdHeaderNames(global, caller);
}
virtual const char *queryGlobalIdHttpHeaderName() const
{
return ctx->queryGlobalIdHttpHeaderName();
}
virtual const char *queryCallerIdHttpHeaderName() const override
{
return ctx->queryCallerIdHttpHeaderName();
}
virtual const QueryOptions &queryOptions() const
{
return ctx->queryOptions();
Expand Down Expand Up @@ -1381,19 +1369,6 @@ class CRoxieServerActivity : implements CInterfaceOf<IRoxieServerActivity>, impl
{
return ctx ? ctx->queryLocalId() : nullptr;
}
virtual void setHttpIdHeaderNames(const char *global, const char *caller) override
{
if (ctx)
ctx->setHttpIdHeaderNames(global, caller);
}
virtual const char *queryGlobalIdHttpHeaderName() const override
{
return ctx ? ctx->queryGlobalIdHttpHeaderName() : "HPCC-Global-Id";
}
virtual const char *queryCallerIdHttpHeaderName() const override
{
return ctx ? ctx->queryCallerIdHttpHeaderName() : "HPCC-Caller-Id";
}
virtual const CRuntimeStatisticCollection & queryStats() const override
{
return stats;
Expand Down
12 changes: 0 additions & 12 deletions system/jlib/jlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2883,18 +2883,6 @@ class DummyLogCtx : implements IContextLogger
{
return logTrace.queryLocalId();
}
virtual void setHttpIdHeaderNames(const char *global, const char *caller) override
{
logTrace.setHttpIdHeaderNames(global, caller);
}
virtual const char *queryGlobalIdHttpHeaderName() const override
{
return logTrace.queryGlobalIdHTTPHeaderName();
}
virtual const char *queryCallerIdHttpHeaderName() const override
{
return logTrace.queryCallerIdHTTPHeaderName();
}
virtual const CRuntimeStatisticCollection &queryStats() const override
{
throwUnexpected();
Expand Down
3 changes: 0 additions & 3 deletions system/jlib/jlog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1254,11 +1254,8 @@ interface jlib_decl IContextLogger : extends IInterface
virtual unsigned queryTraceLevel() const = 0;

virtual void setGlobalId(const char *id, SocketEndpoint &ep, unsigned pid) = 0;
virtual void setHttpIdHeaderNames(const char *global, const char *caller) = 0;
virtual const char *queryGlobalId() const = 0;
virtual const char *queryLocalId() const = 0;
virtual const char *queryGlobalIdHttpHeaderName() const = 0;
virtual const char *queryCallerIdHttpHeaderName() const = 0;
virtual void setCallerId(const char *id) = 0;
virtual const char *queryCallerId() const = 0;
virtual const CRuntimeStatisticCollection & queryStats() const = 0;
Expand Down
Loading

0 comments on commit 7800de0

Please sign in to comment.