-
Notifications
You must be signed in to change notification settings - Fork 45
Improve JWK messages #807
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
base: v3.x/staging
Are you sure you want to change the base?
Improve JWK messages #807
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,14 +118,22 @@ static int jwkTaskMain(RLETask *task) { | |
| if ((i+1) % warnInterval == 0) { | ||
| zowelog(NULL, LOG_COMP_ID_JWK, ZOWE_LOG_WARNING, ZSS_LOG_JWK_RETRY_MSG, | ||
| jwkGetStrStatus(rc), rc, jwkHttpClientGetStrStatus(rsn), rsn, retryIntervalSeconds); | ||
| if (rsn == HTTP_CLIENT_TLS_ERROR) { | ||
| zowelog(NULL, LOG_COMP_ID_JWK, ZOWE_LOG_WARNING, "If TLS error persists, trace GSK for more detail using YAML property 'components.zss.agent.https.trace: true'\n"); | ||
| } | ||
| } | ||
| sleep(retryIntervalSeconds); | ||
| } | ||
| } | ||
| if (success) { | ||
| zowelog(NULL, LOG_COMP_ID_JWK, ZOWE_LOG_INFO, ZSS_LOG_JWK_READY_MSG, settings->fallback ? "with" : "without"); | ||
| } else { | ||
| zowelog(NULL, LOG_COMP_ID_JWK, ZOWE_LOG_WARNING, ZSS_LOG_JWK_FAILED_MSG); | ||
| if (indexOf(settings->host, strlen(settings->host), ':', 0) != -1) { | ||
| //wraps ipv6 address in [] | ||
| zowelog(NULL, LOG_COMP_ID_JWK, ZOWE_LOG_WARNING, ZSS_LOG_JWK_FAILED_IPV6_MSG, settings->host, settings->port, settings->path); | ||
| } else { | ||
| zowelog(NULL, LOG_COMP_ID_JWK, ZOWE_LOG_WARNING, ZSS_LOG_JWK_FAILED_MSG, settings->host, settings->port, settings->path); | ||
| } | ||
| } | ||
| fflush(stdout); | ||
| } | ||
|
|
@@ -280,6 +288,12 @@ static void getPublicKey(Json *jwk, x509_public_key_info *publicKeyOut, int *sta | |
| if (!keyObject) { | ||
| zowelog(NULL, LOG_COMP_ID_JWK, ZOWE_LOG_WARNING, "JWK doesn't contain key\n"); | ||
| *statusOut = JWK_STATUS_UNRECOGNIZED_FMT_ERROR; | ||
|
|
||
| zowelog(NULL, LOG_COMP_ID_JWK, ZOWE_LOG_WARNING, "JWK response:\n"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably needs instead of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On top of that, the message might get split by some other stray message since they're not printed as a single message. |
||
| //Often enough, the destination has some error message that can be printed | ||
| jsonPrinter *jp = makeJsonPrinter(STDOUT_FILENO); | ||
|
ifakhrutdinov marked this conversation as resolved.
|
||
| jsonPrintObject(jp, jwkObject); | ||
| freeJsonPrinter(jp); | ||
| return; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -518,8 +518,10 @@ bool isLogLevelValid(int level); | |
| #ifndef ZSS_LOG_JWK_FAILED_MSG_ID | ||
| #define ZSS_LOG_JWK_FAILED_MSG_ID ZSS_LOG_MSG_PRFX"1605W" | ||
| #endif | ||
| #define ZSS_LOG_JWK_FAILED_MSG_TEXT "Server will not accept JWT\n" | ||
| #define ZSS_LOG_JWK_FAILED_MSG_TEXT "Server will not accept JWT\nCheck URL https://%s:%d%s for errors.\n" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest we have a single messages: |
||
| #define ZSS_LOG_JWK_FAILED_MSG ZSS_LOG_JWK_FAILED_MSG_ID" "ZSS_LOG_JWK_FAILED_MSG_TEXT | ||
| #define ZSS_LOG_JWK_FAILED_IPV6_MSG_TEXT "Server will not accept JWT\nCheck URL https://[%s]:%d%s for errors.\n" | ||
| #define ZSS_LOG_JWK_FAILED_IPV6_MSG ZSS_LOG_JWK_FAILED_MSG_ID" "ZSS_LOG_JWK_FAILED_MSG_TEXT | ||
|
|
||
| #ifndef ZSS_LOG_JWK_RETRY_MSG_ID | ||
| #define ZSS_LOG_JWK_RETRY_MSG_ID ZSS_LOG_MSG_PRFX"1606W" | ||
|
|
||
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'd add a helper function and simplify this code:
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.
This looks to make the code more complicated. Why do this?
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.
Because it's not more complicated?
In the current implementation, you mix lower and higher level logic, and then you have to introduce additional message templates just to work around the peculiarities of IPv6; this all basically unnecessarily spreads lower level details over a larger area than needed.
So, why not just hide this in a specialised function which can be easily reviewed and verified?