From ac83ce2acff1ff4c3ef43cff5716b124f72e863b Mon Sep 17 00:00:00 2001
From: Konstantina Skovola <konstantina.skovola@cern.ch>
Date: Tue, 11 Feb 2025 12:38:24 +0100
Subject: [PATCH 01/10] Update example config file and systemd service file for
 grpc frontend

---
 frontend/grpc/cta-frontend-grpc.conf.example | 53 +++++++++++++++++---
 frontend/grpc/cta-frontend-grpc.service      |  2 +-
 2 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/frontend/grpc/cta-frontend-grpc.conf.example b/frontend/grpc/cta-frontend-grpc.conf.example
index 62d4d7e977..6e2854377f 100644
--- a/frontend/grpc/cta-frontend-grpc.conf.example
+++ b/frontend/grpc/cta-frontend-grpc.conf.example
@@ -20,14 +20,51 @@
 #
 # Unique string to identify CTA's instance the frontend is serving (i.e: production, preproduction).
 # Each of these instances should be associated with a specific CTA catalogue instance.
-InstanceName CI_local
+cta.instance_name CI_local
 
 # Unique string to identify the backend scheduler resources. As an exmple, it can be structured as:
 # "[ceph|postgres|vfs][User|Repack]".
-SchedulerBackendName vfsCI
+cta.schedulerdb.scheduler_backend_name vfsCI
 
+# CTA ObjectStore options
 # Scheduler endpoint
-BackendPath /path/to/local/objectstore
+#cta.objectstore.backendpath /path/to/local/objectstore
+
+# CTA Scheduler DB - thread options
+cta.schedulerdb.numberofthreads 500
+cta.schedulerdb.threadstacksize_mb 1
+
+# Maximum file size (in GB) that the CTA Frontend will accept for archiving
+# cta.archivefile.max_size_gb 1000
+
+# Disallow 0-length files
+# cta.archivefile.zero_length_files_forbidden on
+# Tapepools exempted from this check (if enabled)
+# cta.archivefile.zero_length_files_forbidden_vo_exception_list vo1 vo2 vo3
+
+# CTA Repack buffer URL
+# cta.repack.repack_buffer_url root://ctaeos//eos/ctaeos/repack
+
+# CTA Verification Mount Policy
+# cta.verification.mount_policy verification
+
+# Keytab containing gRPC endpoints and tokens for each disk instance
+#cta.ns.config /etc/cta/eos.grpc.keytab
+
+
+# CTA Frontend log URL
+cta.log.url file:/var/log/cta/cta-frontend.log
+
+# CTA Logger log level
+# Valid log levels are EMERG, ALERT, CRIT, ERR, WARNING, NOTICE (==USERERR), INFO, DEBUG
+# cta.log.level DEBUG
+
+# CTA Logger log format
+# Valid formats are default, json
+# cta.log.format json
+
+# CTA Log header
+# cta.log.log_header true
 
 
 ####################################
@@ -51,14 +88,18 @@ BackendPath /path/to/local/objectstore
 ####################################
 # CTA Scheduler DB cache timeout options
 ####################################
-#SchedulerDB TapeCacheMaxAgeSecs 600
-#SchedulerDB RetrieveQueueCacheMaxAgeSecs 10
+# cta.schedulerdb.tape_cache_max_age_secs 600
+# cta.schedulerdb.retrieve_queue_cache_max_age_secs 10
+
+# CTA Scheduler DB - enable requests for user or repack
+# cta.schedulerdb.enable_repack_requests on
+# cta.schedulerdb.enable_user_requests on
 
 
 ####################################
 # Variables used by cta-frontend-async-grpc
 ####################################
-# The port the gRPC frotnend is listening to
+# The port the gRPC frontend is listening to
 #port 17017
 
 # The ca-cert file path
diff --git a/frontend/grpc/cta-frontend-grpc.service b/frontend/grpc/cta-frontend-grpc.service
index a1f0304e57..8441813b10 100644
--- a/frontend/grpc/cta-frontend-grpc.service
+++ b/frontend/grpc/cta-frontend-grpc.service
@@ -4,7 +4,7 @@ After=syslog.target network-online.target
 
 [Service]
 EnvironmentFile=/etc/sysconfig/cta-frontend-grpc
-ExecStart=/usr/bin/cta-frontend-grpc --no-log-header ${GRPC_USE_TLS} --port ${GRPC_PORT}
+ExecStart=/usr/bin/cta-frontend-grpc
 Type=simple
 Restart=always
 User=cta
-- 
GitLab


From e19d653d8b96cb1b1ae58ec53de4c12ed4d0e3c6 Mon Sep 17 00:00:00 2001
From: Konstantina Skovola <konstantina.skovola@cern.ch>
Date: Thu, 20 Feb 2025 11:02:58 +0100
Subject: [PATCH 02/10] Use scoped options

