-
Notifications
You must be signed in to change notification settings - Fork 23
Support per extension log level #2791
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
Open
SylvainSenechal
wants to merge
3
commits into
development/9.5
Choose a base branch
from
improvement/BB-807
base: development/9.5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,16 @@ const logJoi = | |
| dumpLevel: 'error', | ||
| }); | ||
|
|
||
| // logJoi with no default : | ||
| // Callers fall back to the global log config when this one is not configured | ||
|
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. This is pretty standard behaviour ? Why a comment ? |
||
| const logJoiOptional = | ||
| joi.object({ | ||
| logLevel: joi.alternatives() | ||
| .try('error', 'warn', 'info', 'debug', 'trace').required(), | ||
|
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. Should it be a const array to avoid duplication ? |
||
| dumpLevel: joi.alternatives() | ||
| .try('error', 'warn', 'info', 'debug', 'trace').required(), | ||
| }).optional(); | ||
|
|
||
| const adminCredsJoi = joi.object() | ||
| .min(1) | ||
| .pattern(/^[A-Za-z0-9]{20}$/, joi.string()); | ||
|
|
@@ -168,6 +178,7 @@ module.exports = { | |
| transportJoi, | ||
| bootstrapListJoi, | ||
| logJoi, | ||
| logJoiOptional, | ||
| adminCredsJoi, | ||
| authJoi, | ||
| inheritedAuthJoi, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| 'use strict'; | ||
|
|
||
| const assert = require('assert'); | ||
| const config = require('../../../lib/Config'); | ||
| const configValidator = require('../../../extensions/ingestion/IngestionConfigValidator'); | ||
|
|
||
| const baseExtConfig = { | ||
| auth: { type: 'service', account: 'test-account' }, | ||
| topic: 'backbeat-ingestion', | ||
| zookeeperPath: '/test', | ||
| sources: [], | ||
| probeServer: { port: 4000 }, | ||
| }; | ||
|
|
||
| const qpBatchMaxRead = config.queuePopulator.batchMaxRead; | ||
|
|
||
| describe('IngestionConfigValidator log override', () => { | ||
| it('should pass through log config when set', () => { | ||
| const validated = configValidator({}, { | ||
| ...baseExtConfig, | ||
| log: { logLevel: 'debug', dumpLevel: 'error' }, | ||
| }); | ||
| assert.deepStrictEqual(validated.log, { logLevel: 'debug', dumpLevel: 'error' }); | ||
| }); | ||
|
|
||
| it('should leave log undefined when not set, deferring to global config.log', () => { | ||
| const validated = configValidator({}, baseExtConfig); | ||
| assert.strictEqual(validated.log, undefined); | ||
| }); | ||
|
|
||
| it('should reject a partial log config with missing dumpLevel', () => { | ||
| let err; | ||
| try { | ||
| configValidator({}, { ...baseExtConfig, log: { logLevel: 'debug' } }); | ||
| } catch (e) { | ||
| err = e; | ||
| } | ||
| assert(err, 'expected configValidator to throw on partial log config'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('IngestionConfigValidator batchMaxRead fallback', () => { | ||
| it('should override queuePopulator.batchMaxRead when set in extension config', () => { | ||
| const validated = configValidator({}, { ...baseExtConfig, batchMaxRead: 500 }); | ||
| assert.strictEqual(validated.batchMaxRead, 500); | ||
| assert.notStrictEqual(validated.batchMaxRead, qpBatchMaxRead); | ||
| }); | ||
|
|
||
| it('should leave batchMaxRead undefined when not set, allowing fallback to queuePopulator.batchMaxRead', () => { | ||
| const validated = configValidator({}, baseExtConfig); | ||
| assert.strictEqual(validated.batchMaxRead, undefined); | ||
| }); | ||
|
|
||
| it('should reject a non-positive batchMaxRead', () => { | ||
| let err; | ||
| try { | ||
| configValidator({}, { ...baseExtConfig, batchMaxRead: 0 }); | ||
| } catch (e) { | ||
| err = e; | ||
| } | ||
| assert(err, 'expected configValidator to throw on batchMaxRead: 0'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Partial extension log config drops the global fallback for omitted fields. If a user sets
log: { logLevel: 'debug' }withoutdumpLevel, the??sees a non-nullish object and uses it as-is, sodumpLevelbecomesundefinedinstead of falling back toconfig.log.dumpLevel. Merge at field level instead: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.
mhh fair enough but im gonna go with the option of making both fields required when specified (If you provide log level you must provide dump level and other way around).
This is how the operator works anyway