This is an automated email from the ASF dual-hosted git repository.

houston pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 61954e6  Test if backup directory is writable to avoid chown (#548)
61954e6 is described below

commit 61954e6907a3cbfdff5de1331e075f779e96d1d9
Author: Steffen Moldenhauer <[email protected]>
AuthorDate: Wed Apr 12 19:32:16 2023 +0200

    Test if backup directory is writable to avoid chown (#548)
---
 controllers/util/solr_util.go | 4 +++-
 helm/solr-operator/Chart.yaml | 7 +++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/controllers/util/solr_util.go b/controllers/util/solr_util.go
index a46ba62..9e46fe8 100644
--- a/controllers/util/solr_util.go
+++ b/controllers/util/solr_util.go
@@ -618,6 +618,7 @@ func generateSolrSetupInitContainers(solrCloud 
*solr.SolrCloud, solrCloudStatus
                },
        }
        setupCommands := []string{"cp /tmp/solr.xml /tmp-config/solr.xml"}
+       setupCommands = append(setupCommands, fmt.Sprintf("adduser -u %d -H -D 
solr", DefaultSolrUser))
 
        // Add prep for backup-restore Repositories
        // This entails setting the correct permissions for the directory
@@ -627,7 +628,8 @@ func generateSolrSetupInitContainers(solrCloud 
*solr.SolrCloud, solrCloudStatus
                                volumeMounts = append(volumeMounts, 
*volumeMount)
 
                                setupCommands = append(setupCommands, 
fmt.Sprintf(
-                                       "chown -R %d:%d %s",
+                                       "(su solr -c 'test -w %s' || chown -R 
%d:%d %s)",
+                                       volumeMount.MountPath,
                                        DefaultSolrUser,
                                        DefaultSolrGroup,
                                        volumeMount.MountPath))
diff --git a/helm/solr-operator/Chart.yaml b/helm/solr-operator/Chart.yaml
index 6607cee..d7691bc 100644
--- a/helm/solr-operator/Chart.yaml
+++ b/helm/solr-operator/Chart.yaml
@@ -146,6 +146,13 @@ annotations:
           url: https://github.com/apache/solr-operator/issues/477
         - name: GitHub PR
           url: https://github.com/apache/solr-operator/pull/546
+    - kind: fixed
+      description: Avoid backup directory chown when directories are already 
writable
+      links:
+        - name: GitHub Issue
+          url: https://github.com/apache/solr-operator/issues/537
+        - name: GitHub PR
+          url: https://github.com/apache/solr-operator/pull/548
   artifacthub.io/images: |
     - name: solr-operator
       image: apache/solr-operator:v0.7.0-prerelease

Reply via email to