Merge branch 'master' into fix/graceful-shutdown
# Conflicts: # pkg/cluster/cluster.go # pkg/cluster/exec.go # pkg/cluster/k8sres.go # pkg/cluster/pod.go # pkg/cluster/resources.go # pkg/cluster/util.go # pkg/cluster/volumes.go # pkg/controller/controller.go # pkg/controller/pod.go # pkg/controller/postgresql.go # pkg/controller/util.go # pkg/controller/util_test.go # pkg/spec/postgresql.go # pkg/spec/postgresql_test.go # pkg/util/util.go # pkg/util/util_test.go
This commit is contained in:
		
						commit
						50aaa16574
					
				|  | @ -11,7 +11,7 @@ import ( | ||||||
| 	"sync" | 	"sync" | ||||||
| 
 | 
 | ||||||
| 	"github.com/Sirupsen/logrus" | 	"github.com/Sirupsen/logrus" | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/types" | 	"k8s.io/apimachinery/pkg/types" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | ||||||
|  | @ -62,7 +62,7 @@ type Cluster struct { | ||||||
| 	mu               sync.Mutex | 	mu               sync.Mutex | ||||||
| 	masterLess       bool | 	masterLess       bool | ||||||
| 	userSyncStrategy spec.UserSyncer | 	userSyncStrategy spec.UserSyncer | ||||||
| 	deleteOptions    *meta_v1.DeleteOptions | 	deleteOptions    *metav1.DeleteOptions | ||||||
| 	podEventsQueue   *cache.FIFO | 	podEventsQueue   *cache.FIFO | ||||||
| 
 | 
 | ||||||
| 	teamsAPIClient *teams.API | 	teamsAPIClient *teams.API | ||||||
|  | @ -78,7 +78,7 @@ type compareStatefulsetResult struct { | ||||||
| 
 | 
 | ||||||
| // New creates a new cluster. This function should be called from a controller.
 | // New creates a new cluster. This function should be called from a controller.
 | ||||||
| func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec spec.Postgresql, logger *logrus.Entry) *Cluster { | func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec spec.Postgresql, logger *logrus.Entry) *Cluster { | ||||||
| 	lg := logger.WithField("pkg", "cluster").WithField("cluster-name", pgSpec.Metadata.Name) | 	lg := logger.WithField("pkg", "cluster").WithField("cluster-name", pgSpec.Name) | ||||||
| 	kubeResources := kubeResources{Secrets: make(map[types.UID]*v1.Secret), Service: make(map[PostgresRole]*v1.Service)} | 	kubeResources := kubeResources{Secrets: make(map[types.UID]*v1.Secret), Service: make(map[PostgresRole]*v1.Service)} | ||||||
| 	orphanDependents := true | 	orphanDependents := true | ||||||
| 
 | 
 | ||||||
|  | @ -101,7 +101,7 @@ func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec spec.Postgresql | ||||||
| 		kubeResources:    kubeResources, | 		kubeResources:    kubeResources, | ||||||
| 		masterLess:       false, | 		masterLess:       false, | ||||||
| 		userSyncStrategy: users.DefaultUserSyncStrategy{}, | 		userSyncStrategy: users.DefaultUserSyncStrategy{}, | ||||||
| 		deleteOptions:    &meta_v1.DeleteOptions{OrphanDependents: &orphanDependents}, | 		deleteOptions:    &metav1.DeleteOptions{OrphanDependents: &orphanDependents}, | ||||||
| 		podEventsQueue:   podEventsQueue, | 		podEventsQueue:   podEventsQueue, | ||||||
| 		KubeClient:       kubeClient, | 		KubeClient:       kubeClient, | ||||||
| 		teamsAPIClient:   teams.NewTeamsAPI(cfg.OpConfig.TeamsAPIUrl, logger.Logger), | 		teamsAPIClient:   teams.NewTeamsAPI(cfg.OpConfig.TeamsAPIUrl, logger.Logger), | ||||||
|  | @ -111,7 +111,7 @@ func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec spec.Postgresql | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) clusterName() spec.NamespacedName { | func (c *Cluster) clusterName() spec.NamespacedName { | ||||||
| 	return util.NameFromMeta(c.Metadata) | 	return util.NameFromMeta(c.ObjectMeta) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) teamName() string { | func (c *Cluster) teamName() string { | ||||||
|  | @ -128,7 +128,7 @@ func (c *Cluster) setStatus(status spec.PostgresStatus) { | ||||||
| 	request := []byte(fmt.Sprintf(`{"status": %s}`, string(b))) //TODO: Look into/wait for k8s go client methods
 | 	request := []byte(fmt.Sprintf(`{"status": %s}`, string(b))) //TODO: Look into/wait for k8s go client methods
 | ||||||
| 
 | 
 | ||||||
| 	_, err = c.KubeClient.RESTClient.Patch(types.MergePatchType). | 	_, err = c.KubeClient.RESTClient.Patch(types.MergePatchType). | ||||||
| 		RequestURI(c.Metadata.GetSelfLink()). | 		RequestURI(c.GetSelfLink()). | ||||||
| 		Body(request). | 		Body(request). | ||||||
| 		DoRaw() | 		DoRaw() | ||||||
| 
 | 
 | ||||||
|  | @ -407,7 +407,7 @@ func (c *Cluster) Update(newSpec *spec.Postgresql) error { | ||||||
| 
 | 
 | ||||||
| 	c.setStatus(spec.ClusterStatusUpdating) | 	c.setStatus(spec.ClusterStatusUpdating) | ||||||
| 	c.logger.Debugf("Cluster update from version %q to %q", | 	c.logger.Debugf("Cluster update from version %q to %q", | ||||||
| 		c.Metadata.ResourceVersion, newSpec.Metadata.ResourceVersion) | 		c.ResourceVersion, newSpec.ResourceVersion) | ||||||
| 
 | 
 | ||||||
| 	/* Make sure we update when this function exists */ | 	/* Make sure we update when this function exists */ | ||||||
| 	defer func() { | 	defer func() { | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 
 | 
 | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand" | 	remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand" | ||||||
| 	"k8s.io/client-go/kubernetes/scheme" | 	"k8s.io/client-go/kubernetes/scheme" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
|  | @ -19,7 +19,7 @@ func (c *Cluster) ExecCommand(podName *spec.NamespacedName, command ...string) ( | ||||||
| 		execErr bytes.Buffer | 		execErr bytes.Buffer | ||||||
| 	) | 	) | ||||||
| 
 | 
 | ||||||
| 	pod, err := c.KubeClient.Pods(podName.Namespace).Get(podName.Name, meta_v1.GetOptions{}) | 	pod, err := c.KubeClient.Pods(podName.Namespace).Get(podName.Name, metav1.GetOptions{}) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", fmt.Errorf("could not get pod info: %v", err) | 		return "", fmt.Errorf("could not get pod info: %v", err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ import ( | ||||||
| 	"sort" | 	"sort" | ||||||
| 
 | 
 | ||||||
| 	"k8s.io/apimachinery/pkg/api/resource" | 	"k8s.io/apimachinery/pkg/api/resource" | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/util/intstr" | 	"k8s.io/apimachinery/pkg/util/intstr" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | ||||||
|  | @ -211,7 +211,7 @@ func (c *Cluster) generatePodTemplate(resourceRequirements *v1.ResourceRequireme | ||||||
| 	envVars := []v1.EnvVar{ | 	envVars := []v1.EnvVar{ | ||||||
| 		{ | 		{ | ||||||
| 			Name:  "SCOPE", | 			Name:  "SCOPE", | ||||||
| 			Value: c.Metadata.Name, | 			Value: c.Name, | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Name:  "PGROOT", | 			Name:  "PGROOT", | ||||||
|  | @ -274,7 +274,7 @@ func (c *Cluster) generatePodTemplate(resourceRequirements *v1.ResourceRequireme | ||||||
| 	} | 	} | ||||||
| 	privilegedMode := bool(true) | 	privilegedMode := bool(true) | ||||||
| 	container := v1.Container{ | 	container := v1.Container{ | ||||||
| 		Name:            c.Metadata.Name, | 		Name:            c.Name, | ||||||
| 		Image:           c.OpConfig.DockerImage, | 		Image:           c.OpConfig.DockerImage, | ||||||
| 		ImagePullPolicy: v1.PullAlways, | 		ImagePullPolicy: v1.PullAlways, | ||||||
| 		Resources:       *resourceRequirements, | 		Resources:       *resourceRequirements, | ||||||
|  | @ -312,9 +312,9 @@ func (c *Cluster) generatePodTemplate(resourceRequirements *v1.ResourceRequireme | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	template := v1.PodTemplateSpec{ | 	template := v1.PodTemplateSpec{ | ||||||
| 		ObjectMeta: meta_v1.ObjectMeta{ | 		ObjectMeta: metav1.ObjectMeta{ | ||||||
| 			Labels:    c.labelsSet(), | 			Labels:    c.labelsSet(), | ||||||
| 			Namespace: c.Metadata.Name, | 			Namespace: c.Name, | ||||||
| 		}, | 		}, | ||||||
| 		Spec: podSpec, | 		Spec: podSpec, | ||||||
| 	} | 	} | ||||||
|  | @ -338,14 +338,14 @@ func (c *Cluster) generateStatefulSet(spec spec.PostgresSpec) (*v1beta1.Stateful | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	statefulSet := &v1beta1.StatefulSet{ | 	statefulSet := &v1beta1.StatefulSet{ | ||||||
| 		ObjectMeta: meta_v1.ObjectMeta{ | 		ObjectMeta: metav1.ObjectMeta{ | ||||||
| 			Name:      c.Metadata.Name, | 			Name:      c.Name, | ||||||
| 			Namespace: c.Metadata.Namespace, | 			Namespace: c.Namespace, | ||||||
| 			Labels:    c.labelsSet(), | 			Labels:    c.labelsSet(), | ||||||
| 		}, | 		}, | ||||||
| 		Spec: v1beta1.StatefulSetSpec{ | 		Spec: v1beta1.StatefulSetSpec{ | ||||||
| 			Replicas:             &spec.NumberOfInstances, | 			Replicas:             &spec.NumberOfInstances, | ||||||
| 			ServiceName:          c.Metadata.Name, | 			ServiceName:          c.Name, | ||||||
| 			Template:             *podTemplate, | 			Template:             *podTemplate, | ||||||
| 			VolumeClaimTemplates: []v1.PersistentVolumeClaim{*volumeClaimTemplate}, | 			VolumeClaimTemplates: []v1.PersistentVolumeClaim{*volumeClaimTemplate}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -355,7 +355,7 @@ func (c *Cluster) generateStatefulSet(spec spec.PostgresSpec) (*v1beta1.Stateful | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func generatePersistentVolumeClaimTemplate(volumeSize, volumeStorageClass string) (*v1.PersistentVolumeClaim, error) { | func generatePersistentVolumeClaimTemplate(volumeSize, volumeStorageClass string) (*v1.PersistentVolumeClaim, error) { | ||||||
| 	metadata := meta_v1.ObjectMeta{ | 	metadata := metav1.ObjectMeta{ | ||||||
| 		Name: constants.DataVolumeName, | 		Name: constants.DataVolumeName, | ||||||
| 	} | 	} | ||||||
| 	if volumeStorageClass != "" { | 	if volumeStorageClass != "" { | ||||||
|  | @ -387,7 +387,7 @@ func generatePersistentVolumeClaimTemplate(volumeSize, volumeStorageClass string | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) generateUserSecrets() (secrets map[string]*v1.Secret) { | func (c *Cluster) generateUserSecrets() (secrets map[string]*v1.Secret) { | ||||||
| 	secrets = make(map[string]*v1.Secret, len(c.pgUsers)) | 	secrets = make(map[string]*v1.Secret, len(c.pgUsers)) | ||||||
| 	namespace := c.Metadata.Namespace | 	namespace := c.Namespace | ||||||
| 	for username, pgUser := range c.pgUsers { | 	for username, pgUser := range c.pgUsers { | ||||||
| 		//Skip users with no password i.e. human users (they'll be authenticated using pam)
 | 		//Skip users with no password i.e. human users (they'll be authenticated using pam)
 | ||||||
| 		secret := c.generateSingleUserSecret(namespace, pgUser) | 		secret := c.generateSingleUserSecret(namespace, pgUser) | ||||||
|  | @ -413,7 +413,7 @@ func (c *Cluster) generateSingleUserSecret(namespace string, pgUser spec.PgUser) | ||||||
| 	} | 	} | ||||||
| 	username := pgUser.Name | 	username := pgUser.Name | ||||||
| 	secret := v1.Secret{ | 	secret := v1.Secret{ | ||||||
| 		ObjectMeta: meta_v1.ObjectMeta{ | 		ObjectMeta: metav1.ObjectMeta{ | ||||||
| 			Name:      c.credentialSecretName(username), | 			Name:      c.credentialSecretName(username), | ||||||
| 			Namespace: namespace, | 			Namespace: namespace, | ||||||
| 			Labels:    c.labelsSet(), | 			Labels:    c.labelsSet(), | ||||||
|  | @ -430,7 +430,7 @@ func (c *Cluster) generateSingleUserSecret(namespace string, pgUser spec.PgUser) | ||||||
| func (c *Cluster) generateService(role PostgresRole, newSpec *spec.PostgresSpec) *v1.Service { | func (c *Cluster) generateService(role PostgresRole, newSpec *spec.PostgresSpec) *v1.Service { | ||||||
| 
 | 
 | ||||||
| 	dnsNameFunction := c.masterDnsName | 	dnsNameFunction := c.masterDnsName | ||||||
| 	name := c.Metadata.Name | 	name := c.Name | ||||||
| 	if role == Replica { | 	if role == Replica { | ||||||
| 		dnsNameFunction = c.replicaDnsName | 		dnsNameFunction = c.replicaDnsName | ||||||
| 		name = name + "-repl" | 		name = name + "-repl" | ||||||
|  | @ -469,9 +469,9 @@ func (c *Cluster) generateService(role PostgresRole, newSpec *spec.PostgresSpec) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	service := &v1.Service{ | 	service := &v1.Service{ | ||||||
| 		ObjectMeta: meta_v1.ObjectMeta{ | 		ObjectMeta: metav1.ObjectMeta{ | ||||||
| 			Name:        name, | 			Name:        name, | ||||||
| 			Namespace:   c.Metadata.Namespace, | 			Namespace:   c.Namespace, | ||||||
| 			Labels:      c.roleLabelsSet(role), | 			Labels:      c.roleLabelsSet(role), | ||||||
| 			Annotations: annotations, | 			Annotations: annotations, | ||||||
| 		}, | 		}, | ||||||
|  | @ -483,9 +483,9 @@ func (c *Cluster) generateService(role PostgresRole, newSpec *spec.PostgresSpec) | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) generateMasterEndpoints(subsets []v1.EndpointSubset) *v1.Endpoints { | func (c *Cluster) generateMasterEndpoints(subsets []v1.EndpointSubset) *v1.Endpoints { | ||||||
| 	endpoints := &v1.Endpoints{ | 	endpoints := &v1.Endpoints{ | ||||||
| 		ObjectMeta: meta_v1.ObjectMeta{ | 		ObjectMeta: metav1.ObjectMeta{ | ||||||
| 			Name:      c.Metadata.Name, | 			Name:      c.Name, | ||||||
| 			Namespace: c.Metadata.Namespace, | 			Namespace: c.Namespace, | ||||||
| 			Labels:    c.roleLabelsSet(Master), | 			Labels:    c.roleLabelsSet(Master), | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ var getUserSQL = `SELECT a.rolname, COALESCE(a.rolpassword, ''), a.rolsuper, a.r | ||||||
| 	 ORDER BY 1;` | 	 ORDER BY 1;` | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) pgConnectionString() string { | func (c *Cluster) pgConnectionString() string { | ||||||
| 	hostname := fmt.Sprintf("%s.%s.svc.cluster.local", c.Metadata.Name, c.Metadata.Namespace) | 	hostname := fmt.Sprintf("%s.%s.svc.cluster.local", c.Name, c.Namespace) | ||||||
| 	username := c.systemUsers[constants.SuperuserKeyName].Name | 	username := c.systemUsers[constants.SuperuserKeyName].Name | ||||||
| 	password := c.systemUsers[constants.SuperuserKeyName].Password | 	password := c.systemUsers[constants.SuperuserKeyName].Password | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ package cluster | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 
 | 
 | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| 
 | 
 | ||||||
| 	"github.com/zalando-incubator/postgres-operator/pkg/spec" | 	"github.com/zalando-incubator/postgres-operator/pkg/spec" | ||||||
|  | @ -12,8 +12,8 @@ import ( | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) listPods() ([]v1.Pod, error) { | func (c *Cluster) listPods() ([]v1.Pod, error) { | ||||||
| 	ns := c.Metadata.Namespace | 	ns := c.Namespace | ||||||
| 	listOptions := meta_v1.ListOptions{ | 	listOptions := metav1.ListOptions{ | ||||||
| 		LabelSelector: c.labelsSet().String(), | 		LabelSelector: c.labelsSet().String(), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -114,9 +114,9 @@ func (c *Cluster) recreatePod(pod v1.Pod) error { | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) recreatePods() error { | func (c *Cluster) recreatePods() error { | ||||||
| 	ls := c.labelsSet() | 	ls := c.labelsSet() | ||||||
| 	namespace := c.Metadata.Namespace | 	namespace := c.Namespace | ||||||
| 
 | 
 | ||||||
| 	listOptions := meta_v1.ListOptions{ | 	listOptions := metav1.ListOptions{ | ||||||
| 		LabelSelector: ls.String(), | 		LabelSelector: ls.String(), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ package cluster | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 
 | 
 | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/types" | 	"k8s.io/apimachinery/pkg/types" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | ||||||
|  | @ -16,8 +16,8 @@ import ( | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) loadResources() error { | func (c *Cluster) loadResources() error { | ||||||
| 	ns := c.Metadata.Namespace | 	ns := c.Namespace | ||||||
| 	listOptions := meta_v1.ListOptions{ | 	listOptions := metav1.ListOptions{ | ||||||
| 		LabelSelector: c.labelsSet().String(), | 		LabelSelector: c.labelsSet().String(), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -172,7 +172,7 @@ func (c *Cluster) replaceStatefulSet(newStatefulSet *v1beta1.StatefulSet) error | ||||||
| 	orphanDepencies := true | 	orphanDepencies := true | ||||||
| 	oldStatefulset := c.Statefulset | 	oldStatefulset := c.Statefulset | ||||||
| 
 | 
 | ||||||
| 	options := meta_v1.DeleteOptions{OrphanDependents: &orphanDepencies} | 	options := metav1.DeleteOptions{OrphanDependents: &orphanDepencies} | ||||||
| 	if err := c.KubeClient.StatefulSets(oldStatefulset.Namespace).Delete(oldStatefulset.Name, &options); err != nil { | 	if err := c.KubeClient.StatefulSets(oldStatefulset.Namespace).Delete(oldStatefulset.Name, &options); err != nil { | ||||||
| 		return fmt.Errorf("could not delete statefulset %q: %v", statefulSetName, err) | 		return fmt.Errorf("could not delete statefulset %q: %v", statefulSetName, err) | ||||||
| 	} | 	} | ||||||
|  | @ -183,7 +183,7 @@ func (c *Cluster) replaceStatefulSet(newStatefulSet *v1beta1.StatefulSet) error | ||||||
| 
 | 
 | ||||||
| 	err := retryutil.Retry(constants.StatefulsetDeletionInterval, constants.StatefulsetDeletionTimeout, | 	err := retryutil.Retry(constants.StatefulsetDeletionInterval, constants.StatefulsetDeletionTimeout, | ||||||
| 		func() (bool, error) { | 		func() (bool, error) { | ||||||
| 			_, err := c.KubeClient.StatefulSets(oldStatefulset.Namespace).Get(oldStatefulset.Name, meta_v1.GetOptions{}) | 			_, err := c.KubeClient.StatefulSets(oldStatefulset.Namespace).Get(oldStatefulset.Name, metav1.GetOptions{}) | ||||||
| 
 | 
 | ||||||
| 			return err != nil, nil | 			return err != nil, nil | ||||||
| 		}) | 		}) | ||||||
|  | @ -263,7 +263,7 @@ func (c *Cluster) updateService(role PostgresRole, newService *v1.Service) error | ||||||
| 		if role == Master { | 		if role == Master { | ||||||
| 			// for the master service we need to re-create the endpoint as well. Get the up-to-date version of
 | 			// for the master service we need to re-create the endpoint as well. Get the up-to-date version of
 | ||||||
| 			// the addresses stored in it before the service is deleted (deletion of the service removes the endpooint)
 | 			// the addresses stored in it before the service is deleted (deletion of the service removes the endpooint)
 | ||||||
| 			currentEndpoint, err = c.KubeClient.Endpoints(c.Service[role].Namespace).Get(c.Service[role].Name, meta_v1.GetOptions{}) | 			currentEndpoint, err = c.KubeClient.Endpoints(c.Service[role].Namespace).Get(c.Service[role].Name, metav1.GetOptions{}) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return fmt.Errorf("could not get current cluster endpoints: %v", err) | 				return fmt.Errorf("could not get current cluster endpoints: %v", err) | ||||||
| 			} | 			} | ||||||
|  | @ -372,7 +372,7 @@ func (c *Cluster) applySecrets() error { | ||||||
| 		secret, err := c.KubeClient.Secrets(secretSpec.Namespace).Create(secretSpec) | 		secret, err := c.KubeClient.Secrets(secretSpec.Namespace).Create(secretSpec) | ||||||
| 		if k8sutil.ResourceAlreadyExists(err) { | 		if k8sutil.ResourceAlreadyExists(err) { | ||||||
| 			var userMap map[string]spec.PgUser | 			var userMap map[string]spec.PgUser | ||||||
| 			curSecret, err := c.KubeClient.Secrets(secretSpec.Namespace).Get(secretSpec.Name, meta_v1.GetOptions{}) | 			curSecret, err := c.KubeClient.Secrets(secretSpec.Namespace).Get(secretSpec.Name, metav1.GetOptions{}) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return fmt.Errorf("could not get current secret: %v", err) | 				return fmt.Errorf("could not get current secret: %v", err) | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ import ( | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/labels" | 	"k8s.io/apimachinery/pkg/labels" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | ||||||
|  | @ -124,7 +124,7 @@ func (c *Cluster) getOAuthToken() (string, error) { | ||||||
| 	// Temporary getting postgresql-operator secret from the NamespaceDefault
 | 	// Temporary getting postgresql-operator secret from the NamespaceDefault
 | ||||||
| 	credentialsSecret, err := c.KubeClient. | 	credentialsSecret, err := c.KubeClient. | ||||||
| 		Secrets(c.OpConfig.OAuthTokenSecretName.Namespace). | 		Secrets(c.OpConfig.OAuthTokenSecretName.Namespace). | ||||||
| 		Get(c.OpConfig.OAuthTokenSecretName.Name, meta_v1.GetOptions{}) | 		Get(c.OpConfig.OAuthTokenSecretName.Name, metav1.GetOptions{}) | ||||||
| 
 | 
 | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		c.logger.Debugf("Oauth token secret name: %q", c.OpConfig.OAuthTokenSecretName) | 		c.logger.Debugf("Oauth token secret name: %q", c.OpConfig.OAuthTokenSecretName) | ||||||
|  | @ -194,10 +194,10 @@ func (c *Cluster) waitForPodDeletion(podEvents chan spec.PodEvent) error { | ||||||
| func (c *Cluster) waitStatefulsetReady() error { | func (c *Cluster) waitStatefulsetReady() error { | ||||||
| 	return retryutil.Retry(c.OpConfig.ResourceCheckInterval, c.OpConfig.ResourceCheckTimeout, | 	return retryutil.Retry(c.OpConfig.ResourceCheckInterval, c.OpConfig.ResourceCheckTimeout, | ||||||
| 		func() (bool, error) { | 		func() (bool, error) { | ||||||
| 			listOptions := meta_v1.ListOptions{ | 			listOptions := metav1.ListOptions{ | ||||||
| 				LabelSelector: c.labelsSet().String(), | 				LabelSelector: c.labelsSet().String(), | ||||||
| 			} | 			} | ||||||
| 			ss, err := c.KubeClient.StatefulSets(c.Metadata.Namespace).List(listOptions) | 			ss, err := c.KubeClient.StatefulSets(c.Namespace).List(listOptions) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return false, err | 				return false, err | ||||||
| 			} | 			} | ||||||
|  | @ -212,17 +212,17 @@ func (c *Cluster) waitStatefulsetReady() error { | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) waitPodLabelsReady() error { | func (c *Cluster) waitPodLabelsReady() error { | ||||||
| 	ls := c.labelsSet() | 	ls := c.labelsSet() | ||||||
| 	namespace := c.Metadata.Namespace | 	namespace := c.Namespace | ||||||
| 
 | 
 | ||||||
| 	listOptions := meta_v1.ListOptions{ | 	listOptions := metav1.ListOptions{ | ||||||
| 		LabelSelector: ls.String(), | 		LabelSelector: ls.String(), | ||||||
| 	} | 	} | ||||||
| 	masterListOption := meta_v1.ListOptions{ | 	masterListOption := metav1.ListOptions{ | ||||||
| 		LabelSelector: labels.Merge(ls, labels.Set{ | 		LabelSelector: labels.Merge(ls, labels.Set{ | ||||||
| 			c.OpConfig.PodRoleLabel: constants.PodRoleMaster, | 			c.OpConfig.PodRoleLabel: constants.PodRoleMaster, | ||||||
| 		}).String(), | 		}).String(), | ||||||
| 	} | 	} | ||||||
| 	replicaListOption := meta_v1.ListOptions{ | 	replicaListOption := metav1.ListOptions{ | ||||||
| 		LabelSelector: labels.Merge(ls, labels.Set{ | 		LabelSelector: labels.Merge(ls, labels.Set{ | ||||||
| 			c.OpConfig.PodRoleLabel: constants.PodRoleReplica, | 			c.OpConfig.PodRoleLabel: constants.PodRoleReplica, | ||||||
| 		}).String(), | 		}).String(), | ||||||
|  | @ -278,7 +278,7 @@ func (c *Cluster) labelsSet() labels.Set { | ||||||
| 	for k, v := range c.OpConfig.ClusterLabels { | 	for k, v := range c.OpConfig.ClusterLabels { | ||||||
| 		lbls[k] = v | 		lbls[k] = v | ||||||
| 	} | 	} | ||||||
| 	lbls[c.OpConfig.ClusterNameLabel] = c.Metadata.Name | 	lbls[c.OpConfig.ClusterNameLabel] = c.Name | ||||||
| 
 | 
 | ||||||
| 	return labels.Set(lbls) | 	return labels.Set(lbls) | ||||||
| } | } | ||||||
|  | @ -308,7 +308,7 @@ func (c *Cluster) credentialSecretName(username string) string { | ||||||
| 	// and must start and end with an alphanumeric character
 | 	// and must start and end with an alphanumeric character
 | ||||||
| 	return fmt.Sprintf(constants.UserSecretTemplate, | 	return fmt.Sprintf(constants.UserSecretTemplate, | ||||||
| 		strings.Replace(username, "_", "-", -1), | 		strings.Replace(username, "_", "-", -1), | ||||||
| 		c.Metadata.Name) | 		c.Name) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) podSpiloRole(pod *v1.Pod) string { | func (c *Cluster) podSpiloRole(pod *v1.Pod) string { | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ import ( | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
| 	"k8s.io/apimachinery/pkg/api/resource" | 	"k8s.io/apimachinery/pkg/api/resource" | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| 
 | 
 | ||||||
| 	"github.com/zalando-incubator/postgres-operator/pkg/spec" | 	"github.com/zalando-incubator/postgres-operator/pkg/spec" | ||||||
|  | @ -17,8 +17,8 @@ import ( | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) listPersistentVolumeClaims() ([]v1.PersistentVolumeClaim, error) { | func (c *Cluster) listPersistentVolumeClaims() ([]v1.PersistentVolumeClaim, error) { | ||||||
| 	ns := c.Metadata.Namespace | 	ns := c.Namespace | ||||||
| 	listOptions := meta_v1.ListOptions{ | 	listOptions := metav1.ListOptions{ | ||||||
| 		LabelSelector: c.labelsSet().String(), | 		LabelSelector: c.labelsSet().String(), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -70,7 +70,7 @@ func (c *Cluster) listPersistentVolumes() ([]*v1.PersistentVolume, error) { | ||||||
| 				continue | 				continue | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		pv, err := c.KubeClient.PersistentVolumes().Get(pvc.Spec.VolumeName, meta_v1.GetOptions{}) | 		pv, err := c.KubeClient.PersistentVolumes().Get(pvc.Spec.VolumeName, metav1.GetOptions{}) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, fmt.Errorf("could not get PersistentVolume: %v", err) | 			return nil, fmt.Errorf("could not get PersistentVolume: %v", err) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ import ( | ||||||
| 	"sync" | 	"sync" | ||||||
| 
 | 
 | ||||||
| 	"github.com/Sirupsen/logrus" | 	"github.com/Sirupsen/logrus" | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| 	"k8s.io/client-go/rest" | 	"k8s.io/client-go/rest" | ||||||
| 	"k8s.io/client-go/tools/cache" | 	"k8s.io/client-go/tools/cache" | ||||||
|  | @ -33,7 +33,7 @@ type Controller struct { | ||||||
| 
 | 
 | ||||||
| 	logger     *logrus.Entry | 	logger     *logrus.Entry | ||||||
| 	KubeClient k8sutil.KubernetesClient | 	KubeClient k8sutil.KubernetesClient | ||||||
| 	RestClient rest.Interface | 	RestClient rest.Interface // kubernetes API group REST client
 | ||||||
| 
 | 
 | ||||||
| 	clustersMu sync.RWMutex | 	clustersMu sync.RWMutex | ||||||
| 	clusters   map[spec.NamespacedName]*cluster.Cluster | 	clusters   map[spec.NamespacedName]*cluster.Cluster | ||||||
|  | @ -78,7 +78,7 @@ func (c *Controller) initOperatorConfig() { | ||||||
| 
 | 
 | ||||||
| 	if c.config.ConfigMapName != (spec.NamespacedName{}) { | 	if c.config.ConfigMapName != (spec.NamespacedName{}) { | ||||||
| 		configMap, err := c.KubeClient.ConfigMaps(c.config.ConfigMapName.Namespace). | 		configMap, err := c.KubeClient.ConfigMaps(c.config.ConfigMapName.Namespace). | ||||||
| 			Get(c.config.ConfigMapName.Name, meta_v1.GetOptions{}) | 			Get(c.config.ConfigMapName.Name, metav1.GetOptions{}) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			panic(err) | 			panic(err) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -1,9 +1,7 @@ | ||||||
| package controller | package controller | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"sync" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 
 |  | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" |  | ||||||
| 	"k8s.io/apimachinery/pkg/runtime" | 	"k8s.io/apimachinery/pkg/runtime" | ||||||
| 	"k8s.io/apimachinery/pkg/watch" | 	"k8s.io/apimachinery/pkg/watch" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
|  | @ -12,11 +10,11 @@ import ( | ||||||
| 	"github.com/zalando-incubator/postgres-operator/pkg/util" | 	"github.com/zalando-incubator/postgres-operator/pkg/util" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (c *Controller) podListFunc(options meta_v1.ListOptions) (runtime.Object, error) { | func (c *Controller) podListFunc(options metav1.ListOptions) (runtime.Object, error) { | ||||||
| 	var labelSelector string | 	var labelSelector string | ||||||
| 	var fieldSelector string | 	var fieldSelector string | ||||||
| 
 | 
 | ||||||
| 	opts := meta_v1.ListOptions{ | 	opts := metav1.ListOptions{ | ||||||
| 		LabelSelector:   labelSelector, | 		LabelSelector:   labelSelector, | ||||||
| 		FieldSelector:   fieldSelector, | 		FieldSelector:   fieldSelector, | ||||||
| 		Watch:           options.Watch, | 		Watch:           options.Watch, | ||||||
|  | @ -27,11 +25,11 @@ func (c *Controller) podListFunc(options meta_v1.ListOptions) (runtime.Object, e | ||||||
| 	return c.KubeClient.Pods(c.opConfig.Namespace).List(opts) | 	return c.KubeClient.Pods(c.opConfig.Namespace).List(opts) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (c *Controller) podWatchFunc(options meta_v1.ListOptions) (watch.Interface, error) { | func (c *Controller) podWatchFunc(options metav1.ListOptions) (watch.Interface, error) { | ||||||
| 	var labelSelector string | 	var labelSelector string | ||||||
| 	var fieldSelector string | 	var fieldSelector string | ||||||
| 
 | 
 | ||||||
| 	opts := meta_v1.ListOptions{ | 	opts := metav1.ListOptions{ | ||||||
| 		LabelSelector:   labelSelector, | 		LabelSelector:   labelSelector, | ||||||
| 		FieldSelector:   fieldSelector, | 		FieldSelector:   fieldSelector, | ||||||
| 		Watch:           options.Watch, | 		Watch:           options.Watch, | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ import ( | ||||||
| 	"sync/atomic" | 	"sync/atomic" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/runtime" | 	"k8s.io/apimachinery/pkg/runtime" | ||||||
| 	"k8s.io/apimachinery/pkg/types" | 	"k8s.io/apimachinery/pkg/types" | ||||||
| 	"k8s.io/apimachinery/pkg/watch" | 	"k8s.io/apimachinery/pkg/watch" | ||||||
|  | @ -27,14 +27,14 @@ func (c *Controller) clusterResync(stopCh <-chan struct{}, wg *sync.WaitGroup) { | ||||||
| 	for { | 	for { | ||||||
| 		select { | 		select { | ||||||
| 		case <-ticker.C: | 		case <-ticker.C: | ||||||
| 			c.clusterListFunc(meta_v1.ListOptions{ResourceVersion: "0"}) | 			c.clusterListFunc(metav1.ListOptions{ResourceVersion: "0"}) | ||||||
| 		case <-stopCh: | 		case <-stopCh: | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (c *Controller) clusterListFunc(options meta_v1.ListOptions) (runtime.Object, error) { | func (c *Controller) clusterListFunc(options metav1.ListOptions) (runtime.Object, error) { | ||||||
| 	var list spec.PostgresqlList | 	var list spec.PostgresqlList | ||||||
| 	var activeClustersCnt, failedClustersCnt int | 	var activeClustersCnt, failedClustersCnt int | ||||||
| 
 | 
 | ||||||
|  | @ -42,7 +42,7 @@ func (c *Controller) clusterListFunc(options meta_v1.ListOptions) (runtime.Objec | ||||||
| 		Get(). | 		Get(). | ||||||
| 		Namespace(c.opConfig.Namespace). | 		Namespace(c.opConfig.Namespace). | ||||||
| 		Resource(constants.ResourceName). | 		Resource(constants.ResourceName). | ||||||
| 		VersionedParams(&options, meta_v1.ParameterCodec) | 		VersionedParams(&options, metav1.ParameterCodec) | ||||||
| 
 | 
 | ||||||
| 	b, err := req.DoRaw() | 	b, err := req.DoRaw() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  | @ -101,13 +101,13 @@ func (d *tprDecoder) Decode() (action watch.EventType, object runtime.Object, er | ||||||
| 	return e.Type, &e.Object, nil | 	return e.Type, &e.Object, nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (c *Controller) clusterWatchFunc(options meta_v1.ListOptions) (watch.Interface, error) { | func (c *Controller) clusterWatchFunc(options metav1.ListOptions) (watch.Interface, error) { | ||||||
| 	options.Watch = true | 	options.Watch = true | ||||||
| 	r, err := c.RestClient. | 	r, err := c.RestClient. | ||||||
| 		Get(). | 		Get(). | ||||||
| 		Namespace(c.opConfig.Namespace). | 		Namespace(c.opConfig.Namespace). | ||||||
| 		Resource(constants.ResourceName). | 		Resource(constants.ResourceName). | ||||||
| 		VersionedParams(&options, meta_v1.ParameterCodec). | 		VersionedParams(&options, metav1.ParameterCodec). | ||||||
| 		FieldsSelectorParam(nil). | 		FieldsSelectorParam(nil). | ||||||
| 		Stream() | 		Stream() | ||||||
| 
 | 
 | ||||||
|  | @ -131,9 +131,9 @@ func (c *Controller) processEvent(obj interface{}) error { | ||||||
| 	logger := c.logger.WithField("worker", event.WorkerID) | 	logger := c.logger.WithField("worker", event.WorkerID) | ||||||
| 
 | 
 | ||||||
| 	if event.EventType == spec.EventAdd || event.EventType == spec.EventSync { | 	if event.EventType == spec.EventAdd || event.EventType == spec.EventSync { | ||||||
| 		clusterName = util.NameFromMeta(event.NewSpec.Metadata) | 		clusterName = util.NameFromMeta(event.NewSpec.ObjectMeta) | ||||||
| 	} else { | 	} else { | ||||||
| 		clusterName = util.NameFromMeta(event.OldSpec.Metadata) | 		clusterName = util.NameFromMeta(event.OldSpec.ObjectMeta) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	c.clustersMu.RLock() | 	c.clustersMu.RLock() | ||||||
|  | @ -248,8 +248,8 @@ func (c *Controller) queueClusterEvent(old, new *spec.Postgresql, eventType spec | ||||||
| 	) | 	) | ||||||
| 
 | 
 | ||||||
| 	if old != nil { //update, delete
 | 	if old != nil { //update, delete
 | ||||||
| 		uid = old.Metadata.GetUID() | 		uid = old.GetUID() | ||||||
| 		clusterName = util.NameFromMeta(old.Metadata) | 		clusterName = util.NameFromMeta(old.ObjectMeta) | ||||||
| 		if eventType == spec.EventUpdate && new.Error == nil && old.Error != nil { | 		if eventType == spec.EventUpdate && new.Error == nil && old.Error != nil { | ||||||
| 			eventType = spec.EventSync | 			eventType = spec.EventSync | ||||||
| 			clusterError = new.Error | 			clusterError = new.Error | ||||||
|  | @ -257,8 +257,8 @@ func (c *Controller) queueClusterEvent(old, new *spec.Postgresql, eventType spec | ||||||
| 			clusterError = old.Error | 			clusterError = old.Error | ||||||
| 		} | 		} | ||||||
| 	} else { //add, sync
 | 	} else { //add, sync
 | ||||||
| 		uid = new.Metadata.GetUID() | 		uid = new.GetUID() | ||||||
| 		clusterName = util.NameFromMeta(new.Metadata) | 		clusterName = util.NameFromMeta(new.ObjectMeta) | ||||||
| 		clusterError = new.Error | 		clusterError = new.Error | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -303,7 +303,7 @@ func (c *Controller) postgresqlUpdate(prev, cur interface{}) { | ||||||
| 	if !ok { | 	if !ok { | ||||||
| 		c.logger.Errorf("could not cast to postgresql spec") | 		c.logger.Errorf("could not cast to postgresql spec") | ||||||
| 	} | 	} | ||||||
| 	if pgOld.Metadata.ResourceVersion == pgNew.Metadata.ResourceVersion { | 	if pgOld.ResourceVersion == pgNew.ResourceVersion { | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	if reflect.DeepEqual(pgOld.Spec, pgNew.Spec) { | 	if reflect.DeepEqual(pgOld.Spec, pgNew.Spec) { | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"hash/crc32" | 	"hash/crc32" | ||||||
| 
 | 
 | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| 	extv1beta "k8s.io/client-go/pkg/apis/extensions/v1beta1" | 	extv1beta "k8s.io/client-go/pkg/apis/extensions/v1beta1" | ||||||
| 
 | 
 | ||||||
|  | @ -30,7 +30,7 @@ func (c *Controller) makeClusterConfig() cluster.Config { | ||||||
| 
 | 
 | ||||||
| func thirdPartyResource(TPRName string) *extv1beta.ThirdPartyResource { | func thirdPartyResource(TPRName string) *extv1beta.ThirdPartyResource { | ||||||
| 	return &extv1beta.ThirdPartyResource{ | 	return &extv1beta.ThirdPartyResource{ | ||||||
| 		ObjectMeta: meta_v1.ObjectMeta{ | 		ObjectMeta: metav1.ObjectMeta{ | ||||||
| 			//ThirdPartyResources are cluster-wide
 | 			//ThirdPartyResources are cluster-wide
 | ||||||
| 			Name: TPRName, | 			Name: TPRName, | ||||||
| 		}, | 		}, | ||||||
|  | @ -69,7 +69,7 @@ func (c *Controller) getInfrastructureRoles(rolesSecret *spec.NamespacedName) (r | ||||||
| 
 | 
 | ||||||
| 	infraRolesSecret, err := c.KubeClient. | 	infraRolesSecret, err := c.KubeClient. | ||||||
| 		Secrets(rolesSecret.Namespace). | 		Secrets(rolesSecret.Namespace). | ||||||
| 		Get(rolesSecret.Name, meta_v1.GetOptions{}) | 		Get(rolesSecret.Name, metav1.GetOptions{}) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		c.logger.Debugf("Infrastructure roles secret name: %q", *rolesSecret) | 		c.logger.Debugf("Infrastructure roles secret name: %q", *rolesSecret) | ||||||
| 		return nil, fmt.Errorf("could not get infrastructure roles secret: %v", err) | 		return nil, fmt.Errorf("could not get infrastructure roles secret: %v", err) | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ import ( | ||||||
| 	"reflect" | 	"reflect" | ||||||
| 	"testing" | 	"testing" | ||||||
| 
 | 
 | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	v1core "k8s.io/client-go/kubernetes/typed/core/v1" | 	v1core "k8s.io/client-go/kubernetes/typed/core/v1" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| 
 | 
 | ||||||
|  | @ -21,7 +21,7 @@ type mockSecret struct { | ||||||
| 	v1core.SecretInterface | 	v1core.SecretInterface | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (c *mockSecret) Get(name string, options meta_v1.GetOptions) (*v1.Secret, error) { | func (c *mockSecret) Get(name string, options metav1.GetOptions) (*v1.Secret, error) { | ||||||
| 	if name != testInfrastructureRolesSecretName { | 	if name != testInfrastructureRolesSecretName { | ||||||
| 		return nil, fmt.Errorf("NotFound") | 		return nil, fmt.Errorf("NotFound") | ||||||
| 	} | 	} | ||||||
|  | @ -70,7 +70,7 @@ func TestPodClusterName(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			&v1.Pod{ | 			&v1.Pod{ | ||||||
| 				ObjectMeta: meta_v1.ObjectMeta{ | 				ObjectMeta: metav1.ObjectMeta{ | ||||||
| 					Namespace: v1.NamespaceDefault, | 					Namespace: v1.NamespaceDefault, | ||||||
| 					Labels: map[string]string{ | 					Labels: map[string]string{ | ||||||
| 						mockController.opConfig.ClusterNameLabel: "testcluster", | 						mockController.opConfig.ClusterNameLabel: "testcluster", | ||||||
|  |  | ||||||
|  | @ -6,8 +6,7 @@ import ( | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // MaintenanceWindow describes the time window when the operator is allowed to do maintenance on a cluster.
 | // MaintenanceWindow describes the time window when the operator is allowed to do maintenance on a cluster.
 | ||||||
|  | @ -70,8 +69,8 @@ const ( | ||||||
| 
 | 
 | ||||||
| // Postgresql defines PostgreSQL Third Party (resource) Object.
 | // Postgresql defines PostgreSQL Third Party (resource) Object.
 | ||||||
| type Postgresql struct { | type Postgresql struct { | ||||||
| 	meta_v1.TypeMeta `json:",inline"` | 	metav1.TypeMeta   `json:",inline"` | ||||||
| 	Metadata         meta_v1.ObjectMeta `json:"metadata"` | 	metav1.ObjectMeta `json:"metadata"` | ||||||
| 
 | 
 | ||||||
| 	Spec   PostgresSpec   `json:"spec"` | 	Spec   PostgresSpec   `json:"spec"` | ||||||
| 	Status PostgresStatus `json:"status,omitempty"` | 	Status PostgresStatus `json:"status,omitempty"` | ||||||
|  | @ -98,8 +97,8 @@ type PostgresSpec struct { | ||||||
| 
 | 
 | ||||||
| // PostgresqlList defines a list of PostgreSQL clusters.
 | // PostgresqlList defines a list of PostgreSQL clusters.
 | ||||||
| type PostgresqlList struct { | type PostgresqlList struct { | ||||||
| 	meta_v1.TypeMeta `json:",inline"` | 	metav1.TypeMeta `json:",inline"` | ||||||
| 	Metadata         meta_v1.ListMeta `json:"metadata"` | 	metav1.ListMeta `json:"metadata"` | ||||||
| 
 | 
 | ||||||
| 	Items []Postgresql `json:"items"` | 	Items []Postgresql `json:"items"` | ||||||
| } | } | ||||||
|  | @ -190,25 +189,6 @@ func (m *MaintenanceWindow) UnmarshalJSON(data []byte) error { | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // GetObject implements Object interface for PostgreSQL TPR spec object.
 |  | ||||||
| func (p *Postgresql) GetObjectKind() schema.ObjectKind { |  | ||||||
| 	return &p.TypeMeta |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // GetObjectMeta implements ObjectMetaAccessor interface for PostgreSQL TPR spec object.
 |  | ||||||
| func (p *Postgresql) GetObjectMeta() meta_v1.Object { |  | ||||||
| 	return &p.Metadata |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (pl *PostgresqlList) GetObjectKind() schema.ObjectKind { |  | ||||||
| 	return &pl.TypeMeta |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // GetListMeta implements ListMetaAccessor interface for PostgreSQL TPR List spec object.
 |  | ||||||
| func (pl *PostgresqlList) GetListMeta() meta_v1.List { |  | ||||||
| 	return &pl.Metadata |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func extractClusterName(clusterName string, teamName string) (string, error) { | func extractClusterName(clusterName string, teamName string) (string, error) { | ||||||
| 	teamNameLen := len(teamName) | 	teamNameLen := len(teamName) | ||||||
| 	if len(clusterName) < teamNameLen+2 { | 	if len(clusterName) < teamNameLen+2 { | ||||||
|  | @ -226,10 +206,6 @@ func extractClusterName(clusterName string, teamName string) (string, error) { | ||||||
| 	return clusterName[teamNameLen+1:], nil | 	return clusterName[teamNameLen+1:], nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // The code below is used only to work around a known problem with third-party
 |  | ||||||
| // resources and ugorji. If/when these issues are resolved, the code below
 |  | ||||||
| // should no longer be required.
 |  | ||||||
| //
 |  | ||||||
| type postgresqlListCopy PostgresqlList | type postgresqlListCopy PostgresqlList | ||||||
| type postgresqlCopy Postgresql | type postgresqlCopy Postgresql | ||||||
| 
 | 
 | ||||||
|  | @ -239,7 +215,7 @@ func (p *Postgresql) UnmarshalJSON(data []byte) error { | ||||||
| 
 | 
 | ||||||
| 	err := json.Unmarshal(data, &tmp) | 	err := json.Unmarshal(data, &tmp) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		metaErr := json.Unmarshal(data, &tmp.Metadata) | 		metaErr := json.Unmarshal(data, &tmp.ObjectMeta) | ||||||
| 		if metaErr != nil { | 		if metaErr != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|  | @ -253,7 +229,7 @@ func (p *Postgresql) UnmarshalJSON(data []byte) error { | ||||||
| 	} | 	} | ||||||
| 	tmp2 := Postgresql(tmp) | 	tmp2 := Postgresql(tmp) | ||||||
| 
 | 
 | ||||||
| 	clusterName, err := extractClusterName(tmp2.Metadata.Name, tmp2.Spec.TeamID) | 	clusterName, err := extractClusterName(tmp2.ObjectMeta.Name, tmp2.Spec.TeamID) | ||||||
| 	if err == nil { | 	if err == nil { | ||||||
| 		tmp2.Spec.ClusterName = clusterName | 		tmp2.Spec.ClusterName = clusterName | ||||||
| 	} else { | 	} else { | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ import ( | ||||||
| 	"testing" | 	"testing" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| var parseTimeTests = []struct { | var parseTimeTests = []struct { | ||||||
|  | @ -103,11 +103,11 @@ var unmarshalCluster = []struct { | ||||||
|   "kind": "Postgresql","apiVersion": "acid.zalan.do/v1", |   "kind": "Postgresql","apiVersion": "acid.zalan.do/v1", | ||||||
|   "metadata": {"name": "acid-testcluster1"}, "spec": {"teamId": 100}}`), |   "metadata": {"name": "acid-testcluster1"}, "spec": {"teamId": 100}}`), | ||||||
| 	Postgresql{ | 	Postgresql{ | ||||||
| 		TypeMeta: meta_v1.TypeMeta{ | 		TypeMeta: metav1.TypeMeta{ | ||||||
| 			Kind:       "Postgresql", | 			Kind:       "Postgresql", | ||||||
| 			APIVersion: "acid.zalan.do/v1", | 			APIVersion: "acid.zalan.do/v1", | ||||||
| 		}, | 		}, | ||||||
| 		Metadata: meta_v1.ObjectMeta{ | 		ObjectMeta: metav1.ObjectMeta{ | ||||||
| 			Name: "acid-testcluster1", | 			Name: "acid-testcluster1", | ||||||
| 		}, | 		}, | ||||||
| 		Status: ClusterStatusInvalid, | 		Status: ClusterStatusInvalid, | ||||||
|  | @ -183,11 +183,11 @@ var unmarshalCluster = []struct { | ||||||
|   } |   } | ||||||
| }`), | }`), | ||||||
| 		Postgresql{ | 		Postgresql{ | ||||||
| 			TypeMeta: meta_v1.TypeMeta{ | 			TypeMeta: metav1.TypeMeta{ | ||||||
| 				Kind:       "Postgresql", | 				Kind:       "Postgresql", | ||||||
| 				APIVersion: "acid.zalan.do/v1", | 				APIVersion: "acid.zalan.do/v1", | ||||||
| 			}, | 			}, | ||||||
| 			Metadata: meta_v1.ObjectMeta{ | 			ObjectMeta: metav1.ObjectMeta{ | ||||||
| 				Name: "acid-testcluster1", | 				Name: "acid-testcluster1", | ||||||
| 			}, | 			}, | ||||||
| 			Spec: PostgresSpec{ | 			Spec: PostgresSpec{ | ||||||
|  | @ -249,11 +249,11 @@ var unmarshalCluster = []struct { | ||||||
| 	{ | 	{ | ||||||
| 		[]byte(`{"kind": "Postgresql","apiVersion": "acid.zalan.do/v1","metadata": {"name": "teapot-testcluster1"}, "spec": {"teamId": "acid"}}`), | 		[]byte(`{"kind": "Postgresql","apiVersion": "acid.zalan.do/v1","metadata": {"name": "teapot-testcluster1"}, "spec": {"teamId": "acid"}}`), | ||||||
| 		Postgresql{ | 		Postgresql{ | ||||||
| 			TypeMeta: meta_v1.TypeMeta{ | 			TypeMeta: metav1.TypeMeta{ | ||||||
| 				Kind:       "Postgresql", | 				Kind:       "Postgresql", | ||||||
| 				APIVersion: "acid.zalan.do/v1", | 				APIVersion: "acid.zalan.do/v1", | ||||||
| 			}, | 			}, | ||||||
| 			Metadata: meta_v1.ObjectMeta{ | 			ObjectMeta: metav1.ObjectMeta{ | ||||||
| 				Name: "teapot-testcluster1", | 				Name: "teapot-testcluster1", | ||||||
| 			}, | 			}, | ||||||
| 			Spec:   PostgresSpec{TeamID: "acid"}, | 			Spec:   PostgresSpec{TeamID: "acid"}, | ||||||
|  | @ -277,16 +277,16 @@ var postgresqlList = []struct { | ||||||
| }{ | }{ | ||||||
| 	{[]byte(`{"apiVersion":"v1","items":[{"apiVersion":"acid.zalan.do/v1","kind":"Postgresql","metadata":{"labels":{"team":"acid"},"name":"acid-testcluster42","namespace":"default","resourceVersion":"30446957","selfLink":"/apis/acid.zalan.do/v1/namespaces/default/postgresqls/acid-testcluster42","uid":"857cd208-33dc-11e7-b20a-0699041e4b03"},"spec":{"allowedSourceRanges":["185.85.220.0/22"],"numberOfInstances":1,"postgresql":{"version":"9.6"},"teamId":"acid","volume":{"size":"10Gi"}},"status":"Running"}],"kind":"List","metadata":{},"resourceVersion":"","selfLink":""}`), | 	{[]byte(`{"apiVersion":"v1","items":[{"apiVersion":"acid.zalan.do/v1","kind":"Postgresql","metadata":{"labels":{"team":"acid"},"name":"acid-testcluster42","namespace":"default","resourceVersion":"30446957","selfLink":"/apis/acid.zalan.do/v1/namespaces/default/postgresqls/acid-testcluster42","uid":"857cd208-33dc-11e7-b20a-0699041e4b03"},"spec":{"allowedSourceRanges":["185.85.220.0/22"],"numberOfInstances":1,"postgresql":{"version":"9.6"},"teamId":"acid","volume":{"size":"10Gi"}},"status":"Running"}],"kind":"List","metadata":{},"resourceVersion":"","selfLink":""}`), | ||||||
| 		PostgresqlList{ | 		PostgresqlList{ | ||||||
| 			TypeMeta: meta_v1.TypeMeta{ | 			TypeMeta: metav1.TypeMeta{ | ||||||
| 				Kind:       "List", | 				Kind:       "List", | ||||||
| 				APIVersion: "v1", | 				APIVersion: "v1", | ||||||
| 			}, | 			}, | ||||||
| 			Items: []Postgresql{{ | 			Items: []Postgresql{{ | ||||||
| 				TypeMeta: meta_v1.TypeMeta{ | 				TypeMeta: metav1.TypeMeta{ | ||||||
| 					Kind:       "Postgresql", | 					Kind:       "Postgresql", | ||||||
| 					APIVersion: "acid.zalan.do/v1", | 					APIVersion: "acid.zalan.do/v1", | ||||||
| 				}, | 				}, | ||||||
| 				Metadata: meta_v1.ObjectMeta{ | 				ObjectMeta: metav1.ObjectMeta{ | ||||||
| 					Name:            "acid-testcluster42", | 					Name:            "acid-testcluster42", | ||||||
| 					Namespace:       "default", | 					Namespace:       "default", | ||||||
| 					Labels:          map[string]string{"team": "acid"}, | 					Labels:          map[string]string{"team": "acid"}, | ||||||
|  | @ -445,8 +445,8 @@ func TestPostgresMeta(t *testing.T) { | ||||||
| 			t.Errorf("GetObjectKindMeta expected: %v, got: %v", tt.out.TypeMeta, a) | 			t.Errorf("GetObjectKindMeta expected: %v, got: %v", tt.out.TypeMeta, a) | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if a := tt.out.GetObjectMeta(); reflect.DeepEqual(a, tt.out.Metadata) { | 		if a := tt.out.GetObjectMeta(); reflect.DeepEqual(a, tt.out.ObjectMeta) { | ||||||
| 			t.Errorf("GetObjectMeta expected: %v, got: %v", tt.out.Metadata, a) | 			t.Errorf("GetObjectMeta expected: %v, got: %v", tt.out.ObjectMeta, a) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | @ -475,8 +475,8 @@ func TestPostgresListMeta(t *testing.T) { | ||||||
| 			t.Errorf("GetObjectKindMeta expected: %v, got: %v", tt.out.TypeMeta, a) | 			t.Errorf("GetObjectKindMeta expected: %v, got: %v", tt.out.TypeMeta, a) | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if a := tt.out.GetListMeta(); reflect.DeepEqual(a, tt.out.Metadata) { | 		if a := tt.out.GetListMeta(); reflect.DeepEqual(a, tt.out.ListMeta) { | ||||||
| 			t.Errorf("GetObjectMeta expected: %v, got: %v", tt.out.Metadata, a) | 			t.Errorf("GetObjectMeta expected: %v, got: %v", tt.out.ListMeta, a) | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		return | 		return | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ import ( | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/motomux/pretty" | 	"github.com/motomux/pretty" | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 
 | 
 | ||||||
| 	"github.com/zalando-incubator/postgres-operator/pkg/spec" | 	"github.com/zalando-incubator/postgres-operator/pkg/spec" | ||||||
| ) | ) | ||||||
|  | @ -34,7 +34,7 @@ func RandomPassword(n int) string { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // NameFromMeta converts a metadata object to the NamespacedName name representation.
 | // NameFromMeta converts a metadata object to the NamespacedName name representation.
 | ||||||
| func NameFromMeta(meta meta_v1.ObjectMeta) spec.NamespacedName { | func NameFromMeta(meta metav1.ObjectMeta) spec.NamespacedName { | ||||||
| 	return spec.NamespacedName{ | 	return spec.NamespacedName{ | ||||||
| 		Namespace: meta.Namespace, | 		Namespace: meta.Namespace, | ||||||
| 		Name:      meta.Name, | 		Name:      meta.Name, | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ import ( | ||||||
| 	"reflect" | 	"reflect" | ||||||
| 	"testing" | 	"testing" | ||||||
| 
 | 
 | ||||||
| 	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 
 | 
 | ||||||
| 	"github.com/zalando-incubator/postgres-operator/pkg/spec" | 	"github.com/zalando-incubator/postgres-operator/pkg/spec" | ||||||
| ) | ) | ||||||
|  | @ -53,7 +53,7 @@ func TestRandomPassword(t *testing.T) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func TestNameFromMeta(t *testing.T) { | func TestNameFromMeta(t *testing.T) { | ||||||
| 	meta := meta_v1.ObjectMeta{ | 	meta := metav1.ObjectMeta{ | ||||||
| 		Name:      "testcluster", | 		Name:      "testcluster", | ||||||
| 		Namespace: "default", | 		Namespace: "default", | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue