Skip to content

Commit e802597

Browse files
author
lamai93
committed
Added CannotShrink Event.
1 parent 571c0cb commit e802597

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/deployment/resources/pvc_inspector.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func (r *Resources) InspectPVCs(ctx context.Context) (util.Interval, error) {
100100
} else if cmp > 0 {
101101
log.Error().Str("server-group", group.AsRole()).Str("pvc-storage-size", volumeSize.String()).Str("requested-size", requestedSize.String()).
102102
Msg("Volume size should not shrink")
103+
r.context.CreateEvent(k8sutil.NewCannotShrinkVolumeEvent(r.context.GetAPIObject(), p.Name))
103104
}
104105
}
105106
}

pkg/util/k8sutil/events.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@ func NewPVCResizedEvent(apiObject APIObject, pvcname string) *Event {
202202
return event
203203
}
204204

205+
// NewCannotShrinkVolumeEvent creates an event indicating that the user tried to shrink a PVC
206+
func NewCannotShrinkVolumeEvent(apiObject APIObject, pvcname string) *Event {
207+
event := newDeploymentEvent(apiObject)
208+
event.Type = v1.EventTypeNormal
209+
event.Reason = "PVC Shrinked"
210+
event.Message = fmt.Sprintf("The persistent volume claim %s can not be shrinked", pvcname)
211+
return event
212+
}
213+
205214
// NewUpgradeNotAllowedEvent creates an event indicating that an upgrade (or downgrade) is not allowed.
206215
func NewUpgradeNotAllowedEvent(apiObject APIObject,
207216
fromVersion, toVersion driver.Version,

0 commit comments

Comments
 (0)