From 60824e54a548f33b9067fa69e36935fe3e19dee4 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Mon, 5 Jul 2021 19:19:08 +0530 Subject: [PATCH] Add "SnapshotCreated" and "SnapshotReady" events for snapshot-controller --- pkg/common-controller/snapshot_controller.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/common-controller/snapshot_controller.go b/pkg/common-controller/snapshot_controller.go index ef3862d9..115f27e2 100644 --- a/pkg/common-controller/snapshot_controller.go +++ b/pkg/common-controller/snapshot_controller.go @@ -1159,6 +1159,8 @@ func (ctrl *csiSnapshotCommonController) updateSnapshotStatus(snapshot *crdv1.Vo createOperationKey := metrics.NewOperationKey(metrics.CreateSnapshotOperationName, snapshot.UID) if !utils.IsSnapshotCreated(snapshotObj) && utils.IsSnapshotCreated(snapshotClone) { ctrl.metricsManager.RecordMetrics(createOperationKey, metrics.NewSnapshotOperationStatus(metrics.SnapshotStatusTypeSuccess), driverName) + msg := fmt.Sprintf("Snapshot %s was successfully created by the CSI driver.", utils.SnapshotKey(snapshot)) + ctrl.eventRecorder.Event(snapshot, v1.EventTypeNormal, "SnapshotCreated", msg) } // Must meet the following criteria to emit a successful CreateSnapshotAndReady status @@ -1167,6 +1169,8 @@ func (ctrl *csiSnapshotCommonController) updateSnapshotStatus(snapshot *crdv1.Vo if !utils.IsSnapshotReady(snapshotObj) && utils.IsSnapshotReady(snapshotClone) { createAndReadyOperation := metrics.NewOperationKey(metrics.CreateSnapshotAndReadyOperationName, snapshot.UID) ctrl.metricsManager.RecordMetrics(createAndReadyOperation, metrics.NewSnapshotOperationStatus(metrics.SnapshotStatusTypeSuccess), driverName) + msg := fmt.Sprintf("Snapshot %s is ready to use.", utils.SnapshotKey(snapshot)) + ctrl.eventRecorder.Event(snapshot, v1.EventTypeNormal, "SnapshotReady", msg) } newSnapshotObj, err := ctrl.clientset.SnapshotV1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(context.TODO(), snapshotClone, metav1.UpdateOptions{})