use scoped port and SslRoot etc options
---
 frontend/common/FrontendService.cpp          | 12 +++++-----
 frontend/grpc/FrontendCmd.cpp                | 10 ++++----
 frontend/grpc/cta-frontend-grpc.conf.example | 25 ++++++++++++--------
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/frontend/common/FrontendService.cpp b/frontend/common/FrontendService.cpp
index 803fa2e4e3..1a3c65b424 100644
--- a/frontend/common/FrontendService.cpp
+++ b/frontend/common/FrontendService.cpp
@@ -374,25 +374,25 @@ FrontendService::FrontendService(const std::string& configFilename) : m_archiveF
   // Get the mount policy name for verification requests
 
   // Get the gRPC-specific values, if they are set (getOptionValue returns an std::optional)
-  std::optional<bool> TLS = config.getOptionValueBool("TLS");
+  std::optional<bool> TLS = config.getOptionValueBool("grpc.TLS");
   m_Tls = TLS.has_value() ? TLS.value() : false;  // default value is false
-  auto TlsKey = config.getOptionValueStr("TlsKey");
+  auto TlsKey = config.getOptionValueStr("grpc.TlsKey");
   if (TlsKey.has_value()) {
     m_TlsKey = TlsKey.value();
   }
-  auto TlsCert = config.getOptionValueStr("TlsCert");
+  auto TlsCert = config.getOptionValueStr("grpc.TlsCert");
   if (TlsCert.has_value()) {
     m_TlsCert = TlsCert.value();
   }
-  auto TlsChain = config.getOptionValueStr("TlsChain");
+  auto TlsChain = config.getOptionValueStr("grpc.TlsChain");
   if (TlsChain.has_value()) {
     m_TlsChain = TlsChain.value();
   }
-  auto port = config.getOptionValueStr("port");
+  auto port = config.getOptionValueStr("grpc.port");
   if (port.has_value()) {
     m_port = port.value();
   }
-  auto threads = config.getOptionValueInt("threads");
+  auto threads = config.getOptionValueInt("grpc.numberofthreads");
   if (threads.has_value()) {
     m_threads = threads.value();
   }
