From e3c5110b180f2e8c35a19ed44ef9c7b502d858ab Mon Sep 17 00:00:00 2001
From: Erwan Rouchet <rouchet@teklia.com>
Date: Tue, 17 Jan 2023 12:48:15 +0100
Subject: [PATCH] Set a worker version for S3 imports

---
 arkindex/process/models.py                      | 2 +-
 arkindex/process/tests/test_create_s3_import.py | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arkindex/process/models.py b/arkindex/process/models.py
index 9da233f5fc..e959121708 100644
--- a/arkindex/process/models.py
+++ b/arkindex/process/models.py
@@ -463,7 +463,7 @@ class Process(IndexableModel):
             if settings.INGEST_S3_REGION:
                 recipe['env']['INGEST_S3_REGION'] = settings.INGEST_S3_REGION
 
-        elif settings.IMPORTS_WORKER_VERSION and self.mode == ProcessMode.Files:
+        if settings.IMPORTS_WORKER_VERSION and self.mode in (ProcessMode.Files, ProcessMode.S3):
             recipe['env']['WORKER_VERSION_ID'] = str(settings.IMPORTS_WORKER_VERSION)
 
         if self.corpus:
diff --git a/arkindex/process/tests/test_create_s3_import.py b/arkindex/process/tests/test_create_s3_import.py
index 5af39140d6..ad12d1843f 100644
--- a/arkindex/process/tests/test_create_s3_import.py
+++ b/arkindex/process/tests/test_create_s3_import.py
@@ -114,6 +114,7 @@ class TestCreateS3Import(FixtureTestCase):
         INGEST_S3_REGION=None,
         INGEST_S3_ACCESS_KEY='🔑',
         INGEST_S3_SECRET_KEY='its-secret-i-wont-tell-you',
+        IMPORTS_WORKER_VERSION='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
     )
     def test_create(self):
         self.user.user_scopes.create(scope=Scope.S3Ingest)
@@ -157,6 +158,7 @@ class TestCreateS3Import(FixtureTestCase):
             'INGEST_S3_ENDPOINT': 'http://s3.null.teklia.com',
             'INGEST_S3_ACCESS_KEY': '🔑',
             'INGEST_S3_SECRET_KEY': 'its-secret-i-wont-tell-you',
+            'WORKER_VERSION_ID': 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
         })
 
     @override_settings(
@@ -167,6 +169,7 @@ class TestCreateS3Import(FixtureTestCase):
         INGEST_S3_REGION=None,
         INGEST_S3_ACCESS_KEY='🔑',
         INGEST_S3_SECRET_KEY='its-secret-i-wont-tell-you',
+        IMPORTS_WORKER_VERSION='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
     )
     def test_defaults(self):
         self.user.user_scopes.create(scope=Scope.S3Ingest)
@@ -205,4 +208,5 @@ class TestCreateS3Import(FixtureTestCase):
             'INGEST_S3_ENDPOINT': 'http://s3.null.teklia.com',
             'INGEST_S3_ACCESS_KEY': '🔑',
             'INGEST_S3_SECRET_KEY': 'its-secret-i-wont-tell-you',
+            'WORKER_VERSION_ID': 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
         })
-- 
GitLab