Skip to content

Commit a3e6458

Browse files
committed
HPCC-33885 WIP
Signed-off-by: Dave Streeter <[email protected]>
1 parent 2ebac5a commit a3e6458

File tree

2 files changed

+59
-41
lines changed

2 files changed

+59
-41
lines changed

helm/hpcc/templates/_helpers.tpl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{/*
22
33
--- DO NOT EDIT THIS FILE - all configuration of HPCC platform should be done via values.yaml ----
4-
4+
55
##############################################################################
66
77
HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
@@ -17,7 +17,7 @@
1717
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1818
See the License for the specific language governing permissions and
1919
limitations under the License.
20-
20+
2121
##############################################################################
2222
2323
*/}}
@@ -64,7 +64,7 @@ Translate a port list to a comma-separated list
6464
{{- $local := dict "first" true -}}
6565
{{- range $key, $value := . -}}{{- if not $local.first -}},{{- end -}}{{- $value -}}{{- $_ := set $local "first" false -}}{{- end -}}
6666
{{- else -}}
67-
{{- . -}}
67+
{{- . -}}
6868
{{- end -}}
6969
{{- end -}}
7070

@@ -877,7 +877,7 @@ Generates image information into env. variables used at runtime for runtime plat
877877
{{- end -}}
878878

879879
{{/*
880-
Add image attributes for a component
880+
Add image attributes for a component
881881
Pass in a dictionary with root, me and imagename defined
882882
*/}}
883883
{{- define "hpcc.addImageAttrs" -}}
@@ -890,7 +890,7 @@ imagePullPolicy: {{ .root.Values.global.image.pullPolicy | default "IfNotPresent
890890
{{- end -}}
891891

892892
{{/*
893-
Add image pull credentials for a component
893+
Add image pull credentials for a component
894894
Pass in a dictionary with root and me defined
895895
*/}}
896896
{{- define "hpcc.addImagePullSecrets" -}}
@@ -1237,7 +1237,7 @@ Generate instance queue names
12371237
{{- range $.Values.roxie -}}
12381238
{{- if not .disabled -}}
12391239
- name: {{ .name }}
1240-
type: roxie
1240+
type: roxie
12411241
{{- if hasKey . "prefix" }}
12421242
prefix: {{ .prefix }}
12431243
{{- end }}
@@ -1660,12 +1660,12 @@ spec:
16601660
loadBalancerSourceRanges:
16611661
{{- if ne $lvars.type "LoadBalancer" -}}
16621662
{{- $_ := fail (printf "loadBalanceSourceRanges invalid unless service type is LoadBalancer" ) -}}
1663-
{{- end -}}
1663+
{{- end -}}
16641664
{{- range $cidr := $lvars.loadBalancerSourceRanges }}
16651665
- {{ $cidr }}
16661666
{{- end }}
16671667
{{ end }}
1668-
{{- if $lvars.ingress }}
1668+
{{- if $lvars.ingress }}
16691669
---
16701670
apiVersion: networking.k8s.io/v1
16711671
kind: NetworkPolicy
@@ -1727,7 +1727,7 @@ dali data
17271727
A template to generate the standard app.kubernetes.io labels and standard HPCC labels
17281728
17291729
Pass in root, name, component, instance
1730-
root name(k8s application name) component(component within the application, can be same as app) instance
1730+
root name(k8s application name) component(component within the application, can be same as app) instance
17311731
17321732
https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/
17331733
----------------------------+-------------------------------------------------------------+----------
@@ -2571,7 +2571,7 @@ e.g. a cache of secrets, with an auto reload/refresh mechanism, or 'replicas'.
25712571
{{- range $topKey, $topVal := $configElementDict -}}
25722572
{{- if or (and (not $outerIsWild) (eq $outerKey $topKey)) (and $outerIsWild (regexMatch $outerKey $topKey)) -}}
25732573
{{- if not $hasSubKey -}}
2574-
{{- $configElementDict = unset $configElementDict $topKey -}}
2574+
{{- unset $configElementDict $topKey -}}
25752575
{{- else -}}
25762576
{{- $innerDict := get $configElementDict $topKey | default dict -}}
25772577
{{- if (kindIs "map" $innerDict) -}}
@@ -2623,7 +2623,7 @@ globalExcludeList below is a hard-coded list of global keys to exclude.
26232623
26242624
*/}}
26252625
{{- define "hpcc.getConfigSHA" }}
2626-
{{- $globalExcludeList := list "~.*::replicas" "~.*::vaults" -}}
2626+
{{- $globalExcludeList := list "~.*::logging" "~.*::replicas" "~.*::vaults" -}}
26272627
{{- $globalExcludeSectionRegexList := list ".*-job.yaml$" -}}
26282628
{{- $componentExcludeList := ternary (splitList "," (.excludeKeys | default "")) list (hasKey . "excludeKeys") -}}
26292629
{{- $combinedExcludeKeyList := concat $globalExcludeList $componentExcludeList -}}
@@ -2803,7 +2803,7 @@ Pass in dict with .root, .me and .labels
28032803
{{- $_ := set $lvars "egress" .me.egress -}}
28042804
{{- end -}}
28052805
{{- end -}}
2806-
{{- if $lvars.egress }}
2806+
{{- if $lvars.egress }}
28072807
apiVersion: networking.k8s.io/v1
28082808
kind: NetworkPolicy
28092809
metadata:
@@ -2921,7 +2921,7 @@ spec:
29212921
minReplicas: {{ (hasKey .hpa "minReplicas") | ternary .hpa.minReplicas 1 }}
29222922
maxReplicas: {{ .hpa.maxReplicas }}
29232923
{{- if hasKey .hpa "behavior" }}
2924-
behavior:
2924+
behavior:
29252925
{{- if hasKey .hpa.behavior "scaleDown" }}
29262926
scaleDown:
29272927
{{- include "hpcc.addHPABehaviorScale" (dict "behaviorScale" .hpa.behavior.scaleDown) | nindent 6 }}

