-
Notifications
You must be signed in to change notification settings - Fork 306
HPCC-33885 Ensure persistent components do not restart, but pick up logging config changes #19783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HPCC-33885 Ensure persistent components do not restart, but pick up logging config changes #19783
Conversation
Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-33885 Jirabot Action Result: |
54c06d8
to
a3e6458
Compare
e9fa1b7
to
dbea252
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses HPCC-33885 by enhancing the logging configuration to allow persistent components to update their logging configuration on the fly without restarting. Key changes include:
- Adding a new pure virtual method queryFormatType() to log handler classes in jlog.ipp.
- Introducing queryMaxLinesToKeep() and setMaxLinesToKeep() in the ILogMsgHandler interface in jlog.hpp and their concrete implementations.
- Updating the containerized logging setup in jlog.cpp to support on‑the‑fly configuration updates and dynamic postmortem log line adjustments.
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
system/jlib/jlog.ipp | Adds queryFormatType() method to log handler classes and adjusts maxLinesToKeep. |
system/jlib/jlog.hpp | Extends ILogMsgHandler interface with new max-lines methods and updates function signature. |
system/jlib/jlog.cpp | Refactors setupContainerizedLogMsgHandler to support live updates and adjusts postmortem handler logic. |
Files not reviewed (1)
- helm/hpcc/templates/_helpers.tpl: Language not supported
system/jlib/jlog.cpp
Outdated
{ | ||
// Alow the first config update hook call to update the config as if it was not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: 'Alow' should be corrected to 'Allow'.
// Alow the first config update hook call to update the config as if it was not | |
// Allow the first config update hook call to update the config as if it was not |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@streeterd - haven't looked beyond the unintended release of a change to plugins/CMakeLists.txt ..
Please self-review in github before tagging, to weed out issues like this.
Removed in 6522db7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@streeterd - discussed offline. I think this needs to be simplified with setupContainerizedLogging split into 2 functions, with a configureHandlers() or similarly named, called from the setup function and installed as a hook.
Such that configureHandlers only changes properties of the already created handlers.
Should still complain if format detection spotted.
A postmortem maxlines change will need to be coded carefully.
In fact, it may be best to do that as a follow on PR - smaller PR's are better PR's.
5dc4dc7
to
ca893c0
Compare
@@ -1142,7 +1142,7 @@ | |||
"description": "Number of log entries to drop from the log queue when it is full. Disabled if 0, or if queueLength is 0", | |||
"default": 0 | |||
}, | |||
"dataFormat": { | |||
"format": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the logging format property name to format
.
1479d7c
to
2452fe9
Compare
The failure of the K8s Regression Suite is being resolved under PR: hpcc-systems/hpcc4j#815 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@streeterd - tagging you back for now, after pushing commit.
system/jlib/jlog.ipp
Outdated
@@ -438,6 +438,7 @@ public: | |||
int flush() { CriticalBlock block(crit); return fflush(handle); } | |||
bool getLogName(StringBuffer &name) const { return false; } | |||
offset_t getLogPosition(StringBuffer &name) const { return 0; } | |||
virtual LogHandlerFormat queryFormatType() const = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtual is good, but it jars that other existing virtuals methods are not decorated like this. In cases like this, it's worth updating the other methods, rather than sacrifice the new code for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, though not strictly needed for this change, I think it would be better to add to interface too (ILogMsgHandler), as it stands out as an anomaly otherwise.
And, given that, these should really all have 'override's on their definitions too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jakesmith Fixed in 2991719
c98a810
to
2991719
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@streeterd - please see comments.
system/jlib/jlog.cpp
Outdated
else if (streq(newFormatString, "table")) | ||
newFormat = LOGFORMAT_table; | ||
else | ||
LOG(MCoperatorWarning, "JLog: Invalid log format configuration detected '%s'!", newFormatString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OWARNLOG more concise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 28782b7
@@ -2473,6 +2517,7 @@ void setupContainerizedLogMsgHandler() | |||
queryLogMsgManager()->addMonitor(thePostMortemHandler, getCategoryLogMsgFilter(MSGAUD_all, MSGCLS_all, TopDetail)); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be call after this line to updateStdErrLogHandler ..
as it stands, nothing is using the config properties at the outset..until there's an update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ad9d66
system/jlib/jlog.hpp
Outdated
@@ -912,6 +914,7 @@ extern jlib_decl ILogMsgHandler * queryStderrLogMsgHandler(); | |||
extern jlib_decl ILogMsgHandler * queryPostMortemLogMsgHandler(); | |||
extern jlib_decl bool copyPostMortemLogging(const char *target, bool clear); | |||
extern jlib_decl void setupContainerizedLogMsgHandler(); | |||
bool configureHandlers(bool rejectOnTheFlyChanges); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing extern jlib_decl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but actually this is old, should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ad9d66
bool needsPrep() const override { return false; } | ||
void prep() override {} | ||
void addToPTree(IPropertyTree * tree) const override; | ||
virtual LogHandlerFormat queryFormatType() const override { return LOGFORMAT_json; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please decorate other methods with 'virtual' too to be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ad9d66
system/jlib/jlog.ipp
Outdated
int flush() override { return 0; } | ||
bool getLogName(StringBuffer &name) const override { name.append(filename); return true; } | ||
offset_t getLogPosition(StringBuffer &name) const override { CriticalBlock block(crit); name.append(filename); return fstr->tell(); } | ||
LogHandlerFormat queryFormatType() const override { return LOGFORMAT_undefined; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please decorate methods with 'virtual' as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ad9d66
system/jlib/jlog.ipp
Outdated
int flush() override { return 0; } | ||
bool getLogName(StringBuffer &name) const override { return false; } | ||
offset_t getLogPosition(StringBuffer &logFileName) const override { return 0; } | ||
LogHandlerFormat queryFormatType() const override { return LOGFORMAT_undefined; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please decorate methods with 'virtual' as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ad9d66
system/mp/mplog.ipp
Outdated
void prep() override {} | ||
void addToPTree(IPropertyTree * tree) const override; | ||
unsigned queryMessageFields() const override { return MSGFIELD_all; } | ||
void setMessageFields(unsigned _fields = MSGFIELD_all) override {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please decorate methods with 'virtual' as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ad9d66
system/mp/mplog.ipp
Outdated
offset_t getLogPosition(StringBuffer &name) const { return 0; } | ||
bool getLogName(StringBuffer &name) const override { return false; } | ||
offset_t getLogPosition(StringBuffer &name) const override { return 0; } | ||
LogHandlerFormat queryFormatType() const override { return LOGFORMAT_undefined; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please decorate methods with 'virtual' as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ad9d66
system/jlib/jlog.cpp
Outdated
void setupContainerizedLogMsgHandler() | ||
// returns LOGFORMAT_undefined if format has not changed | ||
// NB: returns LOGFORMAT_table if no format specified (i.e. this is the default) | ||
LogHandlerFormat hasLogFormatChanged(const IPropertyTree *logConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasXX doesn't really make sense anymore, I suggest renaming to 'getConfigHandlerFormat'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ad9d66
d66e5a6
to
9ad9d66
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@streeterd - 1 trivial issue remaining (see comment).
system/jlib/jlog.ipp
Outdated
virtual int flush() override { CriticalBlock block(crit); return fflush(handle); } | ||
virtual bool getLogName(StringBuffer &name) const override { CriticalBlock block(crit); name.append(filename); return true; } | ||
virtual offset_t getLogPosition(StringBuffer &name) const override { CriticalBlock block(crit); fflush(handle); name.append(filename); return ftell(handle); } | ||
virtual LogHandlerFormat queryFormatType() const override { return LOGFORMAT_undefined; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed one.. RollingFileLogMsgHandler is implicitly LOGFORMAT_table (see its handleMessage impl).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in e647cc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@streeterd - a couple of minor comments.
system/jlib/jlog.cpp
Outdated
if (newFormat != LOGFORMAT_undefined) | ||
{ | ||
OWARNLOG("JLog: Ignoring log format configuration change on the fly, as it is not supported in a containerized environment"); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the message implies only the format change will be ignored, but the return means all changes will be ignored.
Should either say [all] logging configure update ignore (not just format), or continue to call updateStdErrLogHandler.
I think probably should just ignore format and continue to call udpateStdErrLogHandler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant still issue the warning that ignoring format change, but continue...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added code back in to warn if log format changes and carry on in 80f0769
switch (newFormat) | ||
{ | ||
case LOGFORMAT_xml: | ||
theStderrHandler = new HandleLogMsgHandlerXML(stderr, MSGFIELD_STANDARD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a separate existing JIRA to fix the pre-existing leak here?
(Can you link it to this JIRA if so?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9bf2dbe
New JIRA https://hpccsystems.atlassian.net/browse/HPCC-34101
system/jlib/jlog.cpp
Outdated
@@ -2462,7 +2506,7 @@ void setupContainerizedLogMsgHandler() | |||
UseSysLogForOperatorMessages(); | |||
|
|||
unsigned postMortemLines = logConfig->getPropInt(capturePostMortemAtt, 0); | |||
if (postMortemLines) | |||
if (postMortemLines && !thePostMortemHandler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding && !thePostMortemHandler suggests, that it's valid to already be set.
If it were already set, then postMortemLines from config would be ignored.
I think best to remove this new check for now, but open a JIRA to support postMortemLines changing, and support it without recreating the handler, i.e. adding a method that sets it the existing handler, and manages increase/decrease/rollover carefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9bf2dbe
New JIRA https://hpccsystems.atlassian.net/browse/HPCC-34101
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@streeterd - 1 comment re. removal of format change warning
@@ -2442,6 +2442,12 @@ static void loggingSetupUpdate(const IPropertyTree *oldComponentConfiguration, c | |||
return; | |||
} | |||
|
|||
LogHandlerFormat newFormat = getConfigHandlerFormat(logConfig); | |||
if (newFormat != LOGFORMAT_undefined) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trivial/style/don't change: normally we avoid { } for single line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@streeterd - looks good.
Please squash.
80f0769
to
24201ce
Compare
@jakesmith squashed |
@ghalliday - please sanity check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Only a few trivial comments, not worth changing.
virtual LogHandlerFormat queryFormatType() const override | ||
{ | ||
return LOGFORMAT_undefined; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trivial: extraneous semicolon
virtual int flush() override { return 0; } | ||
virtual bool getLogName(StringBuffer &name __attribute__((unused))) const override { return false; } | ||
virtual offset_t getLogPosition(StringBuffer &logFileName __attribute__((unused))) const override { return 0; }; | ||
virtual LogHandlerFormat queryFormatType() const override { return LOGFORMAT_undefined; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar extra ;, and on line above.
@@ -691,6 +691,7 @@ interface jlib_decl ILogMsgFilter : public IInterface | |||
|
|||
typedef enum | |||
{ | |||
LOGFORMAT_undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this ok, but I had to double check none of these values were serialized - because this changes all the values.
@streeterd needs rebasing before it can be merged. |
…ut restarts Implement ability to change to table log format. Add ability for on-the-fly logging configuration changes. Validate on-the-fly logging configuration changes to prevent log format change. Signed-off-by: Dave Streeter <[email protected]>
24201ce
to
4de8fc8
Compare
@ghalliday rebased on candidate-9.12.x |
0c8a2ae
into
hpcc-systems:candidate-9.12.x
Jirabot Action Result: |
Type of change:
Checklist:
Smoketest:
Testing: