thelabdude commented on a change in pull request #221:
URL:
https://github.com/apache/lucene-solr-operator/pull/221#discussion_r580726397
##########
File path: controllers/solrcloud_controller.go
##########
@@ -256,6 +257,55 @@ func (r *SolrCloudReconciler) Reconcile(req ctrl.Request)
(ctrl.Result, error) {
}
}
+ basicAuthCreds := ""
+ if instance.Spec.SolrSecurity != nil {
+ ctx := context.TODO()
+ sec := instance.Spec.SolrSecurity
+ username := solr.DefaultBasicAuthUsername
+ secretName := instance.BasicAuthSecretName()
+ basicAuthSecret := &corev1.Secret{}
+
+ // user has the option of providing a secret with credentials
the operator should use to make requests to Solr
+ if sec.BasicAuthSecret != nil {
+ if err := r.Get(ctx, types.NamespacedName{Name:
secretName, Namespace: instance.Namespace}, basicAuthSecret); err != nil {
+ return requeueOrNot, err
+ }
+
+ if _, ok :=
basicAuthSecret.Data[sec.BasicAuthSecret.Key]; !ok {
+ return requeueOrNot, fmt.Errorf("required %s
key not found in user-provided basic-auth secret %s",
+ sec.BasicAuthSecret.Key, secretName)
+ }
+
+ // the username is the key from the user-provided secret
+ username = sec.BasicAuthSecret.Key
+ } else {
+ // We're supplying a secret with random passwords and a
default security.json
+ // since we randomly generate the passwords, we need to
lookup the secret first and only create if not exist
+ err = r.Get(ctx, types.NamespacedName{Name: secretName,
Namespace: instance.Namespace}, basicAuthSecret)
+ if err != nil && errors.IsNotFound(err) {
+ newSecret :=
util.GenerateBasicAuthSecret(instance)
+ if err :=
controllerutil.SetControllerReference(instance, newSecret, r.scheme); err !=
nil {
+ return requeueOrNot, err
+ }
+ err = r.Create(ctx, newSecret)
+ basicAuthSecret = newSecret
+ }
+ if err != nil {
+ return requeueOrNot, err
+ }
+ // supply the bootstrap security.json to the
initContainer via a simple BASE64 encoding env var
+ configMapInfo[util.SecurityJsonFile] =
string(basicAuthSecret.Data[util.SecurityJsonFile])
+ }
+
+ // save some basic information needed to configure probes for
auth-enabled Solr pods
+ configMapInfo[util.SecuritySecret] = basicAuthSecret.Name
Review comment:
I renamed it to `reconcileConfigInfo` since it holds additional config
info computed during reconcile ... ;-)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]