From e8c46b1e5795ac0b2b7245d7e3de9619705ce88d Mon Sep 17 00:00:00 2001 From: "Cuong. Duong Manh" Date: Mon, 1 Jul 2024 14:42:47 +0700 Subject: [PATCH] [build][feat] add event handler --- pkg/driver/controller.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/driver/controller.go b/pkg/driver/controller.go index 0b68930..c94a54c 100644 --- a/pkg/driver/controller.go +++ b/pkg/driver/controller.go @@ -3,6 +3,7 @@ package driver import ( lctx "context" lerr "errors" + lfmt "fmt" lstrconv "strconv" lstr "strings" ltime "time" @@ -211,13 +212,15 @@ func (s *controllerService) CreateVolume(pctx lctx.Context, preq *lcsi.CreateVol cvr = cvr.WithEncrypted(pvc.GetCsiEncryptedAnnotation()) } - resp, sdkErr := s.cloud.EitherCreateResizeVolume(cvr.ToSdkCreateVolumeRequest()) + newVol, sdkErr := s.cloud.EitherCreateResizeVolume(cvr.ToSdkCreateVolumeRequest()) if sdkErr != nil { llog.ErrorS(sdkErr.GetError(), "[ERROR] - CreateVolume: failed to create volume", sdkErr.GetErrorMessages()) return nil, sdkErr.GetError() } - return newCreateVolumeResponse(resp, cvr, respCtx), nil + s.k8sClient.PersistentVolumeClaimEventNormal(pctx, cvr.PvcNamespaceTag, cvr.PvcNameTag, + "CsiCreateVolumeSuccess", lfmt.Sprintf("Volume created successfully with ID %s for PVC %s", newVol.Id, newVol.Name)) + return newCreateVolumeResponse(newVol, cvr, respCtx), nil } func (s *controllerService) DeleteVolume(_ lctx.Context, preq *lcsi.DeleteVolumeRequest) (*lcsi.DeleteVolumeResponse, error) {