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

[Console] Metadata Migration #756

Conversation

mikaylathompson
Copy link
Collaborator

@mikaylathompson mikaylathompson commented Jun 21, 2024

Description

Add metadata migration, for both local filesystem snapshots in docker & s3 snapshots in ECS (it should also work in s3 in docker and filesystem in ECS, as long as all permissions, etc. are set up correctly, but I haven't tested those permutations).

Mini-walkthroughs from testing of each option at the bottom.

Issues Resolved

MIGRATIONS-1791

Testing

Pretty good unit test coverage, plus lots of manual tests.

Check List

  • New functionality includes testing
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented
  • 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.

In docker:


root@aeda38bdc57b:~# tail -n 7 /etc/migration_services.yaml 
snapshot:
  snapshot_name: "snapshot_2023_01_01"
  fs:
    repo_path: "/snapshot/test-console"
metadata_migration:
  from_snapshot:
  min_replicas: 0


root@aeda38bdc57b:~# console snapshot create
21:14:55.752 INFO  Running CreateSnapshot with --snapshot-name snapshot_2023_01_01 --file-system-repo-path /snapshot/test-console --source-host http://opensearchsource:9200
21:14:55.892 INFO  Attempting to initiate the snapshot...
21:14:56.122 INFO  Snapshot repo registration successful
21:14:56.134 INFO  Snapshot snapshot_2023_01_01 creation initiated
21:14:56.134 INFO  Snapshot in progress...
21:14:56.143 INFO  Snapshot not finished yet; sleeping for 1000ms...
Snapshot created successfully.
Snapshot snapshot_2023_01_01 created successfully


root@aeda38bdc57b:~# console metadata migrate
21:15:06.560 INFO  Running RfsWorker
21:15:06.726 INFO  Migrating the Templates...
21:15:06.769 INFO  Setting Global Metadata
21:15:06.769 INFO  Setting Legacy Templates...
21:15:06.769 INFO  No Legacy Templates in specified allowlist
21:15:06.769 INFO  Setting Component Templates...
21:15:06.769 INFO  No Component Templates in Snapshot
21:15:06.769 INFO  Setting Index Templates...
21:15:06.769 INFO  No Index Templates in Snapshot
21:15:06.769 INFO  Templates migration complete
21:15:07.155 INFO  Index geonames created successfully
Metadata migration completed

On ECS

root@ip-12-0-2-166:~# tail -n 8 /etc/migration_services.yaml
snapshot:
  snapshot_name: rfs-snapshot-5
  s3:
    repo_uri: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo
    aws_region: us-east-1
metadata_migration:
  from_snapshot:
  min_replicas: 1


root@ip-12-0-2-166:~# console snapshot create
07:28:15.048 INFO  Running CreateSnapshot with --snapshot-name rfs-snapshot-5 --s3-repo-uri s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo --s3-region us-east-1 --source-host http://opense-clust-oueYNsFE9Lhm-cec0290bdae9a960.elb.us-east-1.amazonaws.com:9200
07:28:15.859 INFO  Attempting to initiate the snapshot...
07:28:16.969 INFO  Snapshot repo registration successful
07:28:16.998 INFO  Snapshot rfs-snapshot-5 creation initiated
07:28:16.998 INFO  Snapshot in progress...
07:28:17.049 INFO  Snapshot not finished yet; sleeping for 1000ms...
07:28:18.054 INFO  Snapshot not finished yet; sleeping for 1000ms...
07:28:19.059 INFO  Snapshot not finished yet; sleeping for 1000ms...
07:28:20.064 INFO  Snapshot not finished yet; sleeping for 1000ms...
07:28:21.069 INFO  Snapshot not finished yet; sleeping for 1000ms...
07:28:22.074 INFO  Snapshot not finished yet; sleeping for 1000ms...
07:28:23.080 INFO  Snapshot not finished yet; sleeping for 1000ms...
07:28:24.084 INFO  Snapshot not finished yet; sleeping for 1000ms...
Snapshot created successfully.
Snapshot rfs-snapshot-5 created successfully


root@ip-12-0-2-166:~# console metadata migrate
07:29:01.890 INFO  Running RfsWorker
07:29:03.687 INFO  Migrating the Templates...
07:29:04.956 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/index-3 to /tmp/migration-rfs-snapshot-5-e1i71d3t/index-3
07:29:05.366 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/meta-2rKSTGFgQhSZ48VtFK8dLQ.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/meta-2rKSTGFgQhSZ48VtFK8dLQ.dat
07:29:05.414 INFO  Setting Global Metadata
07:29:05.414 INFO  Setting Legacy Templates...
07:29:05.415 INFO  No Legacy Templates in specified allowlist
07:29:05.415 INFO  Setting Component Templates...
07:29:05.415 INFO  No Component Templates in Snapshot
07:29:05.415 INFO  Setting Index Templates...
07:29:05.415 INFO  No Index Templates in Snapshot
07:29:05.415 INFO  Templates migration complete
07:29:05.424 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/indices/-3Lhg_vASLeIXe2WnJOdKw/meta-bUARTpABk4j0km__RgMN.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/indices/-3Lhg_vASLeIXe2WnJOdKw/meta-bUARTpABk4j0km__RgMN.dat
07:29:07.012 INFO  Index sonested created successfully
07:29:07.013 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/indices/azRebDO_RqibxnfvcQAHiA/meta-bkARTpABk4j0km__RgNg.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/indices/azRebDO_RqibxnfvcQAHiA/meta-bkARTpABk4j0km__RgNg.dat
07:29:07.348 INFO  Index geonames created successfully
07:29:07.348 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/indices/7sDJZr2RSQaZdUuhl2ULQw/meta-b0ARTpABk4j0km__RgNh.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/indices/7sDJZr2RSQaZdUuhl2ULQw/meta-b0ARTpABk4j0km__RgNh.dat
07:29:07.691 INFO  Index logs-221998 created successfully
07:29:07.692 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/indices/YqeM1xU7RsabxJcORi7fpg/meta-cEARTpABk4j0km__RgN3.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/indices/YqeM1xU7RsabxJcORi7fpg/meta-cEARTpABk4j0km__RgN3.dat
07:29:07.999 INFO  Index logs-191998 created successfully
07:29:08.000 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/indices/Vo8E6jQJTCubCZeYM0l4og/meta-c0ARTpABk4j0km__RgPG.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/indices/Vo8E6jQJTCubCZeYM0l4og/meta-c0ARTpABk4j0km__RgPG.dat
07:29:08.351 INFO  Index reindexed-logs created successfully
07:29:08.352 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/indices/8aWshKIjR4yM_O4yVfCjpA/meta-cUARTpABk4j0km__RgOD.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/indices/8aWshKIjR4yM_O4yVfCjpA/meta-cUARTpABk4j0km__RgOD.dat
07:29:08.676 INFO  Index logs-181998 created successfully
07:29:08.677 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/indices/Z9dc0b6eSb6ZO03YMrNlJg/meta-ckARTpABk4j0km__RgOZ.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/indices/Z9dc0b6eSb6ZO03YMrNlJg/meta-ckARTpABk4j0km__RgOZ.dat
07:29:08.987 INFO  Index logs-231998 created successfully
07:29:08.988 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/indices/THkFxHrGTBmRycun9BeGow/meta-dEARTpABk4j0km__RgPZ.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/indices/THkFxHrGTBmRycun9BeGow/meta-dEARTpABk4j0km__RgPZ.dat
07:29:09.340 INFO  Index logs-241998 created successfully
07:29:09.341 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/indices/9QEJVwDLTiqdQfGG3UewhQ/meta-dUARTpABk4j0km__RgPe.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/indices/9QEJVwDLTiqdQfGG3UewhQ/meta-dUARTpABk4j0km__RgPe.dat
07:29:09.591 INFO  Index nyc_taxis created successfully
07:29:09.591 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/indices/OkpgyXoZTC-L5k5ygwc2Yw/meta-dkARTpABk4j0km__RgPw.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/indices/OkpgyXoZTC-L5k5ygwc2Yw/meta-dkARTpABk4j0km__RgPw.dat
07:29:09.949 INFO  Index logs-211998 created successfully
07:29:09.949 INFO  Downloading file from S3: s3://migration-artifacts-471142325910-aws-integ-us-east-1/rfs-snapshot-repo/indices/VkJ8itKiTXWyL9XxUWODqA/meta-d0ARTpABk4j0km__RwMG.dat to /tmp/migration-rfs-snapshot-5-e1i71d3t/indices/VkJ8itKiTXWyL9XxUWODqA/meta-d0ARTpABk4j0km__RwMG.dat
07:29:10.373 INFO  Index logs-201998 created successfully
Metadata migration completed

Copy link

codecov bot commented Jun 21, 2024

Codecov Report

Attention: Patch coverage is 82.82209% with 28 lines in your changes missing coverage. Please review.

Project coverage is 68.54%. Comparing base (73f2092) to head (53095aa).
Report is 1 commits behind head on main.

Files Patch % Lines
...e/lib/console_link/console_link/models/metadata.py 84.48% 18 Missing ⚠️
...le/lib/console_link/console_link/logic/metadata.py 66.66% 6 Missing ⚠️
...rationConsole/lib/console_link/console_link/cli.py 87.50% 2 Missing ⚠️
...sole/lib/console_link/console_link/models/utils.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #756      +/-   ##
============================================
+ Coverage     68.50%   68.54%   +0.04%     
+ Complexity     1583     1577       -6     
============================================
  Files           270      272       +2     
  Lines         11175    11335     +160     
  Branches        736      736              
============================================
+ Hits           7655     7770     +115     
- Misses         3118     3162      +44     
- Partials        402      403       +1     
Flag Coverage Δ
gradle-test 61.46% <ø> (-0.21%) ⬇️
python-test 88.53% <82.82%> (-0.35%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
@@ -5,7 +5,7 @@ COPY python/Pipfile python/Pipfile.lock ./
RUN apt -y update
RUN apt -y install python3 python3-pip
RUN pip3 install pipenv
RUN pipenv install --system --deploy --ignore-pipfile
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is included because I was getting this error while deploying to aws. It seems odd that I would run into this and no one else would, so it's possible there's another explanation.
cc: @peternied

#10 [ 6/10] RUN pipenv install --system --deploy --ignore-pipfile
#10 0.471 Usage: pipenv install [OPTIONS] [PACKAGES]...
#10 0.471
#10 0.471 ERROR:: --system is intended to be used for Pipfile installation, not installation of specific packages. Aborting.
#10 0.471 See also: --deploy flag.
#10 ERROR: process "/bin/sh -c pipenv install --system --deploy --ignore-pipfile" did not complete successfully: exit code: 2
------
 > [ 6/10] RUN pipenv install --system --deploy --ignore-pipfile:
0.471 Usage: pipenv install [OPTIONS] [PACKAGES]...
0.471
0.471 ERROR:: --system is intended to be used for Pipfile installation, not installation of specific packages. Aborting.
0.471 See also: --deploy flag.
------
Dockerfile:8
--------------------
   6 |     RUN apt -y install python3 python3-pip
   7 |     RUN pip3 install pipenv
   8 | >>> RUN pipenv install --system --deploy --ignore-pipfile
   9 |
  10 |
--------------------
ERROR: failed to solve: process "/bin/sh -c pipenv install --system --deploy --ignore-pipfile" did not complete successfully: exit code: 2

Copy link
Member

Choose a reason for hiding this comment

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

Did you have this commit when you got that error? #753

Comment on lines +18 to +19
MigrationType = Enum('MigrationType', ['OSI_HISTORICAL_MIGRATION'])

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lewijacn -- neither the file it's being imported from nor the enum referenced exist anymore. I added it locally for the time being, because I don't think this is potentially changeable data at this point. Post-demo, we should 1/ add tests to the api so we don't accidentally break it again, 2/ figure out what this should be calling.

Signed-off-by: Mikayla Thompson <[email protected]>
@mikaylathompson mikaylathompson marked this pull request as ready for review June 25, 2024 08:19
Signed-off-by: Mikayla Thompson <[email protected]>
@@ -8,7 +8,7 @@ if [ -z "$MIGRATION_SERVICES_YAML_PARAMETER" ]; then
fi

# Retrieve the parameter value from AWS Systems Manager Parameter Store
PARAMETER_VALUE=$(aws ssm get-parameters --names "$MIGRATION_SERVICES_YAML_PARAMETER" --query "Parameters[0].Value" --output text)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this still after installing awscli?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I seem to, but I don't know if that's entirely true if it works for other people without it.

Based on the docs, it kind of seems like we need to either do this, or to do pipenv shell before we run any commands.

Copy link
Member

Choose a reason for hiding this comment

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

interesting... i wasn't encountering issues but i'm not opposed to this change either

Copy link
Member

@AndreKurait AndreKurait left a comment

Choose a reason for hiding this comment

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

LGTM, please take a look at the comment i left before merging

@mikaylathompson mikaylathompson merged commit 93fd822 into opensearch-project:main Jun 25, 2024
13 checks passed
@mikaylathompson mikaylathompson deleted the console-lib-metdata-migration branch June 25, 2024 15:10
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.

2 participants