Enhance e2e test and other fixes
This commit is contained in:
parent
d65dc51729
commit
041b9eec52
|
|
@ -189,6 +189,39 @@ class EndToEndTestCase(unittest.TestCase):
|
||||||
self.eventuallyEqual(lambda: k8s.count_running_pods("connection-pooler-name=acid-minimal-cluster-pooler-repl"), 2, "No pooler replica pods found")
|
self.eventuallyEqual(lambda: k8s.count_running_pods("connection-pooler-name=acid-minimal-cluster-pooler-repl"), 2, "No pooler replica pods found")
|
||||||
self.eventuallyEqual(lambda: k8s.count_services_with_label('application=db-connection-pooler,cluster-name=acid-minimal-cluster'), 2, "No pooler service found")
|
self.eventuallyEqual(lambda: k8s.count_services_with_label('application=db-connection-pooler,cluster-name=acid-minimal-cluster'), 2, "No pooler service found")
|
||||||
|
|
||||||
|
#Turn off only master connection pooler
|
||||||
|
k8s.api.custom_objects_api.patch_namespaced_custom_object(
|
||||||
|
'acid.zalan.do', 'v1', 'default',
|
||||||
|
'postgresqls', 'acid-minimal-cluster',
|
||||||
|
{
|
||||||
|
'spec': {
|
||||||
|
'enableConnectionPooler': False,
|
||||||
|
'enableReplicaConnectionPooler': True,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
self.eventuallyEqual(lambda: k8s.get_deployment_replica_count(), 2, "Deployment replicas is 2 default")
|
||||||
|
self.eventuallyEqual(lambda: k8s.count_running_pods("connection-pooler-name=acid-minimal-cluster-pooler"), 0, "Master pooler pods not deleted")
|
||||||
|
self.eventuallyEqual(lambda: k8s.count_running_pods("connection-pooler-name=acid-minimal-cluster-pooler-repl"), 2, "Pooler replica pods not found")
|
||||||
|
self.eventuallyEqual(lambda: k8s.count_services_with_label('application=db-connection-pooler,cluster-name=acid-minimal-cluster'), 1, "No pooler service found")
|
||||||
|
|
||||||
|
#Turn off only replica connection pooler
|
||||||
|
k8s.api.custom_objects_api.patch_namespaced_custom_object(
|
||||||
|
'acid.zalan.do', 'v1', 'default',
|
||||||
|
'postgresqls', 'acid-minimal-cluster',
|
||||||
|
{
|
||||||
|
'spec': {
|
||||||
|
'enableConnectionPooler': True,
|
||||||
|
'enableReplicaConnectionPooler': False,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
self.eventuallyEqual(lambda: k8s.get_deployment_replica_count(), 2, "Deployment replicas is 2 default")
|
||||||
|
self.eventuallyEqual(lambda: k8s.count_running_pods("connection-pooler-name=acid-minimal-cluster-pooler"), 2, "Master pooler pods not found")
|
||||||
|
self.eventuallyEqual(lambda: k8s.count_running_pods("connection-pooler-name=acid-minimal-cluster-pooler-repl"), 0, "Pooler replica pods not deleted")
|
||||||
|
self.eventuallyEqual(lambda: k8s.count_services_with_label('application=db-connection-pooler,cluster-name=acid-minimal-cluster'), 1, "No pooler service found")
|
||||||
|
|
||||||
|
|
||||||
# scale up connection pooler deployment
|
# scale up connection pooler deployment
|
||||||
k8s.api.custom_objects_api.patch_namespaced_custom_object(
|
k8s.api.custom_objects_api.patch_namespaced_custom_object(
|
||||||
'acid.zalan.do', 'v1', 'default',
|
'acid.zalan.do', 'v1', 'default',
|
||||||
|
|
@ -203,7 +236,6 @@ class EndToEndTestCase(unittest.TestCase):
|
||||||
|
|
||||||
self.eventuallyEqual(lambda: k8s.get_deployment_replica_count(), 3, "Deployment replicas is scaled to 3")
|
self.eventuallyEqual(lambda: k8s.get_deployment_replica_count(), 3, "Deployment replicas is scaled to 3")
|
||||||
self.eventuallyEqual(lambda: k8s.count_running_pods("connection-pooler-name=acid-minimal-cluster-pooler"), 3, "Scale up of pooler pods does not work")
|
self.eventuallyEqual(lambda: k8s.count_running_pods("connection-pooler-name=acid-minimal-cluster-pooler"), 3, "Scale up of pooler pods does not work")
|
||||||
self.eventuallyEqual(lambda: k8s.count_running_pods("connection-pooler-name=acid-minimal-cluster-pooler-repl"), 3, "Scale up of pooler replica pods does not work")
|
|
||||||
|
|
||||||
# turn it off, keeping config should be overwritten by false
|
# turn it off, keeping config should be overwritten by false
|
||||||
k8s.api.custom_objects_api.patch_namespaced_custom_object(
|
k8s.api.custom_objects_api.patch_namespaced_custom_object(
|
||||||
|
|
@ -423,7 +455,7 @@ class EndToEndTestCase(unittest.TestCase):
|
||||||
}
|
}
|
||||||
k8s.update_config(patch_lazy_spilo_upgrade, step="Init baseline image version")
|
k8s.update_config(patch_lazy_spilo_upgrade, step="Init baseline image version")
|
||||||
|
|
||||||
self.eventuallyEqual(lambda: k8s.get_statefulset_image(), SPILO_CURRENT, "Stagefulset not updated initially")
|
self.eventuallyEqual(lambda: k8s.get_statefulset_image(), SPILO_CURRENT, "Statefulset not updated initially")
|
||||||
self.eventuallyEqual(lambda: k8s.count_running_pods(), 2, "No 2 pods running")
|
self.eventuallyEqual(lambda: k8s.count_running_pods(), 2, "No 2 pods running")
|
||||||
self.eventuallyEqual(lambda: len(k8s.get_patroni_running_members(pod0)), 2, "Postgres status did not enter running")
|
self.eventuallyEqual(lambda: len(k8s.get_patroni_running_members(pod0)), 2, "Postgres status did not enter running")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ func (c *Cluster) Create() error {
|
||||||
//
|
//
|
||||||
// Do not consider connection pooler as a strict requirement, and if
|
// Do not consider connection pooler as a strict requirement, and if
|
||||||
// something fails, report warning
|
// something fails, report warning
|
||||||
c.createConnectionPooler(c.installLookupFunction)
|
c.createConnectionPooler()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,12 +108,12 @@ func (c *Cluster) connectionPoolerLabelsSelector(name string, role PostgresRole)
|
||||||
// have connectionpooler name in the cp object to have it immutable name
|
// have connectionpooler name in the cp object to have it immutable name
|
||||||
// add these cp related functions to a new cp file
|
// add these cp related functions to a new cp file
|
||||||
// opConfig, cluster, and database name
|
// opConfig, cluster, and database name
|
||||||
func (c *Cluster) createConnectionPooler(lookup InstallFunction) (SyncReason, error) {
|
func (c *Cluster) createConnectionPooler() (SyncReason, error) {
|
||||||
var reason SyncReason
|
var reason SyncReason
|
||||||
c.setProcessName("creating connection pooler")
|
c.setProcessName("creating connection pooler")
|
||||||
|
|
||||||
//this is essentially sync with nil as oldSpec
|
//this is essentially sync with nil as oldSpec
|
||||||
if reason, err := c.syncConnectionPooler(nil, &c.Postgresql, lookup); err != nil {
|
if reason, err := c.syncConnectionPooler(nil, &c.Postgresql, c.installLookupFunction); err != nil {
|
||||||
return reason, err
|
return reason, err
|
||||||
}
|
}
|
||||||
return reason, nil
|
return reason, nil
|
||||||
|
|
@ -692,6 +692,13 @@ func (c *Cluster) syncConnectionPooler(oldSpec, newSpec *acidv1.Postgresql, inst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if newNeedConnectionPooler {
|
if newNeedConnectionPooler {
|
||||||
|
//Sync pooler secrets in case they were deleted
|
||||||
|
c.logger.Debugf("syncing secrets")
|
||||||
|
|
||||||
|
if err := c.syncSecrets(); err != nil {
|
||||||
|
c.logger.Errorf("could not sync secrets: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Try to sync in any case. If we didn't needed connection pooler before,
|
// Try to sync in any case. If we didn't needed connection pooler before,
|
||||||
// it means we want to create it. If it was already present, still sync
|
// it means we want to create it. If it was already present, still sync
|
||||||
// since it could happen that there is no difference in specs, and all
|
// since it could happen that there is no difference in specs, and all
|
||||||
|
|
@ -723,6 +730,7 @@ func (c *Cluster) syncConnectionPooler(oldSpec, newSpec *acidv1.Postgresql, inst
|
||||||
return NoSync, err
|
return NoSync, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if reason, err = c.syncConnectionPoolerWorker(oldSpec, newSpec, role); err != nil {
|
if reason, err = c.syncConnectionPoolerWorker(oldSpec, newSpec, role); err != nil {
|
||||||
c.logger.Errorf("could not sync connection pooler: %v", err)
|
c.logger.Errorf("could not sync connection pooler: %v", err)
|
||||||
return reason, err
|
return reason, err
|
||||||
|
|
@ -820,8 +828,6 @@ func (c *Cluster) syncConnectionPoolerWorker(oldSpec, newSpec *acidv1.Postgresql
|
||||||
return reason, fmt.Errorf(msg, err)
|
return reason, fmt.Errorf(msg, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//oldDeploymentSpec := c.ConnectionPooler[role].Deployment
|
|
||||||
|
|
||||||
deployment, err := updateConnectionPoolerDeployment(c.KubeClient,
|
deployment, err := updateConnectionPoolerDeployment(c.KubeClient,
|
||||||
newDeploymentSpec)
|
newDeploymentSpec)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -567,10 +567,12 @@ func (c *Cluster) installLookupFunction(poolerSchema, poolerUser string, role Po
|
||||||
failedDatabases = append(failedDatabases, dbname)
|
failedDatabases = append(failedDatabases, dbname)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
c.logger.Infof("pooler lookup function installed into %s", dbname)
|
c.logger.Infof("pooler lookup function installed into %s", dbname)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(failedDatabases) == 0 {
|
||||||
c.ConnectionPooler[role].LookupFunction = true
|
c.ConnectionPooler[role].LookupFunction = true
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue