-
Notifications
You must be signed in to change notification settings - Fork 33
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
Added feature to pass additional cluster settings from command line. #21
Conversation
Signed-off-by: Rishabh Singh <sngri@amazon.com>
lib/infra/infra-stack.ts
Outdated
// @ts-ignore | ||
if (props.additionalConfig.toString() !== 'undefined') { | ||
// @ts-ignore | ||
cfnInitConfig.push(InitCommand.shellCommand(`set -ex; cd opensearch; additionalConfig=$(echo "${props.additionalConfig.toString()}" | tr ',' '\\n');` |
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.
As @gaiksaya If we have an array we can remove all this shell logic.
Thank you
120f6cf
to
cd54212
Compare
lib/os-cluster-entrypoint.ts
Outdated
const jsonObj = JSON.parse(osConfig); | ||
ymlConfig = dump(jsonObj); | ||
} catch (e) { | ||
throw new Error(`Encountered following error parsing json: ${e}`); |
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.
nit: Error(`Encountered following error parsing json from additionalConfig: ${e}`);
Would make it easier for user to troubleshoot instead trying to figure out what json is wrong.
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.
didn't understand this. This is just catching exception in case the json is not valid. @gaiksaya
test/os-cluster.test.ts
Outdated
describe('JSON input validation', () => { | ||
test('valid JSON input should parse successfully', () => { | ||
expect(() => JSON.parse(validJson)).not.toThrow(); | ||
}); | ||
|
||
test('invalid JSON input should throw an error', () => { | ||
const invalidJson = '{name: "John", age: 30}'; | ||
expect(() => JSON.parse(invalidJson)).toThrow(); | ||
}); | ||
}); |
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.
Test the additionalConfig
value here. Not the validJson
since the validation already happened inside the code. @prudhvigodithi WDYT?
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.
Couldn't find a way to access the context variable from stack properties. So adding test at parameter level made more sense.
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.
${props.additionalConfig}"
is accessible I believe? Since we are using the same here: https://github.com/opensearch-project/opensearch-cluster-cdk/pull/21/files#diff-d7c4924379311512de5d5b043d465129d2b5fb1254d7a08737f2e3f9b1c13f64R474
Point is this test case won't test any code. It is directly calling JSON.parse
which does not provide any value here.
Signed-off-by: Rishabh Singh <sngri@amazon.com>
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/backport-1.x 1.x
# Navigate to the new working tree
pushd ../.worktrees/backport-1.x
# Create a new branch
git switch --create backport/backport-21-to-1.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 5307477e40d3c620aac3a4c7051f60ad59537bb5
# Push it to GitHub
git push --set-upstream origin backport/backport-21-to-1.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-1.x Then, create a pull request where the |
…21) * make OSD optional and other minor improvements Signed-off-by: Rishabh Singh <sngri@amazon.com> * Feature to pass additional cluster settings from command line Signed-off-by: Rishabh Singh <sngri@amazon.com> --------- Signed-off-by: Rishabh Singh <sngri@amazon.com> (cherry picked from commit 5307477)
…21) * make OSD optional and other minor improvements Signed-off-by: Rishabh Singh <sngri@amazon.com> * Feature to pass additional cluster settings from command line Signed-off-by: Rishabh Singh <sngri@amazon.com> --------- Signed-off-by: Rishabh Singh <sngri@amazon.com> (cherry picked from commit 5307477)
Description
Added feature to pass additional cluster settings from command line.
Issues Resolved
List any issues this PR will resolve, e.g. Closes [...].
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.