mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-02 21:12:08 +02:00
Deprecate old LB options, fix endpoint sync. (#287)
* Depreate old LB options, fix endpoint sync. - deprecate useLoadBalancer, replicaLoadBalancer from the manifest and enable_load_balancer from the operator configuration. The old operator configuration options become no-op with this commit. For the old manifest options, `useLoadBalancer` and `replicaLoadBalancer` are still consulted, but only in the absense of the new ones (enableMasterLoadBalancer and enableReplicaLoadBalancer). - Make sure the endpoint being created during the sync receives proper addresses subset. This is more critical for the replicas, as for the masters Patroni will normally re-create the endpoint before the operator. - Avoid creating the replica endpoint, since it will be created automatically by the corresponding service. - Update the README and unit tests. Code review by @mgomezch and @zerg-junior
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/zalando-incubator/postgres-operator/pkg/spec"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
True bool = true
|
||||
False bool = false
|
||||
)
|
||||
|
||||
func TestMergeDeprecatedPostgreSQLSpecParameters(t *testing.T) {
|
||||
c := NewController(&spec.ControllerConfig{})
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
in *spec.PostgresSpec
|
||||
out *spec.PostgresSpec
|
||||
error string
|
||||
}{
|
||||
{
|
||||
"Check that old parameters propagate values to the new ones",
|
||||
&spec.PostgresSpec{UseLoadBalancer: &True, ReplicaLoadBalancer: &True},
|
||||
&spec.PostgresSpec{UseLoadBalancer: &True, ReplicaLoadBalancer: &True,
|
||||
EnableMasterLoadBalancer: &True, EnableReplicaLoadBalancer: &True},
|
||||
"New parameters should be set from the values of old ones",
|
||||
},
|
||||
{
|
||||
"Check that new parameters are not set when both old and new ones are present",
|
||||
&spec.PostgresSpec{UseLoadBalancer: &True, EnableReplicaLoadBalancer: &True},
|
||||
&spec.PostgresSpec{UseLoadBalancer: &True, EnableReplicaLoadBalancer: &True},
|
||||
"New parameters should remain unchanged when both old and new are present",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
result := c.mergeDeprecatedPostgreSQLSpecParameters(tt.in)
|
||||
if !reflect.DeepEqual(result, tt.out) {
|
||||
t.Errorf("%s: %v", tt.name, tt.error)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user