-
Notifications
You must be signed in to change notification settings - Fork 30
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] OSI support for API and Console Library #680
[Console] OSI support for API and Console Library #680
Conversation
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## e2e-tests-q2 #680 +/- ##
==================================================
- Coverage 75.33% 73.60% -1.73%
Complexity 1416 1416
==================================================
Files 150 160 +10
Lines 6147 6707 +560
Branches 561 561
==================================================
+ Hits 4631 4937 +306
- Misses 1143 1397 +254
Partials 373 373
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…nsole-link Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
…nsole-link # Conflicts: # TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py # TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/__init__.py # TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/instantiation.py # TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/cluster.py # TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/requirements.txt # TrafficCapture/dockerSolution/src/main/docker/migrationConsole/osiMigration.py
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
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.
Super cool. Most of my comments are about organization. Open to pushback on them, or let me know if you think there's a preferable path where we keep it as is for now and refactor in the near-ish future.
logger.info(pretty_request(request, request_data)) | ||
|
||
osi_serializer = OpenSearchIngestionCreateRequestSerializer(data=request_data) |
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.
this is super nice!
response_data = { | ||
'Timestamp': datetime.datetime.now(datetime.timezone.utc) | ||
'Timestamp': datetime.datetime.now(datetime.timezone.utc), | ||
'MigrationType': MigrationType.OSI_HISTORICAL_MIGRATION |
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.
Is this a thing that DMS has requested? I'm fine with it, but not sure exactly why we need it
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.
They haven't and in its current context isn't super useful. I originally was going to have this function not be specific to a certain type of migration and this would have been more useful.
OSI_HISTORICAL_MIGRATION = "OSI_HISTORICAL_MIGRATION" | ||
|
||
|
||
class Migration(): |
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.
can we make this Backfill or Historical? I think a Migration will be a very high level class that includes the full context of backfill, a replay, possibly validation, switchover, etc.
@@ -1,3 +1,5 @@ | |||
-e ../lib/console_link |
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.
in the future, we probably don't want -e
(editable install) but it's very helpful for testing in the short term. just worth adding a note that it shouldn't make it to production.
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.
Agreed, have added a comment here as a reminder
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} | ||
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} | ||
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} | ||
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} |
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.
this approach vs. mounting the ~/.aws directory -- is there a benefit? I don't think I know either approach well enough to have a preference, but standardization > not-standardization.
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.
Curious how you typically load credentials? I think my ~/.aws is pretty much empty and I normally am only using environment variables
try: | ||
self.auth_details = config["authorization"]["details"] | ||
except KeyError: | ||
self.auth_details = None |
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.
in general, I think self.auth_details = config["authorization"].get("details", None)
is a little more concise and clearer. I'd do try/except
in this case if we intended to do a more complicated behavior or throw an error if it were missing.
not a blocker though.
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.
Definitely cleaner, updated
'type': 'list', | ||
'required': True, | ||
'schema': { | ||
'type': 'string', | ||
} |
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.
this syntax means "list of strings"? 👍
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.
Yes!
if not v.validate(config): | ||
raise ValueError("Invalid config file for OpenSearchIngestion migration", v.errors) | ||
self.osi_props = OpenSearchIngestionMigrationProps(config=config) | ||
self.migration_logic = OSIMigrationLogic() |
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.
this is interesting. I'm not opposed to it, but I had been picturing logic imports models, not models imports logic. I'm game to play with it for now and see what we end up with. The risk of having both directions right now is that we're going to run into circular imports at some point, but we can play with it until we hit that.
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.
One point of consideration, I guess -- are there any contexts outside of this class that will use the OSIMigrationLogic? If not, I'd tend to make them internal methods of this class.
My thought was that logic
would be used to make sure that the users of the library could remain as thin as possible--so catIndices
goes in the logic
module because 1. it means that callers don't have to know anything about the exact endpoint or how to call it, but 2. it would be the same logic for all Cluster
s, regardless of type, so there's no reason to re-implement it multiple times in each class.
I don't know if that's the optimal approach, very open to discussion on it. But I'd tend to say that if the OSIMigrationLogic stuff is more "internal" it should go inside this class or into a osi_utils
sort of spot.
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.
Per discussion, have moved all implementation details out of logic
and they now reside in osi_utils
. Still expecting a middleware
layer that will create this OpenSearchIngestionMigration
from the raw input it receives
target_cluster=self.target_cluster, | ||
print_config_only=print_config_only) | ||
|
||
def create_from_json(self, config_json: Dict, pipeline_template_path: str) -> None: |
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.
minor, probably an internal only class (because it's not part of the base class interface), so can be _create_from_json
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.
Have removed this function for now
- `authorization`: optional, if it is provided, type is required. | ||
- `type`: required, the only currently implemented option is "basic", but "sigv4" should be available soon | ||
- `authorization`: required, the auth method to use, if no auth the no_auth type must be specified. | ||
- `type`: required, the only currently implemented options are "no_auth" and "basic", but "sigv4" should be available soon |
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.
mind updating this to "basic_auth"
? (in the example yaml above as well)
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.
Updated these spots now
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
…nsole-link # Conflicts: # TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/requirements.txt
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.
Addressing some minor items now, but some design decisions here need further updates that I will address in this PR later
response_data = { | ||
'Timestamp': datetime.datetime.now(datetime.timezone.utc) | ||
'Timestamp': datetime.datetime.now(datetime.timezone.utc), | ||
'MigrationType': MigrationType.OSI_HISTORICAL_MIGRATION |
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.
They haven't and in its current context isn't super useful. I originally was going to have this function not be specific to a certain type of migration and this would have been more useful.
@@ -1,3 +1,5 @@ | |||
-e ../lib/console_link |
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.
Agreed, have added a comment here as a reminder
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} | ||
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} | ||
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} | ||
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} |
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.
Curious how you typically load credentials? I think my ~/.aws is pretty much empty and I normally am only using environment variables
- `authorization`: optional, if it is provided, type is required. | ||
- `type`: required, the only currently implemented option is "basic", but "sigv4" should be available soon | ||
- `authorization`: required, the auth method to use, if no auth the no_auth type must be specified. | ||
- `type`: required, the only currently implemented options are "no_auth" and "basic", but "sigv4" should be available soon |
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.
Updated these spots now
# ##################### OSI ################### | ||
|
||
@cli.command(name="osi-create-migration") | ||
@click.option('--pipeline-template-file', default='/root/osiPipelineTemplate.yaml', help='Path to config file') |
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.
By default we will use the pipeline template file in the starting directory of the migration console, but allowing this option is nice for more involved cases
'authorization': { | ||
'type': 'dict', | ||
'required': True, | ||
'schema': { | ||
'type': { | ||
'type': 'string', | ||
'required': True, | ||
'allowed': [e.name.lower() for e in AuthMethod] |
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.
Let me at least update so there is consistent quote usage
try: | ||
self.auth_type = AuthMethod[config["authorization"]["type"].upper()] | ||
except KeyError: | ||
self.auth_type = None |
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.
You're right, updated
try: | ||
self.auth_details = config["authorization"]["details"] | ||
except KeyError: | ||
self.auth_details = None |
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.
Definitely cleaner, updated
'type': 'list', | ||
'required': True, | ||
'schema': { | ||
'type': 'string', | ||
} |
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.
Yes!
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
TrafficCapture/dockerSolution/src/main/docker/migrationConsole/README.md
Outdated
Show resolved
Hide resolved
...on/src/main/docker/migrationConsole/console_api/console_api/apps/orchestrator/serializers.py
Outdated
Show resolved
Hide resolved
...lution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/osi_migration.py
Outdated
Show resolved
Hide resolved
...rSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/migration.py
Show resolved
Hide resolved
TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/services.yaml
Show resolved
Hide resolved
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
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.
🚢
...rSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/migration.py
Show resolved
Hide resolved
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.
I think there might be some linger comment threads, not sure if you'd want to follow up on them or not. but I think it would be great to merge this change onto the feature branch.
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
9f167bd
into
opensearch-project:e2e-tests-q2
Description
This change refactors the previous OSI migration library to be a component of the new console library. Such that the following commands are now available from the console CLI:
Enter Backfill Options:
Along with this the three stubbed django APIs have now been implemented to also use this common library on the Migration console, giving the following endpoints:
Issues Resolved
https://opensearch.atlassian.net/browse/MIGRATIONS-1740
Is this a backport? If so, please add backport PR # and/or commits #
Testing
Local docker testing, unit testing
Check List
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.