mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-19 00:31:00 +02:00
enable shmVolume setting in OperatorConfiguration
This commit is contained in:
@@ -360,8 +360,6 @@ func generateContainer(
|
||||
volumeMounts []v1.VolumeMount,
|
||||
privilegedMode bool,
|
||||
) *v1.Container {
|
||||
falseBool := false
|
||||
|
||||
return &v1.Container{
|
||||
Name: name,
|
||||
Image: *dockerImage,
|
||||
@@ -385,7 +383,7 @@ func generateContainer(
|
||||
Env: envVars,
|
||||
SecurityContext: &v1.SecurityContext{
|
||||
Privileged: &privilegedMode,
|
||||
ReadOnlyRootFilesystem: &falseBool,
|
||||
ReadOnlyRootFilesystem: util.False(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -421,9 +419,9 @@ func generateSidecarContainers(sidecars []acidv1.Sidecar,
|
||||
|
||||
// Check whether or not we're requested to mount an shm volume,
|
||||
// taking into account that PostgreSQL manifest has precedence.
|
||||
func mountShmVolumeNeeded(opConfig config.Config, pgSpec *acidv1.PostgresSpec) bool {
|
||||
if pgSpec.ShmVolume != nil {
|
||||
return *pgSpec.ShmVolume
|
||||
func mountShmVolumeNeeded(opConfig config.Config, pgSpec *acidv1.PostgresSpec) *bool {
|
||||
if pgSpec.ShmVolume != nil && *pgSpec.ShmVolume {
|
||||
return pgSpec.ShmVolume
|
||||
}
|
||||
|
||||
return opConfig.ShmVolume
|
||||
@@ -442,7 +440,7 @@ func generatePodTemplate(
|
||||
podServiceAccountName string,
|
||||
kubeIAMRole string,
|
||||
priorityClassName string,
|
||||
shmVolume bool,
|
||||
shmVolume *bool,
|
||||
podAntiAffinity bool,
|
||||
podAntiAffinityTopologyKey string,
|
||||
additionalSecretMount string,
|
||||
@@ -467,7 +465,7 @@ func generatePodTemplate(
|
||||
SecurityContext: &securityContext,
|
||||
}
|
||||
|
||||
if shmVolume {
|
||||
if shmVolume != nil && *shmVolume {
|
||||
addShmVolume(&podSpec)
|
||||
}
|
||||
|
||||
@@ -1456,7 +1454,7 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1beta1.CronJob, error) {
|
||||
c.OpConfig.PodServiceAccountName,
|
||||
c.OpConfig.KubeIAMRole,
|
||||
"",
|
||||
false,
|
||||
util.False(),
|
||||
false,
|
||||
"",
|
||||
"",
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
|
||||
"github.com/zalando/postgres-operator/pkg/util"
|
||||
"github.com/zalando/postgres-operator/pkg/util/config"
|
||||
"github.com/zalando/postgres-operator/pkg/util/constants"
|
||||
"github.com/zalando/postgres-operator/pkg/util/k8sutil"
|
||||
@@ -17,16 +18,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
|
||||
func True() *bool {
|
||||
b := true
|
||||
return &b
|
||||
}
|
||||
|
||||
func False() *bool {
|
||||
b := false
|
||||
return &b
|
||||
}
|
||||
|
||||
func toIntStr(val int) *intstr.IntOrString {
|
||||
b := intstr.FromInt(val)
|
||||
return &b
|
||||
@@ -118,14 +109,14 @@ func TestCreateLoadBalancerLogic(t *testing.T) {
|
||||
{
|
||||
subtest: "new format, load balancer is enabled for replica",
|
||||
role: Replica,
|
||||
spec: &acidv1.PostgresSpec{EnableReplicaLoadBalancer: True()},
|
||||
spec: &acidv1.PostgresSpec{EnableReplicaLoadBalancer: util.True()},
|
||||
opConfig: config.Config{},
|
||||
result: true,
|
||||
},
|
||||
{
|
||||
subtest: "new format, load balancer is disabled for replica",
|
||||
role: Replica,
|
||||
spec: &acidv1.PostgresSpec{EnableReplicaLoadBalancer: False()},
|
||||
spec: &acidv1.PostgresSpec{EnableReplicaLoadBalancer: util.False()},
|
||||
opConfig: config.Config{},
|
||||
result: false,
|
||||
},
|
||||
@@ -208,7 +199,7 @@ func TestGeneratePodDisruptionBudget(t *testing.T) {
|
||||
// With PodDisruptionBudget disabled.
|
||||
{
|
||||
New(
|
||||
Config{OpConfig: config.Config{Resources: config.Resources{ClusterNameLabel: "cluster-name", PodRoleLabel: "spilo-role"}, PDBNameFormat: "postgres-{cluster}-pdb", EnablePodDisruptionBudget: False()}},
|
||||
Config{OpConfig: config.Config{Resources: config.Resources{ClusterNameLabel: "cluster-name", PodRoleLabel: "spilo-role"}, PDBNameFormat: "postgres-{cluster}-pdb", EnablePodDisruptionBudget: util.False()}},
|
||||
k8sutil.KubernetesClient{},
|
||||
acidv1.Postgresql{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "myapp-database", Namespace: "myapp"},
|
||||
@@ -231,7 +222,7 @@ func TestGeneratePodDisruptionBudget(t *testing.T) {
|
||||
// With non-default PDBNameFormat and PodDisruptionBudget explicitly enabled.
|
||||
{
|
||||
New(
|
||||
Config{OpConfig: config.Config{Resources: config.Resources{ClusterNameLabel: "cluster-name", PodRoleLabel: "spilo-role"}, PDBNameFormat: "postgres-{cluster}-databass-budget", EnablePodDisruptionBudget: True()}},
|
||||
Config{OpConfig: config.Config{Resources: config.Resources{ClusterNameLabel: "cluster-name", PodRoleLabel: "spilo-role"}, PDBNameFormat: "postgres-{cluster}-databass-budget", EnablePodDisruptionBudget: util.True()}},
|
||||
k8sutil.KubernetesClient{},
|
||||
acidv1.Postgresql{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "myapp-database", Namespace: "myapp"},
|
||||
|
||||
Reference in New Issue
Block a user