check resize mode on update events
This commit is contained in:
parent
90799d7e7f
commit
b4ba10297b
|
|
@ -105,6 +105,10 @@ rules:
|
||||||
- delete
|
- delete
|
||||||
- get
|
- get
|
||||||
- list
|
- list
|
||||||
|
{{- if toString .Values.configKubernetes.storage_resize_mode | eq "pvc" }}
|
||||||
|
- patch
|
||||||
|
- update
|
||||||
|
{{- end }}
|
||||||
# to read existing PVs. Creation should be done via dynamic provisioning
|
# to read existing PVs. Creation should be done via dynamic provisioning
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- ""
|
- ""
|
||||||
|
|
@ -113,7 +117,9 @@ rules:
|
||||||
verbs:
|
verbs:
|
||||||
- get
|
- get
|
||||||
- list
|
- list
|
||||||
|
{{- if toString .Values.configKubernetes.storage_resize_mode | eq "ebs" }}
|
||||||
- update # only for resizing AWS volumes
|
- update # only for resizing AWS volumes
|
||||||
|
{{- end }}
|
||||||
# to watch Spilo pods and do rolling updates. Creation via StatefulSet
|
# to watch Spilo pods and do rolling updates. Creation via StatefulSet
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- ""
|
- ""
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,8 @@ rules:
|
||||||
- delete
|
- delete
|
||||||
- get
|
- get
|
||||||
- list
|
- list
|
||||||
|
- patch
|
||||||
|
- update
|
||||||
# to read existing PVs. Creation should be done via dynamic provisioning
|
# to read existing PVs. Creation should be done via dynamic provisioning
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- ""
|
- ""
|
||||||
|
|
|
||||||
|
|
@ -671,13 +671,23 @@ func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
|
||||||
|
|
||||||
// Volume
|
// Volume
|
||||||
if oldSpec.Spec.Size != newSpec.Spec.Size {
|
if oldSpec.Spec.Size != newSpec.Spec.Size {
|
||||||
c.logger.Debugf("syncing persistent volumes")
|
|
||||||
c.logVolumeChanges(oldSpec.Spec.Volume, newSpec.Spec.Volume)
|
c.logVolumeChanges(oldSpec.Spec.Volume, newSpec.Spec.Volume)
|
||||||
|
|
||||||
if err := c.syncVolumes(); err != nil {
|
if c.OpConfig.StorageResizeMode == "pvc" {
|
||||||
c.logger.Errorf("could not sync persistent volumes: %v", err)
|
c.logger.Debugf("syncing persistent volume claims using %q resize mode", c.OpConfig.StorageResizeMode)
|
||||||
updateFailed = true
|
if err := c.syncVolumeClaims(); err != nil {
|
||||||
|
c.logger.Errorf("could not sync persistent volume claims: %v", err)
|
||||||
|
updateFailed = true
|
||||||
|
}
|
||||||
|
} else if c.OpConfig.StorageResizeMode == "ebs" {
|
||||||
|
c.logger.Debugf("syncing persistent volumes using %q resize mode", c.OpConfig.StorageResizeMode)
|
||||||
|
if err := c.syncVolumes(); err != nil {
|
||||||
|
c.logger.Errorf("could not sync persistent volumes: %v", err)
|
||||||
|
updateFailed = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
c.logger.Infof("Storage resize is disabled (storage_resize_mode is off). Skipping volume sync.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Statefulset
|
// Statefulset
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.OpConfig.StorageResizeMode == "pvc" {
|
if c.OpConfig.StorageResizeMode == "pvc" {
|
||||||
c.logger.Debugf("syncing persistent volume claims")
|
c.logger.Debugf("syncing persistent volume claims using %q resize mode", c.OpConfig.StorageResizeMode)
|
||||||
if err = c.syncVolumeClaims(); err != nil {
|
if err = c.syncVolumeClaims(); err != nil {
|
||||||
err = fmt.Errorf("could not sync persistent volume claims: %v", err)
|
err = fmt.Errorf("could not sync persistent volume claims: %v", err)
|
||||||
return err
|
return err
|
||||||
|
|
@ -70,7 +70,7 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
|
||||||
// TODO: handle the case of the cluster that is downsized and enlarged again
|
// TODO: handle the case of the cluster that is downsized and enlarged again
|
||||||
// (there will be a volume from the old pod for which we can't act before the
|
// (there will be a volume from the old pod for which we can't act before the
|
||||||
// the statefulset modification is concluded)
|
// the statefulset modification is concluded)
|
||||||
c.logger.Debugf("syncing persistent volumes")
|
c.logger.Debugf("syncing persistent volumes using %q resize mode", c.OpConfig.StorageResizeMode)
|
||||||
if err = c.syncVolumes(); err != nil {
|
if err = c.syncVolumes(); err != nil {
|
||||||
err = fmt.Errorf("could not sync persistent volumes: %v", err)
|
err = fmt.Errorf("could not sync persistent volumes: %v", err)
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue