From a02ee64d007a0eb9be25edb80a7257900831ec53 Mon Sep 17 00:00:00 2001 From: Tomas Smetana Date: Wed, 30 Nov 2016 10:24:46 +0100 Subject: [PATCH] Fix issue #37377: Report an event on successful PVC provisioning cc: @jsafrane --- pkg/controller/volume/persistentvolume/provision_test.go | 6 +++--- pkg/controller/volume/persistentvolume/pv_controller.go | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/controller/volume/persistentvolume/provision_test.go b/pkg/controller/volume/persistentvolume/provision_test.go index fac6186b3e5..88250ffdc7a 100644 --- a/pkg/controller/volume/persistentvolume/provision_test.go +++ b/pkg/controller/volume/persistentvolume/provision_test.go @@ -113,7 +113,7 @@ func TestProvisionSync(t *testing.T) { newClaimArray("claim11-1", "uid11-1", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), // Binding will be completed in the next syncClaim newClaimArray("claim11-1", "uid11-1", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation, annStorageProvisioner), - noevents, noerrors, wrapTestWithProvisionCalls([]provisionCall{provision1Success}, testSyncClaim), + []string{"Normal ProvisioningSucceeded"}, noerrors, wrapTestWithProvisionCalls([]provisionCall{provision1Success}, testSyncClaim), }, { // Provision failure - plugin not found @@ -185,7 +185,7 @@ func TestProvisionSync(t *testing.T) { newClaimArray("claim11-8", "uid11-8", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), // Binding will be completed in the next syncClaim newClaimArray("claim11-8", "uid11-8", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation, annStorageProvisioner), - noevents, + []string{"Normal ProvisioningSucceeded"}, []reactorError{ // Inject error to the first // kubeclient.PersistentVolumes.Create() call. All other calls @@ -306,7 +306,7 @@ func TestProvisionSync(t *testing.T) { claimWithClass("silver", newClaimArray("claim11-13", "uid11-13", "1Gi", "", v1.ClaimPending)), // Binding will be completed in the next syncClaim claimWithClass("silver", newClaimArray("claim11-13", "uid11-13", "1Gi", "", v1.ClaimPending, annStorageProvisioner)), - noevents, noerrors, wrapTestWithProvisionCalls([]provisionCall{provision2Success}, testSyncClaim), + []string{"Normal ProvisioningSucceeded"}, noerrors, wrapTestWithProvisionCalls([]provisionCall{provision2Success}, testSyncClaim), }, { // Provision error - non existing class diff --git a/pkg/controller/volume/persistentvolume/pv_controller.go b/pkg/controller/volume/persistentvolume/pv_controller.go index e15d6a8d76f..dbf0b674aeb 100644 --- a/pkg/controller/volume/persistentvolume/pv_controller.go +++ b/pkg/controller/volume/persistentvolume/pv_controller.go @@ -1382,6 +1382,8 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa } } else { glog.V(2).Infof("volume %q provisioned for claim %q", volume.Name, claimToClaimKey(claim)) + msg := fmt.Sprintf("Successfully provisioned volume %s using %s", volume.Name, plugin.GetPluginName()) + ctrl.eventRecorder.Event(claim, v1.EventTypeNormal, "ProvisioningSucceeded", msg) } }