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

Remove default creds #138

Closed
wants to merge 1 commit into from
Closed

Conversation

derek-ho
Copy link

Description

Describe what this change achieves.

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.

Signed-off-by: Derek Ho <dxho@amazon.com>
@derek-ho
Copy link
Author

@peterzhuamazon @prudhvigodithi can you review this once? I am expecting CI to fail until after 2.12.0 docker image gets published, but looking for early feedback, or if you folks think this approach is appropriate - keep PR open until 2.12.0 image release, at which point CI would break and we merge in this PR to fix it. Not sure if I should modify provider_test.go.

@@ -45,7 +45,7 @@ func init() {

opendistroOriginalConfigureFunc := testAccOpendistroProvider.ConfigureContextFunc
testAccOpendistroProvider.ConfigureContextFunc = func(c context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
err := d.Set("url", "http://admin:admin@127.0.0.1:9200")
err := d.Set("url", "http://admin:myStrongPassword123!@127.0.0.1:9200")
Copy link
Author

Choose a reason for hiding this comment

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

Not sure if I should modify this/not sure how it's used - maybe in the integration test with opensearch 2.x?

Copy link
Member

Choose a reason for hiding this comment

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

we can fetch this value from os if the tests are run in the docker container spun-up by the test workflow:
os.Getenv("OPENSEARCH_INITIAL_ADMIN_PASSWORD")

@prudhvigodithi correct me if I'm wrong here

@@ -69,7 +69,7 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Run Docker containers
run: docker-compose up --detach
run: docker-compose --env-file .github/workflows/.env up --detach
env:
Copy link
Collaborator

Choose a reason for hiding this comment

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

@derek-ho @DarshitChanpura you can directly update here https://github.com/opensearch-project/terraform-provider-opensearch/blob/main/docker-compose.yml, no need for a new .github/workflows/.env. Also the main branch works for past releases of 2.x series, where its not required to add OPENSEARCH_INITIAL_ADMIN_PASSWORD. AFAIK it wont break but OPENSEARCH_INITIAL_ADMIN_PASSWORD would just redundant for old versions right?

Copy link
Member

Choose a reason for hiding this comment

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

agreed. no need to modify this command. we can modify the docker-compose.yml directly if that's the file being used here to spin-up containers.

AFAIK it wont break but OPENSEARCH_INITIAL_ADMIN_PASSWORD would just redundant for old versions right?

Correct. This variable will only be used for 2.12 and above. Else it would simply not be used.

- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
- name: Run the tests
run: |
export OPENSEARCH_URL=http://admin:admin@localhost:9200
export OPENSEARCH_URL=http://admin:myStrongPassword123!@localhost:9200
Copy link
Member

Choose a reason for hiding this comment

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

an alternative approach: we can define an env variable for this action and use that.

env:
    ADMIN_PASSWORD: myStrongPassword123!

and use it as ${{ env.ADMIN_PASSWORD }}:

export OPENSEARCH_URL=http://admin:${{ env.ADMIN_PASSWORD }@localhost:9200

@derek-ho
Copy link
Author

Converting this to draft since it will not pass CI until after 2.12.0 release.

@derek-ho derek-ho marked this pull request as draft January 18, 2024 15:21
@@ -0,0 +1 @@
OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!
Copy link
Collaborator

Choose a reason for hiding this comment

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

@derek-ho can you directly the env value in docker-compose file?

@@ -91,13 +91,13 @@ jobs:
- name: Wait for Opensearch
# ensure that OS has come up and is available
run: |
./script/wait-for-endpoint --timeout=20 http://admin:admin@localhost:9200
./script/wait-for-endpoint --timeout=20 http://admin:myStrongPassword123!@localhost:9200
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will fail for versions below 2.12.0.

@DarshitChanpura
Copy link
Member

@prudhvigodithi Now that 2.12 is released this should be unblocked. Would you mind bringing this home?

@derek-ho
Copy link
Author

@prudhvigodithi I see you made a similar change recently, thanks for following up! I am closing this now since it is redundant.

@derek-ho derek-ho closed this Feb 28, 2024
@prudhvigodithi
Copy link
Collaborator

Thanks @derek-ho and @DarshitChanpura

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.

3 participants