Repository: rucio/rucio

Issue:
set_metadata_bulk doesn't work for external postgres / mongo metadata plugins
### Description

The function that calls the specific metadata plugin expects `set_metadata_bulk` to have a parameter `metadata`:

https://github.com/rucio/rucio/blob/41c85bf713e273e9999097481f8a1eb78ce71238/lib/rucio/core/did_meta_plugins/__init__.py#L182

But both the external postgres and mongo plugins expect the parameter `meta`:

https://github.com/rucio/rucio/blob/41c85bf713e273e9999097481f8a1eb78ce71238/lib/rucio/core/did_meta_plugins/postgres_meta.py#L214

https://github.com/rucio/rucio/blob/41c85bf713e273e9999097481f8a1eb78ce71238/lib/rucio/core/did_meta_plugins/postgres_meta.py#L214

### Steps to reproduce

nt

### Rucio Version

_No response_

### Additional Information

_No response_


Discussion:

Resolving patch:
diff --git a/lib/rucio/core/did_meta_plugins/mongo_meta.py b/lib/rucio/core/did_meta_plugins/mongo_meta.py
--- a/lib/rucio/core/did_meta_plugins/mongo_meta.py
+++ b/lib/rucio/core/did_meta_plugins/mongo_meta.py
@@ -91,22 +91,22 @@ def set_metadata(self, scope, name, key, value, recursive=False, *, session: "Op
         :param recursive: recurse into DIDs (not supported)
         :param session: The database session in use
         """
-        self.set_metadata_bulk(scope=scope, name=name, meta={key: value}, recursive=recursive, session=session)
+        self.set_metadata_bulk(scope=scope, name=name, metadata={key: value}, recursive=recursive, session=session)
 
-    def set_metadata_bulk(self, scope, name, meta, recursive=False, *, session: "Optional[Session]" = None):
+    def set_metadata_bulk(self, scope, name, metadata, recursive=False, *, session: "Optional[Session]" = None):
         """
         Bulk set metadata keys.
 
         :param scope: the scope of did
         :param name: the name of the did
-        :param meta: dictionary of metadata keypairs to be added
+        :param metadata: dictionary of metadata keypairs to be added
         :param recursive: recurse into DIDs (not supported)
         :param session: The database session in use
         """
         # pop immutable keys
         for key in IMMUTABLE_KEYS:
-            if key in meta:
-                meta.pop(key)
+            if key in metadata:
+                metadata.pop(key)
 
         # set first document with did == _id
         self.col.update_one(
@@ -114,7 +114,7 @@ def set_metadata_bulk(self, scope, name, meta, recursive=False, *, session: "Opt
                 "_id": "{}:{}".format(scope.internal, name)
             },
             {
-                '$set': meta,
+                '$set': metadata,
                 '$setOnInsert': {
                     'scope': "{}".format(scope.external),
                     'vo': "{}".format(scope.vo),
diff --git a/lib/rucio/core/did_meta_plugins/postgres_meta.py b/lib/rucio/core/did_meta_plugins/postgres_meta.py
--- a/lib/rucio/core/did_meta_plugins/postgres_meta.py
+++ b/lib/rucio/core/did_meta_plugins/postgres_meta.py
@@ -209,21 +209,21 @@ def set_metadata(self, scope, name, key, value, recursive=False, *, session: "Op
         :param recursive: recurse into DIDs (not supported)
         :param session: The database session in use
         """
-        self.set_metadata_bulk(scope=scope, name=name, meta={key: value}, recursive=recursive, session=session)
+        self.set_metadata_bulk(scope=scope, name=name, metadata={key: value}, recursive=recursive, session=session)
 
-    def set_metadata_bulk(self, scope, name, meta, recursive=False, *, session: "Optional[Session]" = None):
+    def set_metadata_bulk(self, scope, name, metadata, recursive=False, *, session: "Optional[Session]" = None):
         """
         Bulk set metadata keys.
 
         :param scope: the scope of did
         :param name: the name of the did
-        :param meta: dictionary of metadata keypairs to be added
+        :param metadata: dictionary of metadata keypairs to be added
         :param recursive: recurse into DIDs (not supported)
         :param session: The database session in use
         """
         # upsert metadata
         statement = "INSERT INTO {} (scope, name, vo, data) ".format(self.table) + \
-                    "VALUES ('{}', '{}', '{}', '{}') ".format(scope.external, name, scope.vo, json.dumps(meta)) + \
+                    "VALUES ('{}', '{}', '{}', '{}') ".format(scope.external, name, scope.vo, json.dumps(metadata)) + \
                     "ON CONFLICT (scope, name) DO UPDATE set data = {}.data || EXCLUDED.data;".format(self.table)
         cur = self.client.cursor()
         cur.execute(statement)


Test patch: