You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/10/06 15:27:48 UTC

[GitHub] [solr-operator] HoustonPutman commented on a change in pull request #334: Refactor security related code into a separate solr_security_util.go vs. sprinkled throughout the codebase.

HoustonPutman commented on a change in pull request #334:
URL: https://github.com/apache/solr-operator/pull/334#discussion_r723389167



##########
File path: controllers/util/solr_security_util.go
##########
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package util
+
+import (
+	"context"
+	"crypto/sha256"
+	b64 "encoding/base64"
+	"encoding/json"
+	"fmt"
+	solr "github.com/apache/solr-operator/api/v1beta1"
+	appsv1 "k8s.io/api/apps/v1"
+	corev1 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/api/errors"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/types"
+	"math/rand"
+	"regexp"
+	"sigs.k8s.io/controller-runtime/pkg/client"
+	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
+	"strings"
+	"time"
+)
+
+const (
+	SecurityJsonFile       = "security.json"
+	BasicAuthMd5Annotation = "solr.apache.org/basicAuthMd5"
+	DefaultProbePath       = "/admin/info/system"
+)
+
+type SecurityConfig struct {
+	BasicAuthSecret *corev1.Secret
+	SecurityJson    string
+}
+
+// Given a SolrCloud instance and an API service client, produce a SecurityConfig needed to enable Solr security
+func ReconcileSecurityConfig(client *client.Client, instance *solr.SolrCloud) (*SecurityConfig, error) {
+	ctx := context.TODO()

Review comment:
       can you pass the context from the controller, now that a reconcile is called with a given context?

##########
File path: controllers/util/solr_util.go
##########
@@ -1010,21 +992,21 @@ func generateZKInteractionInitContainer(solrCloud *solr.SolrCloud, solrCloudStat
 
 	cmd := ""
 
+	if hasChroot {
+		cmd += "solr zk ls ${ZK_CHROOT} -z ${ZK_SERVER} || solr zk mkroot ${ZK_CHROOT} -z ${ZK_SERVER}; "
+	}
+
 	if solrCloud.Spec.SolrTLS != nil {
 		cmd = setUrlSchemeClusterPropCmd()

Review comment:
       I think you want this to be a `+=`, if you are moving the `hasChroot` logic above here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org