From 107139365ccc15d4cc38bffdfd4165b22b8e2844 Mon Sep 17 00:00:00 2001 From: Steffen Moldenhauer Date: Fri, 31 Mar 2023 11:41:47 +0200 Subject: [PATCH] feat: test backup directory is writable to avoid chown (#537) --- controllers/util/solr_util.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/util/solr_util.go b/controllers/util/solr_util.go index a46ba629..9e46fe8d 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))