Address review
This commit is contained in:
parent
0095be0279
commit
a9d02bacc4
|
|
@ -274,9 +274,9 @@ configConnectionPool:
|
|||
connection_pool_mode: "transaction"
|
||||
# default resources
|
||||
connection_pool_default_cpu_request: "100m"
|
||||
connection_pool_default_memory_request: "100M"
|
||||
connection_pool_default_memory_request: "100Mi"
|
||||
connection_pool_default_cpu_limit: "100m"
|
||||
connection_pool_default_memory_limit: "100M"
|
||||
connection_pool_default_memory_limit: "100Mi"
|
||||
|
||||
rbac:
|
||||
# Specifies whether RBAC resources should be created
|
||||
|
|
|
|||
|
|
@ -251,9 +251,9 @@ configConnectionPool:
|
|||
connection_pool_mode: "transaction"
|
||||
# default resources
|
||||
connection_pool_default_cpu_request: "100m"
|
||||
connection_pool_default_memory_request: "100M"
|
||||
connection_pool_default_memory_request: "100Mi"
|
||||
connection_pool_default_cpu_limit: "100m"
|
||||
connection_pool_default_memory_limit: "100M"
|
||||
connection_pool_default_memory_limit: "100Mi"
|
||||
|
||||
rbac:
|
||||
# Specifies whether RBAC resources should be created
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ configuration for connection pool. If this section is not empty, a connection
|
|||
pool will be created for a database even if `enableConnectionPool` is not
|
||||
present.
|
||||
|
||||
* **number_of_instances**
|
||||
* **numberOfInstances**
|
||||
How many instances of connection pool to create.
|
||||
|
||||
* **mode**
|
||||
|
|
@ -384,5 +384,8 @@ present.
|
|||
* **user**
|
||||
User to create for connection pool to be able to connect to a database.
|
||||
|
||||
* **dockerImage**
|
||||
Which docker image to use for connection pool deployment.
|
||||
|
||||
* **resources**
|
||||
Resource configuration for connection pool deployment.
|
||||
|
|
|
|||
|
|
@ -77,6 +77,9 @@ spec:
|
|||
type: string
|
||||
mode:
|
||||
type: string
|
||||
enum:
|
||||
- "session"
|
||||
- "transaction"
|
||||
numberOfInstances:
|
||||
type: integer
|
||||
minimum: 1
|
||||
|
|
@ -208,22 +211,6 @@ spec:
|
|||
type: string
|
||||
replicaLoadBalancer: # deprecated
|
||||
type: boolean
|
||||
connectionPool:
|
||||
type: object
|
||||
properties:
|
||||
schema:
|
||||
type: string
|
||||
user:
|
||||
type: string
|
||||
number_of_instances:
|
||||
type: integer
|
||||
dockerImage:
|
||||
type: string
|
||||
mode:
|
||||
type: string
|
||||
enum:
|
||||
- "session"
|
||||
- "transaction"
|
||||
resources:
|
||||
type: object
|
||||
required:
|
||||
|
|
|
|||
|
|
@ -184,6 +184,14 @@ var PostgresCRDResourceValidation = apiextv1beta1.CustomResourceValidation{
|
|||
},
|
||||
"mode": {
|
||||
Type: "string",
|
||||
Enum: []apiextv1beta1.JSON{
|
||||
{
|
||||
Raw: []byte(`"session"`),
|
||||
},
|
||||
{
|
||||
Raw: []byte(`"transaction"`),
|
||||
},
|
||||
},
|
||||
},
|
||||
"numberOfInstances": {
|
||||
Type: "integer",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package v1
|
||||
|
||||
// Operator configuration CRD definition, please use snake_case for field names.
|
||||
|
||||
import (
|
||||
"github.com/zalando/postgres-operator/pkg/util/config"
|
||||
|
||||
|
|
@ -159,10 +161,10 @@ type ConnectionPoolConfiguration struct {
|
|||
User string `json:"connection_pool_user,omitempty"`
|
||||
Image string `json:"connection_pool_image,omitempty"`
|
||||
Mode string `json:"connection_pool_mode,omitempty"`
|
||||
DefaultCPURequest string `name:"connection_pool_default_cpu_request,omitempty"`
|
||||
DefaultMemoryRequest string `name:"connection_pool_default_memory_request,omitempty"`
|
||||
DefaultCPULimit string `name:"connection_pool_default_cpu_limit,omitempty"`
|
||||
DefaultMemoryLimit string `name:"connection_pool_default_memory_limit,omitempty"`
|
||||
DefaultCPURequest string `json:"connection_pool_default_cpu_request,omitempty"`
|
||||
DefaultMemoryRequest string `json:"connection_pool_default_memory_request,omitempty"`
|
||||
DefaultCPULimit string `json:"connection_pool_default_cpu_limit,omitempty"`
|
||||
DefaultMemoryLimit string `json:"connection_pool_default_memory_limit,omitempty"`
|
||||
}
|
||||
|
||||
// OperatorLogicalBackupConfiguration defines configuration for logical backup
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package v1
|
||||
|
||||
// Postgres CRD definition, please use CamelCase for field names.
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
|
|
@ -27,7 +29,7 @@ type PostgresSpec struct {
|
|||
Patroni `json:"patroni,omitempty"`
|
||||
Resources `json:"resources,omitempty"`
|
||||
|
||||
EnableConnectionPool bool `json:"enableConnectionPool,omitempty"`
|
||||
EnableConnectionPool *bool `json:"enableConnectionPool,omitempty"`
|
||||
ConnectionPool *ConnectionPool `json:"connectionPool,omitempty"`
|
||||
|
||||
TeamID string `json:"teamId"`
|
||||
|
|
@ -169,7 +171,7 @@ type PostgresStatus struct {
|
|||
// makes sense to expose. E.g. pool size (min/max boundaries), max client
|
||||
// connections etc.
|
||||
type ConnectionPool struct {
|
||||
NumberOfInstances *int32 `json:"number_of_instances,omitempty"`
|
||||
NumberOfInstances *int32 `json:"numberOfInstances,omitempty"`
|
||||
Schema string `json:"schema,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
Mode string `json:"mode,omitempty"`
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ import (
|
|||
|
||||
// APIVersion of the `postgresql` and `operator` CRDs
|
||||
const (
|
||||
APIVersion = "v1"
|
||||
PostgresqlKind = "postgresql"
|
||||
APIVersion = "v1"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -43,7 +42,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
|||
// AddKnownType assumes derives the type kind from the type name, which is always uppercase.
|
||||
// For our CRDs we use lowercase names historically, therefore we have to supply the name separately.
|
||||
// TODO: User uppercase CRDResourceKind of our types in the next major API version
|
||||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind(PostgresqlKind), &Postgresql{})
|
||||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("postgresql"), &Postgresql{})
|
||||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("postgresqlList"), &PostgresqlList{})
|
||||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("OperatorConfiguration"),
|
||||
&OperatorConfiguration{})
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ type Config struct {
|
|||
PodServiceAccountRoleBinding *rbacv1beta1.RoleBinding
|
||||
}
|
||||
|
||||
type ConnectionPoolResources struct {
|
||||
type ConnectionPoolObjects struct {
|
||||
Deployment *appsv1.Deployment
|
||||
Service *v1.Service
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ type kubeResources struct {
|
|||
Endpoints map[PostgresRole]*v1.Endpoints
|
||||
Secrets map[types.UID]*v1.Secret
|
||||
Statefulset *appsv1.StatefulSet
|
||||
ConnectionPool *ConnectionPoolResources
|
||||
ConnectionPool *ConnectionPoolObjects
|
||||
PodDisruptionBudget *policybeta1.PodDisruptionBudget
|
||||
//Pods are treated separately
|
||||
//PVCs are treated separately
|
||||
|
|
|
|||
|
|
@ -541,8 +541,8 @@ func TestConnPoolPodSpec(t *testing.T) {
|
|||
ConnectionPool: config.ConnectionPool{
|
||||
ConnPoolDefaultCPURequest: "100m",
|
||||
ConnPoolDefaultCPULimit: "100m",
|
||||
ConnPoolDefaultMemoryRequest: "100M",
|
||||
ConnPoolDefaultMemoryLimit: "100M",
|
||||
ConnPoolDefaultMemoryRequest: "100Mi",
|
||||
ConnPoolDefaultMemoryLimit: "100Mi",
|
||||
},
|
||||
},
|
||||
}, k8sutil.KubernetesClient{}, acidv1.Postgresql{}, logger)
|
||||
|
|
@ -666,8 +666,8 @@ func TestConnPoolDeploymentSpec(t *testing.T) {
|
|||
ConnectionPool: config.ConnectionPool{
|
||||
ConnPoolDefaultCPURequest: "100m",
|
||||
ConnPoolDefaultCPULimit: "100m",
|
||||
ConnPoolDefaultMemoryRequest: "100M",
|
||||
ConnPoolDefaultMemoryLimit: "100M",
|
||||
ConnPoolDefaultMemoryRequest: "100Mi",
|
||||
ConnPoolDefaultMemoryLimit: "100Mi",
|
||||
},
|
||||
},
|
||||
}, k8sutil.KubernetesClient{}, acidv1.Postgresql{}, logger)
|
||||
|
|
@ -767,8 +767,8 @@ func TestConnPoolServiceSpec(t *testing.T) {
|
|||
ConnectionPool: config.ConnectionPool{
|
||||
ConnPoolDefaultCPURequest: "100m",
|
||||
ConnPoolDefaultCPULimit: "100m",
|
||||
ConnPoolDefaultMemoryRequest: "100M",
|
||||
ConnPoolDefaultMemoryLimit: "100M",
|
||||
ConnPoolDefaultMemoryRequest: "100Mi",
|
||||
ConnPoolDefaultMemoryLimit: "100Mi",
|
||||
},
|
||||
},
|
||||
}, k8sutil.KubernetesClient{}, acidv1.Postgresql{}, logger)
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ func (c *Cluster) createStatefulSet() (*appsv1.StatefulSet, error) {
|
|||
//
|
||||
// After that create all the objects for connection pool, namely a deployment
|
||||
// with a chosen pooler and a service to expose it.
|
||||
func (c *Cluster) createConnectionPool(lookup InstallFunction) (*ConnectionPoolResources, error) {
|
||||
func (c *Cluster) createConnectionPool(lookup InstallFunction) (*ConnectionPoolObjects, error) {
|
||||
var msg string
|
||||
c.setProcessName("creating connection pool")
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ func (c *Cluster) createConnectionPool(lookup InstallFunction) (*ConnectionPoolR
|
|||
return nil, err
|
||||
}
|
||||
|
||||
c.ConnectionPool = &ConnectionPoolResources{
|
||||
c.ConnectionPool = &ConnectionPoolObjects{
|
||||
Deployment: deployment,
|
||||
Service: service,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ func mockInstallLookupFunction(schema string, user string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func boolToPointer(value bool) *bool {
|
||||
return &value
|
||||
}
|
||||
|
||||
func TestConnPoolCreationAndDeletion(t *testing.T) {
|
||||
testName := "Test connection pool creation"
|
||||
var cluster = New(
|
||||
|
|
@ -28,8 +32,8 @@ func TestConnPoolCreationAndDeletion(t *testing.T) {
|
|||
ConnectionPool: config.ConnectionPool{
|
||||
ConnPoolDefaultCPURequest: "100m",
|
||||
ConnPoolDefaultCPULimit: "100m",
|
||||
ConnPoolDefaultMemoryRequest: "100M",
|
||||
ConnPoolDefaultMemoryLimit: "100M",
|
||||
ConnPoolDefaultMemoryRequest: "100Mi",
|
||||
ConnPoolDefaultMemoryLimit: "100Mi",
|
||||
},
|
||||
},
|
||||
}, k8sutil.NewMockKubernetesClient(), acidv1.Postgresql{}, logger)
|
||||
|
|
@ -77,8 +81,8 @@ func TestNeedConnPool(t *testing.T) {
|
|||
ConnectionPool: config.ConnectionPool{
|
||||
ConnPoolDefaultCPURequest: "100m",
|
||||
ConnPoolDefaultCPULimit: "100m",
|
||||
ConnPoolDefaultMemoryRequest: "100M",
|
||||
ConnPoolDefaultMemoryLimit: "100M",
|
||||
ConnPoolDefaultMemoryRequest: "100Mi",
|
||||
ConnPoolDefaultMemoryLimit: "100Mi",
|
||||
},
|
||||
},
|
||||
}, k8sutil.NewMockKubernetesClient(), acidv1.Postgresql{}, logger)
|
||||
|
|
@ -93,7 +97,7 @@ func TestNeedConnPool(t *testing.T) {
|
|||
}
|
||||
|
||||
cluster.Spec = acidv1.PostgresSpec{
|
||||
EnableConnectionPool: true,
|
||||
EnableConnectionPool: boolToPointer(true),
|
||||
}
|
||||
|
||||
if !cluster.needConnectionPool() {
|
||||
|
|
|
|||
|
|
@ -618,7 +618,7 @@ func (c *Cluster) syncLogicalBackupJob() error {
|
|||
func (c *Cluster) syncConnectionPool(oldSpec, newSpec *acidv1.Postgresql) error {
|
||||
if c.ConnectionPool == nil {
|
||||
c.logger.Warning("Connection pool resources are empty")
|
||||
c.ConnectionPool = &ConnectionPoolResources{}
|
||||
c.ConnectionPool = &ConnectionPoolObjects{}
|
||||
}
|
||||
|
||||
deployment, err := c.KubeClient.
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ func TestConnPoolSynchronization(t *testing.T) {
|
|||
ConnectionPool: config.ConnectionPool{
|
||||
ConnPoolDefaultCPURequest: "100m",
|
||||
ConnPoolDefaultCPULimit: "100m",
|
||||
ConnPoolDefaultMemoryRequest: "100M",
|
||||
ConnPoolDefaultMemoryLimit: "100M",
|
||||
ConnPoolDefaultMemoryRequest: "100Mi",
|
||||
ConnPoolDefaultMemoryLimit: "100Mi",
|
||||
},
|
||||
},
|
||||
}, k8sutil.KubernetesClient{}, acidv1.Postgresql{}, logger)
|
||||
|
|
|
|||
|
|
@ -497,5 +497,9 @@ func (c *Cluster) patroniUsesKubernetes() bool {
|
|||
}
|
||||
|
||||
func (c *Cluster) needConnectionPool() bool {
|
||||
return c.Spec.ConnectionPool != nil || c.Spec.EnableConnectionPool == true
|
||||
if c.Spec.EnableConnectionPool == nil {
|
||||
return c.Spec.ConnectionPool != nil
|
||||
} else {
|
||||
return *c.Spec.EnableConnectionPool
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ const (
|
|||
ConnectionPoolUserName = "pooler"
|
||||
ConnectionPoolSchemaName = "pooler"
|
||||
ConnectionPoolDefaultType = "pgbouncer"
|
||||
ConnectionPoolDefaultMode = "transition"
|
||||
ConnectionPoolDefaultMode = "transaction"
|
||||
ConnectionPoolDefaultCpuRequest = "100m"
|
||||
ConnectionPoolDefaultCpuLimit = "100m"
|
||||
ConnectionPoolDefaultMemoryRequest = "100M"
|
||||
ConnectionPoolDefaultMemoryLimit = "100M"
|
||||
ConnectionPoolDefaultMemoryRequest = "100Mi"
|
||||
ConnectionPoolDefaultMemoryLimit = "100Mi"
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue