mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Do not report warning event when an nknown provisioner is requested
with StorageClass.Provisioner == <unknown plugin>, we should wait for either external provisioner or volume admin to provide a PV for a claim instead of reporting an error. Fixes #31723
This commit is contained in:
		@@ -19,6 +19,7 @@ package persistentvolume
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
@@ -1234,6 +1235,19 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa
 | 
				
			|||||||
		// syncVolume() call.
 | 
							// syncVolume() call.
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if plugin == nil {
 | 
				
			||||||
 | 
							// findProvisionablePlugin returned no error nor plugin.
 | 
				
			||||||
 | 
							// This means that an unknown provisioner is requested. Report an event
 | 
				
			||||||
 | 
							// and wait for the external provisioner
 | 
				
			||||||
 | 
							if storageClass != nil {
 | 
				
			||||||
 | 
								msg := fmt.Sprintf("cannot find provisioner %q, expecting that a volume for the claim is provisioned either manually or via external software", storageClass.Provisioner)
 | 
				
			||||||
 | 
								ctrl.eventRecorder.Event(claim, api.EventTypeNormal, "ExternalProvisioning", msg)
 | 
				
			||||||
 | 
								glog.V(3).Infof("provisioning claim %q: %s", claimToClaimKey(claim), msg)
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								glog.V(3).Infof("cannot find storage class for claim %q", claimToClaimKey(claim))
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Gather provisioning options
 | 
						// Gather provisioning options
 | 
				
			||||||
	tags := make(map[string]string)
 | 
						tags := make(map[string]string)
 | 
				
			||||||
@@ -1366,6 +1380,9 @@ func (ctrl *PersistentVolumeController) scheduleOperation(operationName string,
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// findProvisionablePlugin finds a provisioner plugin for a given claim.
 | 
				
			||||||
 | 
					// It returns either the provisioning plugin or nil when an external
 | 
				
			||||||
 | 
					// provisioner is requested.
 | 
				
			||||||
func (ctrl *PersistentVolumeController) findProvisionablePlugin(claim *api.PersistentVolumeClaim) (vol.ProvisionableVolumePlugin, *storage.StorageClass, error) {
 | 
					func (ctrl *PersistentVolumeController) findProvisionablePlugin(claim *api.PersistentVolumeClaim) (vol.ProvisionableVolumePlugin, *storage.StorageClass, error) {
 | 
				
			||||||
	// TODO: remove this alpha behavior in 1.5
 | 
						// TODO: remove this alpha behavior in 1.5
 | 
				
			||||||
	alpha := hasAnnotation(claim.ObjectMeta, annAlphaClass)
 | 
						alpha := hasAnnotation(claim.ObjectMeta, annAlphaClass)
 | 
				
			||||||
@@ -1399,7 +1416,11 @@ func (ctrl *PersistentVolumeController) findProvisionablePlugin(claim *api.Persi
 | 
				
			|||||||
	// Find a plugin for the class
 | 
						// Find a plugin for the class
 | 
				
			||||||
	plugin, err := ctrl.volumePluginMgr.FindProvisionablePluginByName(class.Provisioner)
 | 
						plugin, err := ctrl.volumePluginMgr.FindProvisionablePluginByName(class.Provisioner)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, nil, err
 | 
							if !strings.HasPrefix(class.Provisioner, "kubernetes.io/") {
 | 
				
			||||||
 | 
								// External provisioner is requested, do not report error
 | 
				
			||||||
 | 
								return nil, class, nil
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return nil, class, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return plugin, class, nil
 | 
						return plugin, class, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -95,7 +95,7 @@ type controllerTest struct {
 | 
				
			|||||||
type testCall func(ctrl *PersistentVolumeController, reactor *volumeReactor, test controllerTest) error
 | 
					type testCall func(ctrl *PersistentVolumeController, reactor *volumeReactor, test controllerTest) error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const testNamespace = "default"
 | 
					const testNamespace = "default"
 | 
				
			||||||
const mockPluginName = "MockVolumePlugin"
 | 
					const mockPluginName = "kubernetes.io/mock-volume"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var versionConflictError = errors.New("VersionError")
 | 
					var versionConflictError = errors.New("VersionError")
 | 
				
			||||||
var novolumes []*api.PersistentVolume
 | 
					var novolumes []*api.PersistentVolume
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,6 +54,26 @@ var storageClasses = []*storage.StorageClass{
 | 
				
			|||||||
		Provisioner: mockPluginName,
 | 
							Provisioner: mockPluginName,
 | 
				
			||||||
		Parameters:  class2Parameters,
 | 
							Parameters:  class2Parameters,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							TypeMeta: unversioned.TypeMeta{
 | 
				
			||||||
 | 
								Kind: "StorageClass",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							ObjectMeta: api.ObjectMeta{
 | 
				
			||||||
 | 
								Name: "external",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							Provisioner: "vendor.com/my-volume",
 | 
				
			||||||
 | 
							Parameters:  class1Parameters,
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							TypeMeta: unversioned.TypeMeta{
 | 
				
			||||||
 | 
								Kind: "StorageClass",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							ObjectMeta: api.ObjectMeta{
 | 
				
			||||||
 | 
								Name: "unknown-internal",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							Provisioner: "kubernetes.io/unknown",
 | 
				
			||||||
 | 
							Parameters:  class1Parameters,
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// call to storageClass 1, returning an error
 | 
					// call to storageClass 1, returning an error
 | 
				
			||||||
@@ -314,6 +334,26 @@ func TestProvisionSync(t *testing.T) {
 | 
				
			|||||||
			newClaimArray("claim11-15", "uid11-15", "1Gi", "", api.ClaimPending),
 | 
								newClaimArray("claim11-15", "uid11-15", "1Gi", "", api.ClaimPending),
 | 
				
			||||||
			noevents, noerrors, wrapTestWithProvisionCalls([]provisionCall{}, testSyncClaim),
 | 
								noevents, noerrors, wrapTestWithProvisionCalls([]provisionCall{}, testSyncClaim),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								// No provisioning + normal event with external provisioner
 | 
				
			||||||
 | 
								"11-17 - external provisioner",
 | 
				
			||||||
 | 
								novolumes,
 | 
				
			||||||
 | 
								novolumes,
 | 
				
			||||||
 | 
								claimWithClass("external", newClaimArray("claim11-17", "uid11-17", "1Gi", "", api.ClaimPending)),
 | 
				
			||||||
 | 
								claimWithClass("external", newClaimArray("claim11-17", "uid11-17", "1Gi", "", api.ClaimPending)),
 | 
				
			||||||
 | 
								[]string{"Normal ExternalProvisioning"},
 | 
				
			||||||
 | 
								noerrors, wrapTestWithProvisionCalls([]provisionCall{}, testSyncClaim),
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								// No provisioning + warning event with unknown internal provisioner
 | 
				
			||||||
 | 
								"11-18 - unknown internal provisioner",
 | 
				
			||||||
 | 
								novolumes,
 | 
				
			||||||
 | 
								novolumes,
 | 
				
			||||||
 | 
								claimWithClass("unknown-internal", newClaimArray("claim11-18", "uid11-18", "1Gi", "", api.ClaimPending)),
 | 
				
			||||||
 | 
								claimWithClass("unknown-internal", newClaimArray("claim11-18", "uid11-18", "1Gi", "", api.ClaimPending)),
 | 
				
			||||||
 | 
								[]string{"Warning ProvisioningFailed"},
 | 
				
			||||||
 | 
								noerrors, wrapTestWithProvisionCalls([]provisionCall{}, testSyncClaim),
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	runSyncTests(t, tests, storageClasses)
 | 
						runSyncTests(t, tests, storageClasses)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user