Repository navigation
Add optional Cloud Object Storage region to runtime configurations - #3449
NopeCharon wants to merge 2 commits into
Conversation
Elyra never passed a region to the minio client, so the client asks the object storage service for the bucket's region with a GetBucketLocation request before it reads or writes objects. Some S3-compatible providers require a region and fail these requests, so Elyra could not connect to them at all. Add an optional 'cos_region' property to the Kubeflow Pipelines and Apache Airflow runtime configuration schemas. When it is set: - CosClient, which verifies connectivity, creates the bucket and uploads pipeline dependencies, passes the region to the minio client (a missing bucket is created in that region). - The KFP and Airflow processors add '--cos-region' to the bootstrapper command line of generic nodes, and both bootstrappers pass the value to their minio client. When it is not set, nothing changes: no argument is added and the client still looks up the region itself. The schema only accepts names that the minio client accepts as a region. Fixes elyra-ai#3173 Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3449 +/- ##
==========================================
+ Coverage 84.81% 85.07% +0.26%
==========================================
Files 159 159
Lines 19296 19392 +96
Branches 503 504 +1
==========================================
+ Hits 16365 16497 +132
+ Misses 2891 2856 -35
+ Partials 40 39 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
The cos_region pattern in kfp.json:148 and airflow.json:149 lets a trailing newline through. Elyra validates the schema with Python's re module (through jsonschema), where $ also matches right before a final \n, so "us-east-1\n" passes server-side validation even though the PR description says invalid values are caught when the configuration is saved. The metadata editor's JavaScript regex rejects it, but the CLI, REST and import paths would save it, and the newline would then end up in the quoted --cos-region argument of the generated KFP component and Airflow DAG. Could you replace the trailing $ with (?![\s\S]), which works the same way in both Python and JavaScript? Neither \Z nor \z does, since JavaScript supports neither. In test_schema.py, please add "us-east-1\n" to the rejected values: it passes today and will fail until the pattern is fixed. As a smaller point, the sibling properties keep their regex simple and put length limits in maxLength. Writing it as ^a-zA-Z0-9?(?![\s\S]) plus "maxLength": 63 would match that style and give users a clearer error when the name is too long. |
| "title": "Cloud Object Storage Region", | ||
| "description": "The Cloud Object Storage region. If not specified, the region is determined by querying the Cloud Object Storage service.", | ||
| "type": "string", | ||
| "pattern": "^[a-zA-Z0-9]([a-zA-Z0-9_-]{0,61}[a-zA-Z0-9])?$", |
There was a problem hiding this comment.
| "pattern": "^[a-zA-Z0-9]([a-zA-Z0-9_-]{0,61}[a-zA-Z0-9])?$", | |
| "pattern": "^[a-zA-Z0-9]([a-zA-Z0-9_-]{0,61}[a-zA-Z0-9])?(?![\\s\\S])", |
There was a problem hiding this comment.
Done in 3bf82a1. The pattern now ends with (?![\s\S]) and the 63 character limit moved to maxLength, as you suggested in the main comment.
| "title": "Cloud Object Storage Region", | ||
| "description": "The Cloud Object Storage region. If not specified, the region is determined by querying the Cloud Object Storage service.", | ||
| "type": "string", | ||
| "pattern": "^[a-zA-Z0-9]([a-zA-Z0-9_-]{0,61}[a-zA-Z0-9])?$", |
There was a problem hiding this comment.
| "pattern": "^[a-zA-Z0-9]([a-zA-Z0-9_-]{0,61}[a-zA-Z0-9])?$", | |
| "pattern": "^[a-zA-Z0-9]([a-zA-Z0-9_-]{0,61}[a-zA-Z0-9])?(?![\\s\\S])", |
There was a problem hiding this comment.
Done in 3bf82a1. The pattern now ends with (?![\s\S]) and the 63 character limit moved to maxLength, as you suggested in the main comment.
Python's re lets $ match before a final newline, so a region such as "us-east-1\n" passed server-side schema validation. End the cos_region pattern with (?![\s\S]), which behaves the same in Python and JavaScript, and move the length limit into maxLength like the neighbouring properties. Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
|
Fixed in 3bf82a1: both schemas now use |
What changes were proposed in this pull request?
Elyra never passes a region to the minio client. Without one, the client sends a
GetBucketLocationrequest to find the bucket's region before it reads or writes objects. Some S3-compatible providers require a region and fail these requests, so Elyra can't connect to them (#3173).This PR adds an optional Cloud Object Storage Region (
cos_region) property to the Kubeflow Pipelines and Apache Airflow runtime configurations and uses it everywhere Elyra creates a minio client:elyra/metadata/schemas/kfp.json,airflow.json): a new optionalcos_regionstring in the Cloud Object Storage category. The metadata editor andelyra-metadata create/update ... --cos_regionpick it up from the schema. The pattern only accepts names that the minio client accepts as a region (letters, digits,-and_, up to 63 characters, not starting or ending with-or_). An invalid value is therefore reported when the configuration is saved, not later when a pipeline runs.CosClient(elyra/util/cos.py): passes the configured region to the minio client. This client checks connectivity, creates the bucket and uploads node dependencies during submit/export. If the bucket doesn't exist yet, it is created in that region._compose_container_command_args) and the Airflow processor (BootscriptBuilder) add--cos-region '<region>'to the bootstrapper command. Both bootstrappers accept the new optional--cos-regionargument and pass it to their minio client.If no region is configured, behavior doesn't change: no argument is added, and the client still looks up the region itself. Existing runtime configurations need no migration. The new keyword arguments of
_compose_container_command_argsandBootscriptBuilderare optional and come last, so existing callers keep working.The user guide (
runtime-conf.md) documents the new setting.How was this pull request tested?
New tests (each fails without the change):
test_schema.py: thekfpandairflowschemas accept regions such asus-east-1,garageandRegion_1, and reject"",us east 1, leading/trailing-or_, and names longer than 63 characters. The property is not required.test_cos.py:CosClientpasses the configured region to the minio client, orNoneif no region (or an empty one) is configured.test_kfp_processor.py:_compose_container_command_argsadds--cos-regiononly when a region is given. The compiled one-generic-node pipeline test also runs with a runtime configuration that setscos_region. It checks that the compiled container args include--cos-region 'us-east-1', and that they don't include it when no region is configured.test_processor_airflow.py: every generic operation in the generated Airflow DAG gets--cos-regiononly if the runtime configuration sets one.test_airflow_operator.py:BootscriptBuilderwith and withoutcos_region.kfp/test_bootstrapper.pyandairflow/test_bootstrapper.py:--cos-regionis parsed, and is optional. The bootstrapper's minio client is created with the given region, orNone.Locally (Python 3.12):
test_schema.py,test_cos.py,test_airflow_operator.py,airflow/test_bootstrapper.py,test_processor_airflow.py,test_kfp_processor.py,test_validation.pyandtest_metadata_app.pypass. The new and changed tests inkfp/test_bootstrapper.pyalso pass. I couldn't run the rest of that module locally, because its fixture needs the S3 test container on port 9000.flake8andblack --checkare clean.End to end, against a SeaweedFS S3 server (the image the bootstrapper tests use):
elyra-metadata create runtimes --schema_name kfp ... --cos_region us-east-1saves the region.--cos_region "bad region"fails schema validation.CosClientwithcos_regionset creates the bucket and uploads and downloads an object, using the configured region. Withoutcos_region, the client still looks the region up from the service, as before.NotebookFileOp, given--cos-region us-east-1, downloads the object from the bucket.Fixes #3173
Developer's Certificate of Origin 1.1