only error on Sts creation
This commit is contained in:
parent
f9cc17f846
commit
7bd39d3bfd
|
|
@ -57,7 +57,7 @@ configKubernetes:
|
||||||
# label assigned to Kubernetes objects created by the operator
|
# label assigned to Kubernetes objects created by the operator
|
||||||
cluster_name_label: version
|
cluster_name_label: version
|
||||||
# annotations attached to each database pod
|
# annotations attached to each database pod
|
||||||
# custom_pod_annotations: keya:valuea,keyb:valueb
|
# custom_pod_annotations: "keya:valuea,keyb:valueb"
|
||||||
|
|
||||||
# enables initContainers to run actions before Spilo is started
|
# enables initContainers to run actions before Spilo is started
|
||||||
enable_init_containers: "true"
|
enable_init_containers: "true"
|
||||||
|
|
|
||||||
|
|
@ -788,11 +788,10 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
|
||||||
}
|
}
|
||||||
|
|
||||||
if spec.InitContainers != nil && len(spec.InitContainers) > 0 {
|
if spec.InitContainers != nil && len(spec.InitContainers) > 0 {
|
||||||
if c.OpConfig.EnableInitContainers != nil && *c.OpConfig.EnableInitContainers {
|
if c.OpConfig.EnableInitContainers != nil && !(*c.OpConfig.EnableInitContainers) {
|
||||||
initContainers = spec.InitContainers
|
c.logger.Warningf("initContainers in use but globally disabled - next statefulSet creation would fail")
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("initContainers specified but globally disabled")
|
|
||||||
}
|
}
|
||||||
|
initContainers = spec.InitContainers
|
||||||
}
|
}
|
||||||
|
|
||||||
customPodEnvVarsList := make([]v1.EnvVar, 0)
|
customPodEnvVarsList := make([]v1.EnvVar, 0)
|
||||||
|
|
@ -882,14 +881,13 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
|
||||||
|
|
||||||
// generate sidecar containers
|
// generate sidecar containers
|
||||||
if sideCars != nil && len(sideCars) > 0 {
|
if sideCars != nil && len(sideCars) > 0 {
|
||||||
if c.OpConfig.EnableSidecars != nil && *c.OpConfig.EnableSidecars {
|
if c.OpConfig.EnableSidecars != nil && !(*c.OpConfig.EnableSidecars) {
|
||||||
|
c.logger.Warningf("sidecars in use but globally disabled - next stateful set creation would fail")
|
||||||
|
}
|
||||||
if sidecarContainers, err = generateSidecarContainers(sideCars, volumeMounts, defaultResources,
|
if sidecarContainers, err = generateSidecarContainers(sideCars, volumeMounts, defaultResources,
|
||||||
c.OpConfig.SuperUsername, c.credentialSecretName(c.OpConfig.SuperUsername), c.logger); err != nil {
|
c.OpConfig.SuperUsername, c.credentialSecretName(c.OpConfig.SuperUsername), c.logger); err != nil {
|
||||||
return nil, fmt.Errorf("could not generate sidecar containers: %v", err)
|
return nil, fmt.Errorf("could not generate sidecar containers: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("sidecar containers specified but globally disabled")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tolerationSpec := tolerations(&spec.Tolerations, c.OpConfig.PodToleration)
|
tolerationSpec := tolerations(&spec.Tolerations, c.OpConfig.PodToleration)
|
||||||
|
|
@ -1427,7 +1425,7 @@ func (c *Cluster) generatePodDisruptionBudget() *policybeta1.PodDisruptionBudget
|
||||||
pdbEnabled := c.OpConfig.EnablePodDisruptionBudget
|
pdbEnabled := c.OpConfig.EnablePodDisruptionBudget
|
||||||
|
|
||||||
// if PodDisruptionBudget is disabled or if there are no DB pods, set the budget to 0.
|
// if PodDisruptionBudget is disabled or if there are no DB pods, set the budget to 0.
|
||||||
if (pdbEnabled != nil && !*pdbEnabled) || c.Spec.NumberOfInstances <= 0 {
|
if (pdbEnabled != nil && !(*pdbEnabled)) || c.Spec.NumberOfInstances <= 0 {
|
||||||
minAvailable = intstr.FromInt(0)
|
minAvailable = intstr.FromInt(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,17 @@ func (c *Cluster) listResources() error {
|
||||||
|
|
||||||
func (c *Cluster) createStatefulSet() (*appsv1.StatefulSet, error) {
|
func (c *Cluster) createStatefulSet() (*appsv1.StatefulSet, error) {
|
||||||
c.setProcessName("creating statefulset")
|
c.setProcessName("creating statefulset")
|
||||||
|
// check if it's allowed that spec contains initContainers
|
||||||
|
if c.Spec.InitContainers != nil && len(c.Spec.InitContainers) > 0 &&
|
||||||
|
c.OpConfig.EnableInitContainers != nil && !*c.OpConfig.EnableInitContainers {
|
||||||
|
return nil, fmt.Errorf("initContainers specified but globally disabled")
|
||||||
|
}
|
||||||
|
// check if it's allowed that spec contains sidecars
|
||||||
|
if c.Spec.Sidecars != nil && len(c.Spec.Sidecars) > 0 &&
|
||||||
|
c.OpConfig.EnableSidecars != nil && !*c.OpConfig.EnableSidecars {
|
||||||
|
return nil, fmt.Errorf("sidecar containers specified but globally disabled")
|
||||||
|
}
|
||||||
|
|
||||||
statefulSetSpec, err := c.generateStatefulSet(&c.Spec)
|
statefulSetSpec, err := c.generateStatefulSet(&c.Spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not generate statefulset: %v", err)
|
return nil, fmt.Errorf("could not generate statefulset: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -123,8 +123,8 @@ type Config struct {
|
||||||
ReplicaDNSNameFormat StringTemplate `name:"replica_dns_name_format" default:"{cluster}-repl.{team}.{hostedzone}"`
|
ReplicaDNSNameFormat StringTemplate `name:"replica_dns_name_format" default:"{cluster}-repl.{team}.{hostedzone}"`
|
||||||
PDBNameFormat StringTemplate `name:"pdb_name_format" default:"postgres-{cluster}-pdb"`
|
PDBNameFormat StringTemplate `name:"pdb_name_format" default:"postgres-{cluster}-pdb"`
|
||||||
EnablePodDisruptionBudget *bool `name:"enable_pod_disruption_budget" default:"true"`
|
EnablePodDisruptionBudget *bool `name:"enable_pod_disruption_budget" default:"true"`
|
||||||
EnableSidecars *bool `name:"enable_sidecars" default:"true"`
|
|
||||||
EnableInitContainers *bool `name:"enable_init_containers" default:"true"`
|
EnableInitContainers *bool `name:"enable_init_containers" default:"true"`
|
||||||
|
EnableSidecars *bool `name:"enable_sidecars" default:"true"`
|
||||||
Workers uint32 `name:"workers" default:"4"`
|
Workers uint32 `name:"workers" default:"4"`
|
||||||
APIPort int `name:"api_port" default:"8080"`
|
APIPort int `name:"api_port" default:"8080"`
|
||||||
RingLogLines int `name:"ring_log_lines" default:"100"`
|
RingLogLines int `name:"ring_log_lines" default:"100"`
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue