From 6f66af94ab3261e4c34942eac28f633dde957993 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Thu, 5 Dec 2019 15:33:54 +0100 Subject: [PATCH 1/2] Add AWS_BUCKETNAME_UNSTRUCTURED to by-pass check Curently the name of the bucket is cross checked with the running environment. In rare case you can have a bucket name that doesn't match the structure -odoo- in place. --- README.md | 4 ++++ cloud_platform/models/cloud_platform.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 72a3697..6dbef90 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,10 @@ Besides, the attachment location should be set to `s3` (this is automatically done by the `install` methods of the `cloud_platform` module). * `ir.config_parameter` `ir_attachment.location`: `s3` +Structure of bucket name is checked against environment. +It is possible to by-pass this behavior by using the following environment variable: +`AWS_BUCKETNAME_UNSTRUCTURED`. + ### Attachments in the Object Storage Swift diff --git a/cloud_platform/models/cloud_platform.py b/cloud_platform/models/cloud_platform.py index 74de077..6b37b96 100644 --- a/cloud_platform/models/cloud_platform.py +++ b/cloud_platform/models/cloud_platform.py @@ -166,6 +166,13 @@ class CloudPlatform(models.AbstractModel): "If you don't actually need a bucket, change the" " 'ir_attachment.location' parameter." ) + # A bucket name is defined under the following format + # -odoo- + # + # Use AWS_BUCKETNAME_UNSTRUCTURED to by-pass check on bucket name + # structure + if os.environ.get('AWS_BUCKETNAME_UNSTRUCTURED'): + return prod_bucket = bool(re.match(r'[a-z-0-9]+-odoo-prod', bucket_name)) if environment_name == 'prod': assert prod_bucket, ( From feb737cb25f16c0bf6bd3e68a8bfd5de54ea85f9 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Thu, 5 Dec 2019 15:56:54 +0100 Subject: [PATCH 2/2] Swift same by-pass structured store location --- README.md | 4 ++++ cloud_platform/models/cloud_platform.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 6dbef90..dbc57b5 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,10 @@ Besides, the attachment location should be set to `swift` (this is automatically done by the `install` methods of the `cloud_platform` module). * `ir.config_parameter` `ir_attachment.location`: `swift` +Structure of container name is checked against environment. +It is possible to by-pass this behavior by using the following environment variable: +`SWIFT_WRITE_CONTAINER_UNSTRUCTURED`. + ### Sessions in Redis * prod: diff --git a/cloud_platform/models/cloud_platform.py b/cloud_platform/models/cloud_platform.py index 6b37b96..f9a8476 100644 --- a/cloud_platform/models/cloud_platform.py +++ b/cloud_platform/models/cloud_platform.py @@ -112,6 +112,13 @@ class CloudPlatform(models.AbstractModel): ) prod_container = bool(re.match(r'[a-z0-9-]+-odoo-prod', container_name)) + # A bucket name is defined under the following format + # -odoo- + # + # Use SWIFT_WRITE_CONTAINER_UNSTRUCTURED to by-pass check on bucket name + # structure + if os.environ.get('SWIFT_WRITE_CONTAINER_UNSTRUCTURED'): + return if environment_name == 'prod': assert prod_container, ( "SWIFT_WRITE_CONTAINER should match '-odoo-prod', "