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

Copy resource contents from Prod to Beta #5697

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

MSDrao
Copy link
Contributor

@MSDrao MSDrao commented Jan 12, 2025

GH Action to copy resource contents from prod to beta, if bucket exists

Pull Request Checklist:

  • Positive Test Case Written by Dev
  • Automated Testing
  • Sufficient User and Developer Documentation
  • Passing Jenkins Build
  • Peer Code review and approval

Positive Test Case

  1. [Enter positive test case here]

@MSDrao MSDrao self-assigned this Jan 12, 2025
Copy link

github-actions bot commented Jan 12, 2025

Test Results

0 files   -     2  0 suites   - 2   0s ⏱️ - 1h 31m 52s
0 tests  - 1 415  0 ✅  - 1 399  0 💤  - 16  0 ❌ ±0 
0 runs   - 1 527  0 ✅  - 1 509  0 💤  - 18  0 ❌ ±0 

Results for commit 8100a0c. ± Comparison against base commit 69f2ddc.

♻️ This comment has been updated with latest results.

@MSDrao MSDrao requested a review from sblack-usu January 16, 2025 15:57
MINIO_SECRET_KEY: ${{ secrets.MINIO_SECRET_KEY }}
run: |
mc alias set prod $MINIO_PROD_URL $MINIO_ACCESS_KEY $MINIO_SECRET_KEY
mc alias set beta $MINIO_BETA_URL $MINIO_ACCESS_KEY $MINIO_SECRET_KEY
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure these keys will be printed to console. I wonder if you can write the keys to a configuration file instead.

Also, I think it would be best to not share key/secret between environments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Scott,
I moved the keys to a config file and seperated beta and prod keys.

IFS=',' read -ra RESOURCES <<< "$RESOURCE_IDS"

for RESOURCE_ID in "${RESOURCES[@]}"; do
echo "Checking resource: $RESOURCE_ID"
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use mc mirror for the sync. By including the --remove --overwrite flags, it'll sync for the source to the target completely (including removing files that are on the target that aren't in the source).

You will also need to look up the bucket the resource is in, in order to sync the resource. There is an endpoint for this, GET https://beta.hydroshare.org/hsapi/resource/$resource_id/quota_holder_bucket_name/. An admin basic credentials are necessary to hit the endpoint.

You will also need to make sure the bucket exists on the target minio server. That can be done with mc mb --ignore-existing

@MSDrao MSDrao linked an issue Jan 16, 2025 that may be closed by this pull request
sudo mv mc /usr/local/bin/mc

- name: Create MinIO Config File
env:
Copy link
Contributor

Choose a reason for hiding this comment

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

You can collapse this run and the next run into just setting the environment variables with https://min.io/docs/minio/linux/reference/minio-mc/minio-client-settings.html#envvar.MC_HOST_-ALIAS

Copy link
Contributor

Choose a reason for hiding this comment

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

The rest of it looks good and can should run successfully, given correct secret values.

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.

copy specific resource data to beta
2 participants