diff --git a/frontend/grpc/FrontendCmd.cpp b/frontend/grpc/FrontendCmd.cpp
index 097b391ced..de5e5778b0 100644
--- a/frontend/grpc/FrontendCmd.cpp
+++ b/frontend/grpc/FrontendCmd.cpp
@@ -185,11 +185,11 @@ int cta::frontend::grpc::server::FrontendCmd::main(const int argc, char** argv)
   cta::common::Config config(strConFile);
   try {
     if (!uiPort) {
-      uiPort = config.getOptionValueUInt("port").value_or(DEFAULT_PORT);
+      uiPort = config.getOptionValueUInt("grpc.port").value_or(DEFAULT_PORT);
     }
-    strSslRoot = config.getOptionValueStr("SslRoot").value();
-    strSslKey = config.getOptionValueStr("SslKey").value();
-    strSslCert = config.getOptionValueStr("SslCert").value();
+    strSslRoot = config.getOptionValueStr("grpc.SslRoot").value();
+    strSslKey = config.getOptionValueStr("grpc.SslKey").value();
+    strSslCert = config.getOptionValueStr("grpc.SslCert").value();
   } catch(const cta::exception::Exception &ex) {
     m_err << m_strExecName << ": problem while reading a configuration file - " << ex.getMessage().str() << std::endl;
     return EXIT_FAILURE;
@@ -200,7 +200,7 @@ int cta::frontend::grpc::server::FrontendCmd::main(const int argc, char** argv)
   }
 
   if(strKeytab.empty()) {
-    strKeytab = config.getOptionValueStr("Keytab").value_or("");
+    strKeytab = config.getOptionValueStr("grpc.Keytab").value_or("");
     // and check again
     if(strKeytab.empty()) {
       m_err << m_strExecName << ": the keytab file is unspecified" << std::endl
diff --git a/frontend/grpc/cta-frontend-grpc.conf.example b/frontend/grpc/cta-frontend-grpc.conf.example
index 6e2854377f..9f7cea506a 100644
--- a/frontend/grpc/cta-frontend-grpc.conf.example
+++ b/frontend/grpc/cta-frontend-grpc.conf.example
@@ -45,6 +45,8 @@ cta.schedulerdb.threadstacksize_mb 1
 # CTA Repack buffer URL
 # cta.repack.repack_buffer_url root://ctaeos//eos/ctaeos/repack
 
+# cta.repack.repack_max_files_to_select 100
+
 # CTA Verification Mount Policy
 # cta.verification.mount_policy verification
 
@@ -71,19 +73,19 @@ cta.log.url file:/var/log/cta/cta-frontend.log
 #  TLS related variables. Only used when TLS is true
 ####################################
 # Use TLS (previously the command-line option --tls)
-#TLS true/false
+#grpc.TLS true/false
 #  TLS service key file
-#TlsKey /path/to/key
+#grpc.tls.key /path/to/key
 #
 #  TLS service certificate file
-#TlsCert /path/to/cert
+#grpc.tls.cert /path/to/cert
 #
 #  TLS CA chain file
-#TlsChain /path/to/CA/chain
+#grpc.tls.chain /path/to/CA/chain
 #
 
 # gRPC number of threads
-#threads nthreads
+#grpc.numberofthreads nthreads
 
 ####################################
 # CTA Scheduler DB cache timeout options
@@ -95,21 +97,24 @@ cta.log.url file:/var/log/cta/cta-frontend.log
 # cta.schedulerdb.enable_repack_requests on
 # cta.schedulerdb.enable_user_requests on
 
+# CTA Catalogue options
+cta.catalogue.numberofconnections 10
+
 
 ####################################
 # Variables used by cta-frontend-async-grpc
 ####################################
 # The port the gRPC frontend is listening to
-#port 17017
+#grpc.port 17017
 
 # The ca-cert file path
-#SslRoot /path/to/ca/cert
+#grpc.SslRoot /path/to/ca/cert
 
 # Ssl Key file
-#SslKey /path/to/ssl/key
+#grpc.SslKey /path/to/ssl/key
 
 # Ssl certificate file
-#SslCert /path/to/ssl/cert
+#grpc.SslCert /path/to/ssl/cert
 
 # keytab file
-#Keytab /path/to/keytab
+#grpc.Keytab /path/to/keytab
-- 
GitLab


From 1a139cc45d0d533665cdf3584c7f22549dae0cbe Mon Sep 17 00:00:00 2001
From: Konstantina Skovola <konstantina.skovola@cern.ch>
Date: Thu, 20 Feb 2025 11:27:03 +0100
Subject: [PATCH 03/10] Install config file with the frontend-grpc rpm

---
 cta.spec.in                  | 8 ++++++++
 frontend/grpc/CMakeLists.txt | 1 +
 2 files changed, 9 insertions(+)

diff --git a/cta.spec.in b/cta.spec.in
index f2573c4630..f7b4ae1b05 100644
--- a/cta.spec.in
+++ b/cta.spec.in
@@ -206,6 +206,7 @@ dCache frontend
 %attr(0755,root,root) %{_bindir}/cta-frontend-grpc
 %attr(0644,root,root) /etc/systemd/system/cta-frontend-grpc.service
 %attr(0644,root,root) /etc/sysconfig/cta-frontend-grpc
+%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cta/cta-frontend-grpc.conf.example
 %attr(0644,root,root) %doc /usr/share/man/man1/cta-frontend-grpc.1cta.gz
 
 %post -n cta-frontend-grpc
@@ -220,6 +221,13 @@ dCache frontend
 %systemd_postun cta-frontend-grpc.service
 %systemdDaemonReload
 
+%posttrans -n cta-frontend-grpc
+MISSING_CONF=%{_sysconfdir}/cta/cta-frontend-grpc.conf
+if [[ ! -f "${MISSING_CONF}" ]] && [[ -f "${MISSING_CONF}.rpmsave" ]]
+then
+  mv ${MISSING_CONF}.rpmsave ${MISSING_CONF}
+fi
+
 %package -n cta-cli
 Summary: CERN Tape Archive: command line interface
 Group: Application/CTA
diff --git a/frontend/grpc/CMakeLists.txt b/frontend/grpc/CMakeLists.txt
index d1578650f9..e04c0983ee 100644
--- a/frontend/grpc/CMakeLists.txt
+++ b/frontend/grpc/CMakeLists.txt
@@ -44,6 +44,7 @@ install(TARGETS cta-frontend-grpc DESTINATION usr/bin)
 install (FILES cta-frontend-grpc.service DESTINATION etc/systemd/system)
 install (FILES cta-frontend-grpc.sysconfig DESTINATION /etc/sysconfig RENAME cta-frontend-grpc)
 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/cta-frontend-grpc.1cta DESTINATION /usr/share/man/man1)
+install (FILES cta-frontend-grpc.conf.example DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cta)
 
 ##
 ## cta-frontend-grpc-stream-server
-- 
GitLab


From d418c1381dd98eef3d4a2675e48f6caa70a7dab8 Mon Sep 17 00:00:00 2001
From: Konstantina Skovola <konstantina.skovola@cern.ch>
Date: Fri, 21 Feb 2025 16:42:33 +0100
Subject: [PATCH 04/10] Fix improper handing of enable_{repack, user}_requests
 config options

These options are expected to always have a value, the default value is "on". If they are omitted in the config file, print an INFO message and set the value to on.

Applied clang format to changed lines
---
 frontend/common/FrontendService.cpp | 42 ++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/frontend/common/FrontendService.cpp b/frontend/common/FrontendService.cpp
index 1a3c65b424..999f51d842 100644
--- a/frontend/common/FrontendService.cpp
+++ b/frontend/common/FrontendService.cpp
@@ -324,24 +324,36 @@ FrontendService::FrontendService(const std::string& configFilename) : m_archiveF
 
   // Configure allowed requests
   {
-    m_acceptRepackRequests =
-      config.getOptionValueStr("cta.schedulerdb.enable_repack_requests").value() == "on" ? true : false;
-    std::list<log::Param> params;
-    params.push_back(log::Param("source", configFilename));
-    params.push_back(log::Param("category", "cta.schedulerdb"));
-    params.push_back(log::Param("key", "enable_repack_requests"));
-    params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.enable_repack_requests").value()));
-    log(log::INFO, "Configuration entry", params);
+    // default value for both repack and user requests is "on"
+    auto acceptRepackRequests = config.getOptionValueStr("cta.schedulerdb.enable_repack_requests");
+    if (!acceptRepackRequests.has_value()) {
+      log(log::INFO, "'cta.schedulerdb.enable_repack_requests' not specified in config, defaulting to \"on\"");
+      m_acceptRepackRequests = true;
+    } else {
+      m_acceptRepackRequests = (acceptRepackRequests.value() == "on");
+      std::list<log::Param> params;
+      params.push_back(log::Param("source", configFilename));
+      params.push_back(log::Param("category", "cta.schedulerdb"));
+      params.push_back(log::Param("key", "enable_repack_requests"));
+      params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.enable_repack_requests").value()));
+      log(log::INFO, "Configuration entry", params);
+    }
   }
 
   {
-    m_acceptUserRequests = config.getOptionValueStr("cta.schedulerdb.enable_user_requests") == "on" ? true : false;
-    std::list<log::Param> params;
-    params.push_back(log::Param("source", configFilename));
-    params.push_back(log::Param("category", "cta.schedulerdb"));
-    params.push_back(log::Param("key", "enable_user_requests"));
-    params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.enable_user_requests").value()));
-    log(log::INFO, "Configuration entry", params);
+    auto acceptUserRequests = config.getOptionValueStr("cta.schedulerdb.enable_user_requests");
+    if (!acceptUserRequests.has_value()) {
+      log(log::INFO, "'cta.schedulerdb.enable_user_requests' not specified in config, defaulting to \"on\"");
+      m_acceptUserRequests = true;
+    } else {
+      m_acceptUserRequests = (acceptUserRequests.value() == "on");
+      std::list<log::Param> params;
+      params.push_back(log::Param("source", configFilename));
+      params.push_back(log::Param("category", "cta.schedulerdb"));
+      params.push_back(log::Param("key", "enable_user_requests"));
+      params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.enable_user_requests").value()));
+      log(log::INFO, "Configuration entry", params);
+    }
   }
 
   {
-- 
GitLab


From 59f63eb5c2d1c31ddc8aaf89464512437c82ac1e Mon Sep 17 00:00:00 2001
From: Konstantina Skovola <konstantina.skovola@cern.ch>
Date: Tue, 4 Mar 2025 09:53:21 +0100
Subject: [PATCH 05/10] Rename options to disable_XY_requests and make them
 bool

---
 .../configmaps/cta-frontend-xrootd.yaml       |  4 ++--
 .../orchestration/helm/frontend/values.yaml   |  4 ++--
 frontend/common/FrontendService.cpp           | 24 +++++++++----------
 frontend/grpc/cta-frontend-grpc.conf.example  |  4 ++--
 .../cta-frontend-xrootd.conf.example          |  4 ++--
 5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/continuousintegration/orchestration/helm/frontend/templates/configmaps/cta-frontend-xrootd.yaml b/continuousintegration/orchestration/helm/frontend/templates/configmaps/cta-frontend-xrootd.yaml
index 11378affea..b1362725ea 100644
--- a/continuousintegration/orchestration/helm/frontend/templates/configmaps/cta-frontend-xrootd.yaml
+++ b/continuousintegration/orchestration/helm/frontend/templates/configmaps/cta-frontend-xrootd.yaml
@@ -20,8 +20,8 @@ data:
     cta.schedulerdb.scheduler_backend_name {{ $schedulerConfig.backend }}
     cta.schedulerdb.numberofthreads {{ .Values.conf.schedulerdb.numberOfThreads }}
     cta.schedulerdb.threadstacksize_mb {{ .Values.conf.schedulerdb.threadStackSizeMb }}
-    cta.schedulerdb.enable_repack_requests {{ .Values.conf.schedulerdb.enableRepackRequests }}
-    cta.schedulerdb.enable_user_requests {{ .Values.conf.schedulerdb.enableUserRequests }}
+    cta.schedulerdb.disable_repack_requests {{ .Values.conf.schedulerdb.disableRepackRequests }}
+    cta.schedulerdb.disable_user_requests {{ .Values.conf.schedulerdb.disableUserRequests }}
 
     # CTA Scheduler DB options - Cache timeout options (decreased for tests)
     cta.schedulerdb.tape_cache_max_age_secs {{ .Values.conf.schedulerdb.tapeCacheMaxAgeSecs }}
diff --git a/continuousintegration/orchestration/helm/frontend/values.yaml b/continuousintegration/orchestration/helm/frontend/values.yaml
index b1c985cf96..282f530ea9 100644
--- a/continuousintegration/orchestration/helm/frontend/values.yaml
+++ b/continuousintegration/orchestration/helm/frontend/values.yaml
@@ -25,8 +25,8 @@ conf:
   schedulerdb:
     numberOfThreads: 500
     threadStackSizeMb: 1
-    enableRepackRequests: "on"
-    enableUserRequests: "on"
+    disableRepackRequests: false
+    disableUserRequests: false
     tapeCacheMaxAgeSecs: 1
     retrieveQueueCacheMaxAgeSecs: 1
 
diff --git a/frontend/common/FrontendService.cpp b/frontend/common/FrontendService.cpp
index 999f51d842..58a2663e1e 100644
--- a/frontend/common/FrontendService.cpp
+++ b/frontend/common/FrontendService.cpp
@@ -325,33 +325,33 @@ FrontendService::FrontendService(const std::string& configFilename) : m_archiveF
   // Configure allowed requests
   {
     // default value for both repack and user requests is "on"
-    auto acceptRepackRequests = config.getOptionValueStr("cta.schedulerdb.enable_repack_requests");
-    if (!acceptRepackRequests.has_value()) {
-      log(log::INFO, "'cta.schedulerdb.enable_repack_requests' not specified in config, defaulting to \"on\"");
+    std::optional<bool> disableRepackRequests = config.getOptionValueBool("cta.schedulerdb.disable_repack_requests");
+    if (!disableRepackRequests.has_value()) {
+      log(log::INFO, "'cta.schedulerdb.disable_repack_requests' not specified in config, defaulting to false");
       m_acceptRepackRequests = true;
     } else {
-      m_acceptRepackRequests = (acceptRepackRequests.value() == "on");
+      m_acceptRepackRequests = !disableRepackRequests;
       std::list<log::Param> params;
       params.push_back(log::Param("source", configFilename));
       params.push_back(log::Param("category", "cta.schedulerdb"));
-      params.push_back(log::Param("key", "enable_repack_requests"));
-      params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.enable_repack_requests").value()));
+      params.push_back(log::Param("key", "disable_repack_requests"));
+      params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.disable_repack_requests").value()));
       log(log::INFO, "Configuration entry", params);
     }
   }
 
   {
-    auto acceptUserRequests = config.getOptionValueStr("cta.schedulerdb.enable_user_requests");
-    if (!acceptUserRequests.has_value()) {
-      log(log::INFO, "'cta.schedulerdb.enable_user_requests' not specified in config, defaulting to \"on\"");
+    auto disableUserRequests = config.getOptionValueBool("cta.schedulerdb.disable_user_requests");
+    if (!disableUserRequests.has_value()) {
+      log(log::INFO, "'cta.schedulerdb.disable_user_requests' not specified in config, defaulting to false");
       m_acceptUserRequests = true;
     } else {
-      m_acceptUserRequests = (acceptUserRequests.value() == "on");
+      m_acceptUserRequests = !disableUserRequests;
       std::list<log::Param> params;
       params.push_back(log::Param("source", configFilename));
       params.push_back(log::Param("category", "cta.schedulerdb"));
-      params.push_back(log::Param("key", "enable_user_requests"));
-      params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.enable_user_requests").value()));
+      params.push_back(log::Param("key", "disable_user_requests"));
+      params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.disable_user_requests").value()));
       log(log::INFO, "Configuration entry", params);
     }
   }
diff --git a/frontend/grpc/cta-frontend-grpc.conf.example b/frontend/grpc/cta-frontend-grpc.conf.example
index 9f7cea506a..0e286c0d98 100644
--- a/frontend/grpc/cta-frontend-grpc.conf.example
+++ b/frontend/grpc/cta-frontend-grpc.conf.example
@@ -94,8 +94,8 @@ cta.log.url file:/var/log/cta/cta-frontend.log
 # cta.schedulerdb.retrieve_queue_cache_max_age_secs 10
 
 # CTA Scheduler DB - enable requests for user or repack
-# cta.schedulerdb.enable_repack_requests on
-# cta.schedulerdb.enable_user_requests on
+# cta.schedulerdb.disable_repack_requests false
+# cta.schedulerdb.disable_user_requests false
 
 # CTA Catalogue options
 cta.catalogue.numberofconnections 10
diff --git a/xroot_plugins/cta-frontend-xrootd.conf.example b/xroot_plugins/cta-frontend-xrootd.conf.example
index 96a8004e18..d3a30b7c66 100644
--- a/xroot_plugins/cta-frontend-xrootd.conf.example
+++ b/xroot_plugins/cta-frontend-xrootd.conf.example
@@ -19,8 +19,8 @@ cta.schedulerdb.numberofthreads 500
 cta.schedulerdb.threadstacksize_mb 1
 
 # CTA Scheduler DB - enable requests for user or repack
-cta.schedulerdb.enable_repack_requests on
-cta.schedulerdb.enable_user_requests on
+cta.schedulerdb.disable_repack_requests false
+cta.schedulerdb.disable_user_requests false
 
 # CTA Scheduler DB - cache timeout options
 # cta.schedulerdb.tape_cache_max_age_secs 600
-- 
GitLab


From 9e08f4ed858e50cb9048a6fdf3061276e69f3ed4 Mon Sep 17 00:00:00 2001
From: Konstantina Skovola <konstantina.skovola@cern.ch>
Date: Tue, 4 Mar 2025 10:07:04 +0100
Subject: [PATCH 06/10] No need to restore config

---
 cta.spec.in | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/cta.spec.in b/cta.spec.in
index f7b4ae1b05..ca51e1df99 100644
--- a/cta.spec.in
+++ b/cta.spec.in
@@ -221,12 +221,6 @@ dCache frontend
 %systemd_postun cta-frontend-grpc.service
 %systemdDaemonReload
 
-%posttrans -n cta-frontend-grpc
-MISSING_CONF=%{_sysconfdir}/cta/cta-frontend-grpc.conf
-if [[ ! -f "${MISSING_CONF}" ]] && [[ -f "${MISSING_CONF}.rpmsave" ]]
-then
-  mv ${MISSING_CONF}.rpmsave ${MISSING_CONF}
-fi
 
 %package -n cta-cli
 Summary: CERN Tape Archive: command line interface
-- 
GitLab


From d5e80850daefe487bd52b343aff53688b0ae2b30 Mon Sep 17 00:00:00 2001
From: Konstantina Skovola <konstantina.skovola@cern.ch>
Date: Tue, 4 Mar 2025 11:02:32 +0100
Subject: [PATCH 07/10] Rename options to follow naming conventions

---
 frontend/common/FrontendService.cpp          | 16 ++++++++--------
 frontend/common/FrontendService.hpp          | 16 ++++++++--------
 frontend/grpc/FrontendCmd.cpp                |  8 ++++----
 frontend/grpc/cta-frontend-grpc.conf.example | 10 +++++-----
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/frontend/common/FrontendService.cpp b/frontend/common/FrontendService.cpp
index 58a2663e1e..05a6a715d4 100644
--- a/frontend/common/FrontendService.cpp
+++ b/frontend/common/FrontendService.cpp
@@ -386,19 +386,19 @@ FrontendService::FrontendService(const std::string& configFilename) : m_archiveF
   // Get the mount policy name for verification requests
 
   // Get the gRPC-specific values, if they are set (getOptionValue returns an std::optional)
-  std::optional<bool> TLS = config.getOptionValueBool("grpc.TLS");
-  m_Tls = TLS.has_value() ? TLS.value() : false;  // default value is false
-  auto TlsKey = config.getOptionValueStr("grpc.TlsKey");
+  std::optional<bool> tls = config.getOptionValueBool("grpc.tls");
+  m_tls = tls.has_value() ? tls.value() : false;  // default value is false
+  auto TlsKey = config.getOptionValueStr("grpc.tls.key");
   if (TlsKey.has_value()) {
-    m_TlsKey = TlsKey.value();
+    m_tlsKey = TlsKey.value();
   }
-  auto TlsCert = config.getOptionValueStr("grpc.TlsCert");
+  auto TlsCert = config.getOptionValueStr("grpc.tls.cert");
   if (TlsCert.has_value()) {
-    m_TlsCert = TlsCert.value();
+    m_tlsCert = TlsCert.value();
   }
-  auto TlsChain = config.getOptionValueStr("grpc.TlsChain");
+  auto TlsChain = config.getOptionValueStr("grpc.tls.chain");
   if (TlsChain.has_value()) {
-    m_TlsChain = TlsChain.value();
+    m_tlsChain = TlsChain.value();
   }
   auto port = config.getOptionValueStr("grpc.port");
   if (port.has_value()) {
diff --git a/frontend/common/FrontendService.hpp b/frontend/common/FrontendService.hpp
index 83a5e5acb5..04d13f1dab 100644
--- a/frontend/common/FrontendService.hpp
+++ b/frontend/common/FrontendService.hpp
@@ -119,22 +119,22 @@ public:
   /*
    * Get the TLS value
    */
-  bool getTls() const { return m_Tls; }
+  bool getTls() const { return m_tls; }
 
   /*
    * Get the TlsKey
    */
-  const std::optional<std::string> getTlsKey() const { return m_TlsKey; }
+  const std::optional<std::string> getTlsKey() const { return m_tlsKey; }
 
   /*
    * Get the TlsCert
    */
-  const std::optional<std::string> getTlsCert() const { return m_TlsCert; }
+  const std::optional<std::string> getTlsCert() const { return m_tlsCert; }
 
   /*
    * Get the TlsChain
    */
-  const std::optional<std::string> getTlsChain() const { return m_TlsChain; }
+  const std::optional<std::string> getTlsChain() const { return m_tlsChain; }
 
   /*
    * Get the gRPC server port
@@ -182,10 +182,10 @@ private:
   cta::NamespaceMap_t                           m_namespaceMap;                 //!< Endpoints for namespace queries  // gRPC-frontend specific variables
   std::optional<std::string>                    m_port;                         //!< The port for the gRPC server
   std::optional<int>                            m_threads;                      //!< The number of threads used by the gRPC server
-  bool                                          m_Tls;                          //!< Use TLS encryption for gRPC
-  std::optional<std::string>                    m_TlsKey;                       //!< The TLS service key file
-  std::optional<std::string>                    m_TlsCert;                      //!< The TLS service certificate file
-  std::optional<std::string>                    m_TlsChain;                     //!< The TLS CA chain file
+  bool                                          m_tls;                          //!< Use TLS encryption for gRPC
+  std::optional<std::string>                    m_tlsKey;                       //!< The TLS service key file
+  std::optional<std::string>                    m_tlsCert;                      //!< The TLS service certificate file
+  std::optional<std::string>                    m_tlsChain;                     //!< The TLS CA chain file
   // clang-format on
 };
 
diff --git a/frontend/grpc/FrontendCmd.cpp b/frontend/grpc/FrontendCmd.cpp
index de5e5778b0..9d162b23e3 100644
--- a/frontend/grpc/FrontendCmd.cpp
+++ b/frontend/grpc/FrontendCmd.cpp
@@ -187,9 +187,9 @@ int cta::frontend::grpc::server::FrontendCmd::main(const int argc, char** argv)
     if (!uiPort) {
       uiPort = config.getOptionValueUInt("grpc.port").value_or(DEFAULT_PORT);
     }
-    strSslRoot = config.getOptionValueStr("grpc.SslRoot").value();
-    strSslKey = config.getOptionValueStr("grpc.SslKey").value();
-    strSslCert = config.getOptionValueStr("grpc.SslCert").value();
+    strSslRoot = config.getOptionValueStr("grpc.ssl.root").value();
+    strSslKey = config.getOptionValueStr("grpc.ssl.key").value();
+    strSslCert = config.getOptionValueStr("grpc.ssl.cert").value();
   } catch(const cta::exception::Exception &ex) {
     m_err << m_strExecName << ": problem while reading a configuration file - " << ex.getMessage().str() << std::endl;
     return EXIT_FAILURE;
@@ -200,7 +200,7 @@ int cta::frontend::grpc::server::FrontendCmd::main(const int argc, char** argv)
   }
 
   if(strKeytab.empty()) {
-    strKeytab = config.getOptionValueStr("grpc.Keytab").value_or("");
+    strKeytab = config.getOptionValueStr("grpc.keytab").value_or("");
     // and check again
     if(strKeytab.empty()) {
       m_err << m_strExecName << ": the keytab file is unspecified" << std::endl
diff --git a/frontend/grpc/cta-frontend-grpc.conf.example b/frontend/grpc/cta-frontend-grpc.conf.example
index 0e286c0d98..bddb45e40e 100644
--- a/frontend/grpc/cta-frontend-grpc.conf.example
+++ b/frontend/grpc/cta-frontend-grpc.conf.example
@@ -73,7 +73,7 @@ cta.log.url file:/var/log/cta/cta-frontend.log
 #  TLS related variables. Only used when TLS is true
 ####################################
 # Use TLS (previously the command-line option --tls)
-#grpc.TLS true/false
+#grpc.tls true/false
 #  TLS service key file
 #grpc.tls.key /path/to/key
 #
@@ -108,13 +108,13 @@ cta.catalogue.numberofconnections 10
 #grpc.port 17017
 
 # The ca-cert file path
-#grpc.SslRoot /path/to/ca/cert
+#grpc.ssl.root /path/to/ca/cert
 
 # Ssl Key file
-#grpc.SslKey /path/to/ssl/key
+#grpc.ssl.key /path/to/ssl/key
 
 # Ssl certificate file
-#grpc.SslCert /path/to/ssl/cert
+#grpc.ssl.cert /path/to/ssl/cert
 
 # keytab file
-#grpc.Keytab /path/to/keytab
+#grpc.keytab /path/to/keytab
-- 
GitLab


From e17201f167bef473c9dff5bc55fbafd68126fdda Mon Sep 17 00:00:00 2001
From: Konstantina Skovola <konstantina.skovola@cern.ch>
Date: Fri, 7 Mar 2025 15:16:21 +0100
Subject: [PATCH 08/10] Fix handling of optional bool value

---
 cta.spec.in                         | 1 -
 frontend/common/FrontendService.cpp | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/cta.spec.in b/cta.spec.in
index ca51e1df99..c1c996f6b8 100644
--- a/cta.spec.in
+++ b/cta.spec.in
@@ -221,7 +221,6 @@ dCache frontend
 %systemd_postun cta-frontend-grpc.service
 %systemdDaemonReload
 
-
 %package -n cta-cli
 Summary: CERN Tape Archive: command line interface
 Group: Application/CTA
diff --git a/frontend/common/FrontendService.cpp b/frontend/common/FrontendService.cpp
index 05a6a715d4..42ca1e51b2 100644
--- a/frontend/common/FrontendService.cpp
+++ b/frontend/common/FrontendService.cpp
@@ -330,7 +330,7 @@ FrontendService::FrontendService(const std::string& configFilename) : m_archiveF
       log(log::INFO, "'cta.schedulerdb.disable_repack_requests' not specified in config, defaulting to false");
       m_acceptRepackRequests = true;
     } else {
-      m_acceptRepackRequests = !disableRepackRequests;
+      m_acceptRepackRequests = !disableRepackRequests.value();
       std::list<log::Param> params;
       params.push_back(log::Param("source", configFilename));
       params.push_back(log::Param("category", "cta.schedulerdb"));
@@ -346,7 +346,7 @@ FrontendService::FrontendService(const std::string& configFilename) : m_archiveF
       log(log::INFO, "'cta.schedulerdb.disable_user_requests' not specified in config, defaulting to false");
       m_acceptUserRequests = true;
     } else {
-      m_acceptUserRequests = !disableUserRequests;
+      m_acceptUserRequests = !disableUserRequests.value();
       std::list<log::Param> params;
       params.push_back(log::Param("source", configFilename));
       params.push_back(log::Param("category", "cta.schedulerdb"));
-- 
GitLab


From 1604bfefb1e54c86a868f812e31cb3a8abb396b4 Mon Sep 17 00:00:00 2001
From: Konstantina Skovola <konstantina.skovola@cern.ch>
Date: Fri, 7 Mar 2025 16:06:19 +0100
Subject: [PATCH 09/10] Comment default option

---
 xroot_plugins/cta-frontend-xrootd.conf.example | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xroot_plugins/cta-frontend-xrootd.conf.example b/xroot_plugins/cta-frontend-xrootd.conf.example
index d3a30b7c66..1c2f62d647 100644
--- a/xroot_plugins/cta-frontend-xrootd.conf.example
+++ b/xroot_plugins/cta-frontend-xrootd.conf.example
@@ -19,8 +19,8 @@ cta.schedulerdb.numberofthreads 500
 cta.schedulerdb.threadstacksize_mb 1
 
 # CTA Scheduler DB - enable requests for user or repack
-cta.schedulerdb.disable_repack_requests false
-cta.schedulerdb.disable_user_requests false
+# cta.schedulerdb.disable_repack_requests false
+# cta.schedulerdb.disable_user_requests false
 
 # CTA Scheduler DB - cache timeout options
 # cta.schedulerdb.tape_cache_max_age_secs 600
-- 
GitLab


From 265c7742d28db0f45db22ea3be3c15d3dd81d8b9 Mon Sep 17 00:00:00 2001
From: Konstantina Skovola <konstantina.skovola@cern.ch>
Date: Fri, 7 Mar 2025 16:58:15 +0100
Subject: [PATCH 10/10] Update logs printed

---
 frontend/common/FrontendService.cpp | 40 ++++++++++++-----------------
 1 file changed, 16 insertions(+), 24 deletions(-)

diff --git a/frontend/common/FrontendService.cpp b/frontend/common/FrontendService.cpp
index 42ca1e51b2..1d04598ec6 100644
--- a/frontend/common/FrontendService.cpp
+++ b/frontend/common/FrontendService.cpp
@@ -326,34 +326,26 @@ FrontendService::FrontendService(const std::string& configFilename) : m_archiveF
   {
     // default value for both repack and user requests is "on"
     std::optional<bool> disableRepackRequests = config.getOptionValueBool("cta.schedulerdb.disable_repack_requests");
-    if (!disableRepackRequests.has_value()) {
-      log(log::INFO, "'cta.schedulerdb.disable_repack_requests' not specified in config, defaulting to false");
-      m_acceptRepackRequests = true;
-    } else {
-      m_acceptRepackRequests = !disableRepackRequests.value();
-      std::list<log::Param> params;
-      params.push_back(log::Param("source", configFilename));
-      params.push_back(log::Param("category", "cta.schedulerdb"));
-      params.push_back(log::Param("key", "disable_repack_requests"));
-      params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.disable_repack_requests").value()));
-      log(log::INFO, "Configuration entry", params);
-    }
+    m_acceptRepackRequests = disableRepackRequests.has_value() ? (!disableRepackRequests.value()) : true;
+
+    std::list<log::Param> params;
+    params.push_back(log::Param("source", disableRepackRequests.has_value() ? configFilename : "Compile time default"));
+    params.push_back(log::Param("category", "cta.schedulerdb"));
+    params.push_back(log::Param("key", "disable_repack_requests"));
+    params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.disable_repack_requests").value()));
+    log(log::INFO, "Configuration entry", params);
   }
 
   {
     auto disableUserRequests = config.getOptionValueBool("cta.schedulerdb.disable_user_requests");
-    if (!disableUserRequests.has_value()) {
-      log(log::INFO, "'cta.schedulerdb.disable_user_requests' not specified in config, defaulting to false");
-      m_acceptUserRequests = true;
-    } else {
-      m_acceptUserRequests = !disableUserRequests.value();
-      std::list<log::Param> params;
-      params.push_back(log::Param("source", configFilename));
-      params.push_back(log::Param("category", "cta.schedulerdb"));
-      params.push_back(log::Param("key", "disable_user_requests"));
-      params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.disable_user_requests").value()));
-      log(log::INFO, "Configuration entry", params);
-    }
+    m_acceptUserRequests = disableUserRequests.has_value() ? (!disableUserRequests.value()) : true;
+
+    std::list<log::Param> params;
+    params.push_back(log::Param("source", disableUserRequests.has_value() ? configFilename : "Compile time default"));
+    params.push_back(log::Param("category", "cta.schedulerdb"));
+    params.push_back(log::Param("key", "disable_user_requests"));
+    params.push_back(log::Param("value", config.getOptionValueStr("cta.schedulerdb.disable_user_requests").value()));
+    log(log::INFO, "Configuration entry", params);
   }
 
   {
-- 
GitLab