mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-02 18:14:04 +02:00
Merge branch 'master' into replace-spilo-application-by-owner
This commit is contained in:
@@ -1083,7 +1083,7 @@ func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
|
||||
|
||||
// Patroni service and endpoints / config maps
|
||||
if err := c.syncPatroniResources(); err != nil {
|
||||
c.logger.Errorf("could not sync services: %v", err)
|
||||
c.logger.Errorf("could not sync Patroni resources: %v", err)
|
||||
updateFailed = true
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ func TestCreate(t *testing.T) {
|
||||
|
||||
client := k8sutil.KubernetesClient{
|
||||
DeploymentsGetter: clientSet.AppsV1(),
|
||||
ConfigMapsGetter: clientSet.CoreV1(),
|
||||
CronJobsGetter: clientSet.BatchV1(),
|
||||
EndpointsGetter: clientSet.CoreV1(),
|
||||
PersistentVolumeClaimsGetter: clientSet.CoreV1(),
|
||||
|
||||
@@ -1340,28 +1340,6 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
|
||||
}
|
||||
}
|
||||
|
||||
// backward compatible check for InitContainers
|
||||
if spec.InitContainersOld != nil {
|
||||
msg := "manifest parameter init_containers is deprecated."
|
||||
if spec.InitContainers == nil {
|
||||
c.logger.Warningf("%s Consider using initContainers instead.", msg)
|
||||
spec.InitContainers = spec.InitContainersOld
|
||||
} else {
|
||||
c.logger.Warningf("%s Only value from initContainers is used", msg)
|
||||
}
|
||||
}
|
||||
|
||||
// backward compatible check for PodPriorityClassName
|
||||
if spec.PodPriorityClassNameOld != "" {
|
||||
msg := "manifest parameter pod_priority_class_name is deprecated."
|
||||
if spec.PodPriorityClassName == "" {
|
||||
c.logger.Warningf("%s Consider using podPriorityClassName instead.", msg)
|
||||
spec.PodPriorityClassName = spec.PodPriorityClassNameOld
|
||||
} else {
|
||||
c.logger.Warningf("%s Only value from podPriorityClassName is used", msg)
|
||||
}
|
||||
}
|
||||
|
||||
spiloConfiguration, err := generateSpiloJSONConfiguration(&spec.PostgresqlParam, &spec.Patroni, &c.OpConfig, c.logger)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not generate Spilo JSON configuration: %v", err)
|
||||
|
||||
+25
-24
@@ -582,60 +582,60 @@ func TestGenerateSpiloPodEnvVars(t *testing.T) {
|
||||
}
|
||||
expectedValuesS3Bucket := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "WAL_S3_BUCKET",
|
||||
envVarValue: "global-s3-bucket",
|
||||
},
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "WAL_BUCKET_SCOPE_SUFFIX",
|
||||
envVarValue: fmt.Sprintf("/%s", dummyUUID),
|
||||
},
|
||||
{
|
||||
envIndex: 17,
|
||||
envIndex: 18,
|
||||
envVarConstant: "WAL_BUCKET_SCOPE_PREFIX",
|
||||
envVarValue: "",
|
||||
},
|
||||
}
|
||||
expectedValuesGCPCreds := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "WAL_GS_BUCKET",
|
||||
envVarValue: "global-gs-bucket",
|
||||
},
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "WAL_BUCKET_SCOPE_SUFFIX",
|
||||
envVarValue: fmt.Sprintf("/%s", dummyUUID),
|
||||
},
|
||||
{
|
||||
envIndex: 17,
|
||||
envIndex: 18,
|
||||
envVarConstant: "WAL_BUCKET_SCOPE_PREFIX",
|
||||
envVarValue: "",
|
||||
},
|
||||
{
|
||||
envIndex: 18,
|
||||
envIndex: 19,
|
||||
envVarConstant: "GOOGLE_APPLICATION_CREDENTIALS",
|
||||
envVarValue: "some-path-to-credentials",
|
||||
},
|
||||
}
|
||||
expectedS3BucketConfigMap := []ExpectedValue{
|
||||
{
|
||||
envIndex: 17,
|
||||
envIndex: 18,
|
||||
envVarConstant: "wal_s3_bucket",
|
||||
envVarValue: "global-s3-bucket-configmap",
|
||||
},
|
||||
}
|
||||
expectedCustomS3BucketSpec := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "WAL_S3_BUCKET",
|
||||
envVarValue: "custom-s3-bucket",
|
||||
},
|
||||
}
|
||||
expectedCustomVariableSecret := []ExpectedValue{
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "custom_variable",
|
||||
envVarValueRef: &v1.EnvVarSource{
|
||||
SecretKeyRef: &v1.SecretKeySelector{
|
||||
@@ -649,72 +649,72 @@ func TestGenerateSpiloPodEnvVars(t *testing.T) {
|
||||
}
|
||||
expectedCustomVariableConfigMap := []ExpectedValue{
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "custom_variable",
|
||||
envVarValue: "configmap-test",
|
||||
},
|
||||
}
|
||||
expectedCustomVariableSpec := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "CUSTOM_VARIABLE",
|
||||
envVarValue: "spec-env-test",
|
||||
},
|
||||
}
|
||||
expectedCloneEnvSpec := []ExpectedValue{
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "CLONE_WALE_S3_PREFIX",
|
||||
envVarValue: "s3://another-bucket",
|
||||
},
|
||||
{
|
||||
envIndex: 19,
|
||||
envIndex: 20,
|
||||
envVarConstant: "CLONE_WAL_BUCKET_SCOPE_PREFIX",
|
||||
envVarValue: "",
|
||||
},
|
||||
{
|
||||
envIndex: 20,
|
||||
envIndex: 21,
|
||||
envVarConstant: "CLONE_AWS_ENDPOINT",
|
||||
envVarValue: "s3.eu-central-1.amazonaws.com",
|
||||
},
|
||||
}
|
||||
expectedCloneEnvSpecEnv := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "CLONE_WAL_BUCKET_SCOPE_PREFIX",
|
||||
envVarValue: "test-cluster",
|
||||
},
|
||||
{
|
||||
envIndex: 17,
|
||||
envIndex: 18,
|
||||
envVarConstant: "CLONE_WALE_S3_PREFIX",
|
||||
envVarValue: "s3://another-bucket",
|
||||
},
|
||||
{
|
||||
envIndex: 21,
|
||||
envIndex: 22,
|
||||
envVarConstant: "CLONE_AWS_ENDPOINT",
|
||||
envVarValue: "s3.eu-central-1.amazonaws.com",
|
||||
},
|
||||
}
|
||||
expectedCloneEnvConfigMap := []ExpectedValue{
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "CLONE_WAL_S3_BUCKET",
|
||||
envVarValue: "global-s3-bucket",
|
||||
},
|
||||
{
|
||||
envIndex: 17,
|
||||
envIndex: 18,
|
||||
envVarConstant: "CLONE_WAL_BUCKET_SCOPE_SUFFIX",
|
||||
envVarValue: fmt.Sprintf("/%s", dummyUUID),
|
||||
},
|
||||
{
|
||||
envIndex: 21,
|
||||
envIndex: 22,
|
||||
envVarConstant: "clone_aws_endpoint",
|
||||
envVarValue: "s3.eu-west-1.amazonaws.com",
|
||||
},
|
||||
}
|
||||
expectedCloneEnvSecret := []ExpectedValue{
|
||||
{
|
||||
envIndex: 21,
|
||||
envIndex: 22,
|
||||
envVarConstant: "clone_aws_access_key_id",
|
||||
envVarValueRef: &v1.EnvVarSource{
|
||||
SecretKeyRef: &v1.SecretKeySelector{
|
||||
@@ -728,12 +728,12 @@ func TestGenerateSpiloPodEnvVars(t *testing.T) {
|
||||
}
|
||||
expectedStandbyEnvSecret := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "STANDBY_WALE_GS_PREFIX",
|
||||
envVarValue: "gs://some/path/",
|
||||
},
|
||||
{
|
||||
envIndex: 20,
|
||||
envIndex: 21,
|
||||
envVarConstant: "standby_google_application_credentials",
|
||||
envVarValueRef: &v1.EnvVarSource{
|
||||
SecretKeyRef: &v1.SecretKeySelector{
|
||||
@@ -2976,6 +2976,7 @@ func getServices(serviceType v1.ServiceType, sourceRanges []string, extTrafficPo
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyType(extTrafficPolicy),
|
||||
LoadBalancerSourceRanges: sourceRanges,
|
||||
Ports: []v1.ServicePort{{Name: "postgresql", Port: 5432, TargetPort: intstr.IntOrString{IntVal: 5432}, NodePort: nodePort}},
|
||||
Selector: map[string]string{"spilo-role": "master", "application": "spilo", "cluster-name": clusterName},
|
||||
Type: serviceType,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -67,6 +67,10 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
|
||||
}
|
||||
}()
|
||||
|
||||
if !c.patroniKubernetesUseConfigMaps() {
|
||||
c.logger.Warning("K8s endpoints are deprecated. Please, enable kubernetes_use_configmaps. Requires scale-in to a single primary, see v1 -> v2 migration docs!")
|
||||
}
|
||||
|
||||
if err = c.syncFinalizer(); err != nil {
|
||||
c.logger.Debugf("could not sync finalizers: %v", err)
|
||||
}
|
||||
|
||||
+4
-1
@@ -627,9 +627,12 @@ func (c *Cluster) patroniKubernetesUseConfigMaps() bool {
|
||||
if !c.patroniUsesKubernetes() {
|
||||
return false
|
||||
}
|
||||
if c.OpConfig.KubernetesUseConfigMaps == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
// otherwise, follow the operator configuration
|
||||
return c.OpConfig.KubernetesUseConfigMaps
|
||||
return *c.OpConfig.KubernetesUseConfigMaps
|
||||
}
|
||||
|
||||
// Earlier arguments take priority
|
||||
|
||||
@@ -299,7 +299,7 @@ func newInheritedAnnotationsCluster(client k8sutil.KubernetesClient) (*Cluster,
|
||||
OpConfig: config.Config{
|
||||
PatroniAPICheckInterval: &metav1.Duration{Duration: 1 * time.Second},
|
||||
PatroniAPICheckTimeout: &metav1.Duration{Duration: 5 * time.Second},
|
||||
KubernetesUseConfigMaps: true,
|
||||
KubernetesUseConfigMaps: util.True(),
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
@@ -388,7 +388,7 @@ func createPatroniResources(cluster *Cluster) error {
|
||||
Labels: cluster.labelsSet(false),
|
||||
}
|
||||
|
||||
if cluster.OpConfig.KubernetesUseConfigMaps {
|
||||
if cluster.OpConfig.KubernetesUseConfigMaps != nil && *cluster.OpConfig.KubernetesUseConfigMaps {
|
||||
configMap := v1.ConfigMap{
|
||||
ObjectMeta: metadata,
|
||||
}
|
||||
@@ -598,7 +598,7 @@ func TestInheritedAnnotations(t *testing.T) {
|
||||
// 3. Change from ConfigMaps to Endpoints
|
||||
err = cluster.deletePatroniResources()
|
||||
assert.NoError(t, err)
|
||||
cluster.OpConfig.KubernetesUseConfigMaps = false
|
||||
cluster.OpConfig.KubernetesUseConfigMaps = util.False()
|
||||
err = createPatroniResources(cluster)
|
||||
assert.NoError(t, err)
|
||||
err = cluster.Sync(newSpec.DeepCopy())
|
||||
|
||||
Reference in New Issue
Block a user