func isWrongRegion(op string) bool {
	errTexts := []string{
		"You are trying to access your S3 bucket using the wrong region",
		"the region '.+' is wrong; expecting '.+'",
	}
	for i := range errTexts {
		re := regexp.MustCompile(errTexts[i])
		if re.FindAllString(op, -1) != nil {
			return true
		}
	}
	return false
}
isWrongRegion will check the error to see if we are accessing the wrong S3 region
package controllers
import (
	"context"
	"fmt"
	"regexp"
	"sort"
	"strings"
	"time"
	"github.com/go-logr/logr"
	vapi "github.com/vertica/vertica-kubernetes/api/v1beta1"
	"github.com/vertica/vertica-kubernetes/pkg/cmds"
	"github.com/vertica/vertica-kubernetes/pkg/events"
	"github.com/vertica/vertica-kubernetes/pkg/license"
	"github.com/vertica/vertica-kubernetes/pkg/names"
	"github.com/vertica/vertica-kubernetes/pkg/paths"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/types"
	ctrl "sigs.k8s.io/controller-runtime"
)
const (
	PostDBCreateSQLFile = "/home/dbadmin/post-db-create.sql"
)
type CreateDBReconciler struct {
	VRec    *VerticaDBReconciler
	Log     logr.Logger
	Vdb     *vapi.VerticaDB  
	PRunner cmds.PodRunner
	PFacts  *PodFacts
}
func MakeCreateDBReconciler(vdbrecon *VerticaDBReconciler, log logr.Logger,
	vdb *vapi.VerticaDB, prunner cmds.PodRunner, pfacts *PodFacts) ReconcileActor {
	return &CreateDBReconciler{VRec: vdbrecon, Log: log, Vdb: vdb, PRunner: prunner, PFacts: pfacts}
}
func (c *CreateDBReconciler) Reconcile(ctx context.Context, req *ctrl.Request) (ctrl.Result, error) {
	if c.Vdb.Spec.InitPolicy != vapi.CommunalInitPolicyCreate {
		return ctrl.Result{}, nil
	}
	g := GenericDatabaseInitializer{
		initializer: c,
		VRec:        c.VRec,
		Log:         c.Log,
		Vdb:         c.Vdb,
		PRunner:     c.PRunner,
		PFacts:      c.PFacts,
	}
	return g.checkAndRunInit(ctx)
}
func (c *CreateDBReconciler) execCmd(ctx context.Context, atPod types.NamespacedName, cmd []string) (ctrl.Result, error) {
	c.VRec.EVRec.Event(c.Vdb, corev1.EventTypeNormal, events.CreateDBStart,
		"Calling 'admintools -t create_db'")
	start := time.Now()
	stdout, _, err := c.PRunner.ExecAdmintools(ctx, atPod, names.ServerContainer, cmd...)
	if err != nil {
		switch {
		case isEndpointBadError(stdout):
			c.VRec.EVRec.Eventf(c.Vdb, corev1.EventTypeWarning, events.S3EndpointIssue,
				"Unable to write to the bucket in the S3 endpoint '%s'", c.Vdb.Spec.Communal.Endpoint)
			return ctrl.Result{Requeue: true}, nil
		case isBucketNotExistError(stdout):
			c.VRec.EVRec.Eventf(c.Vdb, corev1.EventTypeWarning, events.S3BucketDoesNotExist,
				"The bucket in the S3 path '%s' does not exist", c.Vdb.GetCommunalPath())
			return ctrl.Result{Requeue: true}, nil
		case isCommunalPathNotEmpty(stdout):
			c.VRec.EVRec.Eventf(c.Vdb, corev1.EventTypeWarning, events.CommunalPathIsNotEmpty,
				"The communal path '%s' is not empty", c.Vdb.GetCommunalPath())
			return ctrl.Result{Requeue: true}, nil
		case isWrongRegion(stdout):
			c.VRec.EVRec.Eventf(c.Vdb, corev1.EventTypeWarning, events.S3WrongRegion,
				"You are trying to access your S3 bucket using the wrong region")
			return ctrl.Result{Requeue: true}, nil
		default:
			c.VRec.EVRec.Event(c.Vdb, corev1.EventTypeWarning, events.CreateDBFailed,
				"Failed to create the database")
			return ctrl.Result{}, err
		}
	}
	c.VRec.EVRec.Eventf(c.Vdb, corev1.EventTypeNormal, events.CreateDBSucceeded,
		"Successfully created database with subcluster '%s'. It took %s", c.Vdb.Spec.Subclusters[0].Name, time.Since(start))
	return ctrl.Result{}, nil
}
func isCommunalPathNotEmpty(op string) bool {
	re := regexp.MustCompile(`Communal location \[.+\] is not empty`)
	return re.FindAllString(op, -1) != nil
}