Skip to content
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-31775 Hook jlog to use api to log operator messages #18685

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

shamser
Copy link
Contributor

@shamser shamser commented May 21, 2024

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

Copy link

Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-31775

Jirabot Action Result:

@shamser shamser force-pushed the issue31775 branch 2 times, most recently from 2a91c83 to 868c78c Compare May 22, 2024 12:36
@shamser shamser force-pushed the issue31775 branch 2 times, most recently from fa54e96 to 7e305d4 Compare May 30, 2024 12:52
@shamser shamser changed the base branch from master to candidate-9.8.x October 11, 2024 12:52
@shamser shamser marked this pull request as ready for review October 11, 2024 12:52
@shamser shamser requested a review from jakesmith October 11, 2024 12:53
@shamser shamser changed the base branch from candidate-9.8.x to master November 20, 2024 12:42
Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shamser - looks good in general. Please see comments.

dali/base/sysinfologger.cpp Outdated Show resolved Hide resolved
dali/base/sysinfologger.cpp Outdated Show resolved Hide resolved
@@ -141,6 +142,8 @@ bool initClientProcess(IGroup *servergrp, DaliClientRole role, unsigned mpport,
covengrp->Release();
queryLogMsgManager()->setSession(myProcessSession());

if (getGlobalConfigSP()->getPropBool("@enableGlobalSysLog", true))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure want to default on yet?
should add a entry in values.schema.json and a commented out entry in values.yaml showing how it can be enabled (or disabled if enabled by default).

dali/base/daclient.cpp Outdated Show resolved Hide resolved
dali/base/sysinfologger.hpp Outdated Show resolved Hide resolved
id++;
}
Owned<ISysInfoLoggerMsgFilter> msgFilter = createSysInfoLoggerMsgFilter();
msgFilter->setVisibleOnly();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: to be later extended so service can pass filter types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing/unittests/dalitests.cpp Outdated Show resolved Hide resolved
dali/base/sysinfologger.cpp Outdated Show resolved Hide resolved
else
{
queryLogMsgManager()->removeMonitor(msgHandler);
msgHandler = NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: nullptr

ILogMsgFilter * operatorFilter = getCategoryLogMsgFilter(MSGAUD_operator,
MSGCLS_disaster|MSGCLS_error|MSGCLS_warning,
WarnMsgThreshold);
queryLogMsgManager()->addMonitorOwn(msgHandler, operatorFilter);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's slightly unsafe to pass ownership to the handler, but keep a reference to it (in the static).
Should change so it calls addMonitor( not addMonitorOwn, and change the static to static Owned msgHandler.
Also better if the static declaration is outside of the function, because being inside causes the compiler (>= c++11) to wrap them with thread safety code (and overhead).

Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shamser - please see follow comments/questions.

},
"enableGlobalSysLog": {
"type": "boolean",
"description" : "Enable the reporting of important user/operator messages in ECL Watch"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: may not involve the UI (eclwatch), e.g. may programmatically get these messages from the esp service via soap. I'd rephrase to "Enable centralized reporting of important user/operator logging messages"

@@ -24,6 +24,9 @@ global:
# logging sets the default logging information for all components. Can be overridden locally
logging:
detail: 80
# GlobalSysLog records user/operator messages to dali so that messages are reported in ECL Watch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: EclWatch may not be the only consumer/client of the service - I'd reword to convey that it is accessible via service (used by EclWatch)

@@ -142,8 +142,9 @@ bool initClientProcess(IGroup *servergrp, DaliClientRole role, unsigned mpport,
covengrp->Release();
queryLogMsgManager()->setSession(myProcessSession());

if (getGlobalConfigSP()->getPropBool("@enableGlobalSysLog", true))
UseDaliForOperatorMessages();
if (getComponentConfigSP()->getPropBool("logging/@enableGlobalSysLog") || getGlobalConfigSP()->getPropBool("logging/@enableGlobalSysLog"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be:

    if (getComponentConfigSP()->getPropBool("logging/@enableGlobalSysLog", getGlobalConfigSP()->getPropBool("logging/@enableGlobalSysLog")))

so that the global property is the default, but the component can override, i.e. including setting it to false.

@@ -502,6 +510,27 @@ void WUDetails::processRequest(IEspWUDetailsRequest &req, IEspWUDetailsResponse
espWuResponseNote->setErrorCode_null();
espWuResponseNote->setSeverity(cur.queryProp("@severity"));
espWuResponseNote->setCost(0);
VStringBuffer idstr("%" I64F "u", id|COMPONENT_NOTE_MASK);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id's here, being returned in setId (WuResponseNote::Id), they're 64-bit ..
For the non-static warnings, they will have been created by makeMessageId ? i.e. the bottom 21 bits correspond to the year/month/day, the id lies in the top bits (id<<21).
Is that correct?

If so, then the id's created here for static's should follow the same format (and use makeMessageId). Otherwise these 32-bit id's with the top-bit set will always decodeMessageId to an id of 0, and some bits set for the date.

And, I think COMPONENT_NOTE_MASK should move to sysinfologger.hpp, and be used as the upper limit to wrap on instead of the current UINT_MAX.

if (!msgHandler)
{
msgHandler.setown(getDaliMsgLoggerHandler());
ILogMsgFilter * operatorFilter = getCategoryLogMsgFilter(MSGAUD_operator,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check, but this looks like it leaks ? addMonitor (via LogMsgMonitor ctor) links both the handler and the filter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding id's: I agree that different uses of the id may cause confusion and may lead to bugs in the future. I have created a PR to distinguish between message id's and "sequence numbers". Should this be merged first: #19367 @jakesmith

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks like a leak.

catch(IException *e)
{
// Non-existant global messages may mean that /SysInfoLogs hasn't been created
// so catch and ignore the exception
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exception handler looks too broad, catching and silently ignoring any exception from the block of code above.
Would it make more sense to go around createSysInfoLoggerMsgIterator only?

And/or should createSysInfoLoggerMsgIterator be not throw an error if no messages yet - but instead return an iterator that returns none ?

Copy link
Member

@jakesmith jakesmith Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conclusion from an offline chat was to allow createSysInfoLoggerMsgIterator to return a null iterator, i.e. do not throw an exception if SYS_INFO_ROOT doesn't exist (i.e. if there have not been any messages yet).
I think there should be a single static factory method that makes the IRemoteConnection to SYS_INFO_ROOT, if it doesn't exist it creates/returns a CNullMsgIterator, if the connection is made, then it passes it to a ctor of CSysInfoLoggerMsgIterator.

This can be left to a subsequent JIRA/PR. @shamser - please open one and reference/link it to this one.

Use id or msgid for unique SysInfoLogger message identifier
Use SeqNum for the sequence number used to the generated ensure id/msgid is unique

Signed-off-by: Shamser Ahmed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants