func (c *M3DBController) reconcileNamespaces(cluster *myspec.M3DBCluster) error {
	resp, err := c.adminClient.namespaceClientForCluster(cluster).List()
	if err != nil {
		c.logger.Error("failed to get namespace", zap.Error(err))
		c.recorder.WarningEvent(cluster, eventer.ReasonFailSync, err.Error())
		return err
	}
	if err := c.pruneNamespaces(cluster, resp.Registry); err != nil {
		return err
	}
	if err := c.createNamespaces(cluster, resp.Registry); err != nil {
		return err
	}
	return c.readyNamespaces(cluster, resp.Registry)
}
reconcileNamespaces will delete any namespaces currently in the cluster that
aren't part of the cluster spec, and create any that are present in the spec
but not in the cluster.
package controller
import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"reflect"
	"sort"
	"strconv"
	"strings"
	"time"
	myspec "github.com/m3db/m3db-operator/pkg/apis/m3dboperator/v1alpha1"
	"github.com/m3db/m3db-operator/pkg/k8sops/labels"
	"github.com/m3db/m3db-operator/pkg/k8sops/m3db"
	"github.com/m3db/m3db-operator/pkg/k8sops/podidentity"
	"github.com/m3db/m3db-operator/pkg/m3admin"
	"github.com/m3db/m3db-operator/pkg/m3admin/namespace"
	"github.com/m3db/m3db-operator/pkg/util/eventer"
	"github.com/m3db/m3/src/cluster/generated/proto/placementpb"
	"github.com/m3db/m3/src/cluster/placement"
	dbns "github.com/m3db/m3/src/dbnode/generated/proto/namespace"
	"github.com/m3db/m3/src/query/generated/proto/admin"
	appsv1 "k8s.io/api/apps/v1"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	klabels "k8s.io/apimachinery/pkg/labels"
	"k8s.io/apimachinery/pkg/util/runtime"
	pkgerrors "github.com/pkg/errors"
	"go.uber.org/zap"
)
var (
	errEmptyPodList         = errors.New("cannot find removal candidate in empty list")
	errNoPodsInPlacement    = errors.New("no pods were found in the placement")
	errNilNamespaceRegistry = errors.New("nil registry for namespaces")
	errPodNotInPlacement    = errors.New("instance not found in placement")
)