system/jlib/jlog.cpp

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,9 @@ void SessionLogMsgFilter::addToPTree(IPropertyTree * tree) const
814814
tree->addPropTree("filter", filterTree);
815815
}
816816

817-
bool RegexLogMsgFilter::includeMessage(const LogMsg & msg) const
818-
{
819-
if(localFlag && msg.queryRemoteFlag()) return false;
817+
bool RegexLogMsgFilter::includeMessage(const LogMsg & msg) const
818+
{
819+
if(localFlag && msg.queryRemoteFlag()) return false;
820820
SpinBlock b(lock);
821821
return const_cast<RegExpr &>(regex).find(msg.queryText()) != NULL;
822822
}
@@ -1303,7 +1303,7 @@ void RollingFileLogMsgHandler::doRollover(bool daily, const char *forceName)
13031303
}
13041304
}
13051305
}
1306-
if(!handle)
1306+
if(!handle)
13071307
{
13081308
handle = getNullHandle();
13091309
OWARNLOG("RollingFileLogMsgHandler::doRollover : could not open log file %s for output", filename.str());
@@ -1420,9 +1420,9 @@ void LogMsgMonitor::addToPTree(IPropertyTree * tree) const
14201420
void CLogMsgManager::MsgProcessor::push(LogMsg * msg)
14211421
{
14221422
//assertex(more); an assertex will just recurse here
1423-
if (!more) // we are effective stopped so don't bother even dropping (and leak parameter) as drop will involve
1424-
// interaction with the base class which is stopped and could easily crash (as this condition
1425-
// is expected not to occur - typically occurs if the user has incorrectly called exit on one thread
1423+
if (!more) // we are effective stopped so don't bother even dropping (and leak parameter) as drop will involve
1424+
// interaction with the base class which is stopped and could easily crash (as this condition
1425+
// is expected not to occur - typically occurs if the user has incorrectly called exit on one thread
14261426
// while still in the process of logging on another)
14271427
// cf Bug #53695 for more discussion of the issue
14281428
return;
@@ -1578,14 +1578,14 @@ void CLogMsgManager::enterQueueingMode()
15781578

15791579
void CLogMsgManager::setQueueBlockingLimit(unsigned lim)
15801580
{
1581-
CriticalBlock crit(modeLock);
1581+
CriticalBlock crit(modeLock);
15821582
if(processor)
15831583
processor->setBlockingLimit(lim);
15841584
}
15851585

15861586
void CLogMsgManager::setQueueDroppingLimit(unsigned lim, unsigned numToDrop)
15871587
{
1588-
CriticalBlock crit(modeLock);
1588+
CriticalBlock crit(modeLock);
15891589
if(processor)
15901590
processor->setDroppingLimit(lim, numToDrop);
15911591
}
@@ -1925,8 +1925,8 @@ void CLogMsgManager::addAllMonitorsToPTree(IPropertyTree * tree) const
19251925
monitors.item(i).addToPTree(tree);
19261926
}
19271927

1928-
bool CLogMsgManager::rejectsCategory(const LogMsgCategory & cat) const
1929-
{
1928+
bool CLogMsgManager::rejectsCategory(const LogMsgCategory & cat) const
1929+
{
19301930
if (!prefilter.includeCategory(cat))
19311931
return true;
19321932

@@ -2329,7 +2329,6 @@ class CNullManager : implements ILogMsgManager
23292329

23302330
static CNullManager nullManager;
23312331
static Singleton<IRemoteLogAccess> logAccessor;
2332-
static CriticalSection logAccessCrit;
23332332

23342333
MODULE_INIT(INIT_PRIORITY_JLOG)
23352334
{
@@ -2377,6 +2376,7 @@ static constexpr unsigned queueLenDefault = 512;
23772376
static constexpr unsigned queueDropDefault = 0; // disabled by default
23782377
static constexpr bool useSysLogDefault = false;
23792378

2379+
static CConfigUpdateHook configUpdateHook;
23802380
void setupContainerizedLogMsgHandler()
23812381
{
23822382
Owned<IPropertyTree> logConfig = getComponentConfigSP()->getPropTree("logging");
@@ -2391,22 +2391,25 @@ void setupContainerizedLogMsgHandler()
23912391
if (logConfig->hasProp(logFormatAtt))
23922392
{
23932393
const char *logFormat = logConfig->queryProp(logFormatAtt);
2394-
bool newFormatDetected = false;
2394+
HandleLogMsgHandler *previousStderrHandler{nullptr};
23952395
if (streq(logFormat, "xml"))
23962396
{
2397+
previousStderrHandler = theStderrHandler;
23972398
theStderrHandler = new HandleLogMsgHandlerXML(stderr, MSGFIELD_STANDARD);
2398-
newFormatDetected = true;
23992399
}
24002400
else if (streq(logFormat, "json"))
24012401
{
2402+
previousStderrHandler = theStderrHandler;
24022403
theStderrHandler = new HandleLogMsgHandlerJSON(stderr, MSGFIELD_STANDARD);
2403-
newFormatDetected = true;
24042404
}
24052405
else if (!streq(logFormat, "table"))
24062406
LOG(MCoperatorWarning, "JLog: Invalid log format configuration detected '%s'!", logFormat);
24072407

2408-
if (newFormatDetected)
2408+
if (previousStderrHandler)
2409+
{
24092410
theManager->resetMonitors();
2411+
delete previousStderrHandler;
2412+
}
24102413
}
24112414

24122415
if (logConfig->hasProp(logFieldsAtt))
@@ -2464,15 +2467,30 @@ void setupContainerizedLogMsgHandler()
24642467
unsigned postMortemLines = logConfig->getPropInt(capturePostMortemAtt, 0);
24652468
if (postMortemLines)
24662469
{
2470+
PostMortemLogMsgHandler *previousPostMortemHandler{nullptr};
2471+
if (thePostMortemHandler)
2472+
{
2473+
previousPostMortemHandler = thePostMortemHandler;
2474+
queryLogMsgManager()->removeMonitor(thePostMortemHandler);
2475+
}
2476+
24672477
// augment postmortem files with <pid> to avoid clashes where multiple processes are running within
24682478
// same process space, e.g. hthor processes running in same k8s container
24692479
unsigned pid = GetCurrentProcessId();
24702480
VStringBuffer portMortemFileBase("/tmp/postmortem.%u.log", pid);
24712481

24722482
thePostMortemHandler = new PostMortemLogMsgHandler(portMortemFileBase, postMortemLines, MSGFIELD_STANDARD);
24732483
queryLogMsgManager()->addMonitor(thePostMortemHandler, getCategoryLogMsgFilter(MSGAUD_all, MSGCLS_all, TopDetail));
2484+
2485+
delete previousPostMortemHandler;
24742486
}
24752487
}
2488+
2489+
auto updateConfigFunc = [](const IPropertyTree *oldComponentConfiguration, const IPropertyTree *oldGlobalConfiguration)
2490+
{
2491+
setupContainerizedLogMsgHandler();
2492+
};
2493+
configUpdateHook.installOnce(updateConfigFunc, false);
24762494
}
24772495

24782496
ILogMsgManager * queryLogMsgManager()
@@ -2504,7 +2522,7 @@ ISysLogEventLogger * querySysLogEventLogger()
25042522

25052523
ILogMsgHandler * getSysLogMsgHandler(unsigned fields)
25062524
{
2507-
return new SysLogMsgHandler(theSysLogEventLogger, fields);
2525+
return new SysLogMsgHandler(theSysLogEventLogger, fields);
25082526
}
25092527

25102528
#ifdef _WIN32
@@ -2555,7 +2573,7 @@ bool CSysLogEventLogger::win32Report(unsigned eventtype, unsigned category, unsi
25552573
char src[_MAX_PATH+1];
25562574
LPTSTR tail;
25572575
DWORD res = SearchPath(NULL,"JELOG.DLL",NULL,sizeof(src),src,&tail);
2558-
if (res>0)
2576+
if (res>0)
25592577
copyFile(path,src);
25602578
else
25612579
throw makeOsException(GetLastError());
@@ -2570,20 +2588,20 @@ bool CSysLogEventLogger::win32Report(unsigned eventtype, unsigned category, unsi
25702588

25712589
}
25722590
HKEY hk;
2573-
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\Seisint",
2591+
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\Seisint",
25742592
NULL, NULL, 0, KEY_ALL_ACCESS, NULL, &hk, NULL)==0) {
25752593
DWORD sizedata = 0;
25762594
DWORD type = REG_EXPAND_SZ;
25772595
if ((RegQueryValueEx(hk,"EventMessageFile",NULL, &type, NULL, &sizedata)!=0)||!sizedata) {
2578-
StringAttr str("%SystemRoot%\\System32\\JELOG.dll");
2596+
StringAttr str("%SystemRoot%\\System32\\JELOG.dll");
25792597
RegSetValueEx(hk,"EventMessageFile", 0, REG_EXPAND_SZ, (LPBYTE) str.get(), (DWORD)str.length() + 1);
25802598
RegSetValueEx(hk,"CategoryMessageFile", 0, REG_EXPAND_SZ, (LPBYTE) str.get(), (DWORD)str.length() + 1);
2581-
DWORD dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE | EVENTLOG_AUDIT_SUCCESS | EVENTLOG_AUDIT_FAILURE;
2599+
DWORD dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE | EVENTLOG_AUDIT_SUCCESS | EVENTLOG_AUDIT_FAILURE;
25822600
RegSetValueEx(hk, "TypesSupported", 0, REG_DWORD, (LPBYTE) &dwData, sizeof(DWORD));
25832601
dwData = 16;
25842602
RegSetValueEx(hk, "CategoryCount", 0, REG_DWORD, (LPBYTE) &dwData, sizeof(DWORD));
25852603
}
2586-
RegCloseKey(hk);
2604+
RegCloseKey(hk);
25872605
}
25882606
hEventLog = RegisterEventSource(NULL,"Seisint");
25892607
if (!hEventLog) {
@@ -2621,8 +2639,8 @@ bool CSysLogEventLogger::win32Report(unsigned eventtype, unsigned category, unsi
26212639

26222640
CSysLogEventLogger::~CSysLogEventLogger()
26232641
{
2624-
if (hEventLog!=0)
2625-
DeregisterEventSource(hEventLog);
2642+
if (hEventLog!=0)
2643+
DeregisterEventSource(hEventLog);
26262644
}
26272645

26282646
#else
@@ -2631,7 +2649,7 @@ CSysLogEventLogger::~CSysLogEventLogger()
26312649

26322650
#define CATEGORY_AUDIT_FUNCTION_REQUIRED
26332651
#define AUDIT_TYPES_BEGIN int auditTypeDataMap[NUM_AUDIT_TYPES+1] = {
2634-
#define MAKE_AUDIT_TYPE(name, type, categoryid, eventid, level) level,
2652+
#define MAKE_AUDIT_TYPE(name, type, categoryid, eventid, level) level,
26352653
#define AUDIT_TYPES_END 0 };
26362654
#include "jelogtype.hpp"
26372655
#undef CATEGORY_AUDIT_FUNCTION_REQUIRED
@@ -2932,7 +2950,7 @@ extern jlib_decl void UseSysLogForOperatorMessages(bool use)
29322950
return;
29332951
if (use) {
29342952
msgHandler = getSysLogMsgHandler();
2935-
ILogMsgFilter * operatorFilter = getCategoryLogMsgFilter(MSGAUD_operator, MSGCLS_all, DefaultDetail, true);
2953+
ILogMsgFilter * operatorFilter = getCategoryLogMsgFilter(MSGAUD_operator, MSGCLS_all, DefaultDetail, true);
29362954
queryLogMsgManager()->addMonitorOwn(msgHandler, operatorFilter);
29372955
}
29382956
else {
@@ -3435,15 +3453,15 @@ TraceFlags loadTraceFlags(const IPropertyTree *ptree, const std::initializer_lis
34353453
return dft;
34363454
}
34373455

3438-
void ctxlogReport(const LogMsgCategory & cat, const char * format, ...)
3456+
void ctxlogReport(const LogMsgCategory & cat, const char * format, ...)
34393457
{
34403458
va_list args;
34413459
va_start(args, format);
34423460
ctxlogReportVA(cat, NoLogMsgCode, format, args);
34433461
va_end(args);
34443462
}
34453463

3446-
void ctxlogReportVA(const LogMsgCategory & cat, const char * format, va_list args)
3464+
void ctxlogReportVA(const LogMsgCategory & cat, const char * format, va_list args)
34473465
{
34483466
ctxlogReportVA(cat, NoLogMsgCode, format, args);
34493467
}

0 commit comments

Comments
 (0)