remove volume size requirement and relax changes on update
This commit is contained in:
parent
a0b0da3c8c
commit
c48ddd1055
|
|
@ -40,9 +40,8 @@ you can find this example also in the manifests folder:
|
||||||
kubectl create -f manifests/minimal-postgres-manifest.yaml
|
kubectl create -f manifests/minimal-postgres-manifest.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
Note, that the minimum volume size to properly run the `postgresql` resource is
|
Note, that the minimum volume size to run the `postgresql` resource on Elastic
|
||||||
`1Gi`. If a lower value is set in the manifest the operator will cancel ADD or
|
Block Storage (EBS) is `1Gi`.
|
||||||
UPDATE events on this resource with an error.
|
|
||||||
|
|
||||||
## Watch pods being created
|
## Watch pods being created
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -500,7 +500,6 @@ func (c *Cluster) validateResources(spec *acidv1.PostgresSpec) error {
|
||||||
const (
|
const (
|
||||||
cpuMinLimit = "256m"
|
cpuMinLimit = "256m"
|
||||||
memoryMinLimit = "256Mi"
|
memoryMinLimit = "256Mi"
|
||||||
volumeMinSize = "1Gi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -530,15 +529,6 @@ func (c *Cluster) validateResources(spec *acidv1.PostgresSpec) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
volumeSize := spec.Volume.Size
|
|
||||||
isSmaller, err = util.IsSmallerQuantity(volumeSize, volumeMinSize)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error validating volume size: %v", err)
|
|
||||||
}
|
|
||||||
if isSmaller {
|
|
||||||
return fmt.Errorf("defined volume size %s is below required minimum %s to properly run postgresql resource", volumeSize, volumeMinSize)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -552,6 +542,7 @@ func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
|
|
||||||
|
oldStatus := c.Status
|
||||||
c.setStatus(acidv1.ClusterStatusUpdating)
|
c.setStatus(acidv1.ClusterStatusUpdating)
|
||||||
c.setSpec(newSpec)
|
c.setSpec(newSpec)
|
||||||
|
|
||||||
|
|
@ -563,6 +554,21 @@ func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
// check if pod resources were edited below the enforced minimum limits
|
||||||
|
if err := c.validateResources(&newSpec.Spec); err != nil {
|
||||||
|
err = fmt.Errorf("insufficient resource limits specified: %v", err)
|
||||||
|
|
||||||
|
isCPULimitSmaller, err2 := util.IsSmallerQuantity(newSpec.Spec.Resources.ResourceLimits.CPU, oldSpec.Spec.Resources.ResourceLimits.CPU)
|
||||||
|
isMemoryLimitSmaller, err3 := util.IsSmallerQuantity(newSpec.Spec.Resources.ResourceLimits.Memory, oldSpec.Spec.Resources.ResourceLimits.Memory)
|
||||||
|
|
||||||
|
if oldStatus.Running() && !isCPULimitSmaller && !isMemoryLimitSmaller && err2 == nil && err3 == nil {
|
||||||
|
c.logger.Warning(err)
|
||||||
|
} else {
|
||||||
|
updateFailed = true
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if oldSpec.Spec.PgVersion != newSpec.Spec.PgVersion { // PG versions comparison
|
if oldSpec.Spec.PgVersion != newSpec.Spec.PgVersion { // PG versions comparison
|
||||||
c.logger.Warningf("postgresql version change(%q -> %q) has no effect", oldSpec.Spec.PgVersion, newSpec.Spec.PgVersion)
|
c.logger.Warningf("postgresql version change(%q -> %q) has no effect", oldSpec.Spec.PgVersion, newSpec.Spec.PgVersion)
|
||||||
//we need that hack to generate statefulset with the old version
|
//we need that hack to generate statefulset with the old version
|
||||||
|
|
@ -595,12 +601,6 @@ func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check pod resources and volume size and cancel update if they are too low
|
|
||||||
if err := c.validateResources(&c.Spec); err != nil {
|
|
||||||
updateFailed = true
|
|
||||||
return fmt.Errorf("insufficient resource limits specified: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Volume
|
// Volume
|
||||||
if oldSpec.Spec.Size != newSpec.Spec.Size {
|
if oldSpec.Spec.Size != newSpec.Spec.Size {
|
||||||
c.logger.Debugf("syncing persistent volumes")
|
c.logger.Debugf("syncing persistent volumes")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue