Skip to content

Commit

Permalink
Improve messaging on how to set initial admin password (#3879)
Browse files Browse the repository at this point in the history
### Description
When the demo configuration script fails when no initial admin password
is set, it does not provide helpful output telling the user how to set
the initial admin password. This PR provides some helpful output
indicating what variable the user should modify in order for the setup
to succeed.

### Issues Resolved
[List any issues this PR will resolve]

Is this a backport? If so, please add backport PR # and/or commits #

### Testing
Changed test asserting output 

### Check List
- [ ] New functionality includes testing
- [ ] New functionality has been documented
- [x] Commits are signed per the DCO using --signoff

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](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho authored Jan 4, 2024
1 parent f216743 commit 21c086c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ void updateAdminPassword() {

// if ADMIN_PASSWORD is still an empty string, it implies no custom password was provided. We exit the setup.
if (Strings.isNullOrEmpty(ADMIN_PASSWORD)) {
System.out.println("No custom admin password found. Please provide a password.");
System.out.println(
String.format(
"No custom admin password found. Please provide a password via the environment variable %s.",
ConfigConstants.OPENSEARCH_INITIAL_ADMIN_PASSWORD
)
);
System.exit(-1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ public void testUpdateAdminPassword_noPasswordSupplied() {
System.setSecurityManager(null);
}

verifyStdOutContainsString("No custom admin password found. Please provide a password.");
verifyStdOutContainsString(
String.format(
"No custom admin password found. Please provide a password via the environment variable %s.",
ConfigConstants.OPENSEARCH_INITIAL_ADMIN_PASSWORD
)
);
}

@Test
Expand Down

0 comments on commit 21c086c

Please sign in to comment.