mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Merge pull request #54656 from mindprince/device-plugin-error-message
Automatic merge from submit-queue (batch tested with PRs 54656, 54552, 54389, 53634, 54408). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Better error messages and logging while registering device plugins. Related to: #51993 /sig scheduling **Release note**: ```release-note NONE ```
This commit is contained in:
commit
3335fcc01f
@ -169,15 +169,18 @@ func (m *ManagerImpl) Allocate(resourceName string, devs []string) (*pluginapi.A
|
||||
}
|
||||
|
||||
// Register registers a device plugin.
|
||||
func (m *ManagerImpl) Register(ctx context.Context,
|
||||
r *pluginapi.RegisterRequest) (*pluginapi.Empty, error) {
|
||||
glog.V(2).Infof("Got request for Device Plugin %s", r.ResourceName)
|
||||
func (m *ManagerImpl) Register(ctx context.Context, r *pluginapi.RegisterRequest) (*pluginapi.Empty, error) {
|
||||
glog.Infof("Got registration request from device plugin with resource name %q", r.ResourceName)
|
||||
if r.Version != pluginapi.Version {
|
||||
return &pluginapi.Empty{}, fmt.Errorf(errUnsuportedVersion)
|
||||
errorString := fmt.Sprintf(errUnsuportedVersion, r.Version, pluginapi.Version)
|
||||
glog.Infof("Bad registration request from device plugin with resource name %q: %v", r.ResourceName, errorString)
|
||||
return &pluginapi.Empty{}, fmt.Errorf(errorString)
|
||||
}
|
||||
|
||||
if !v1helper.IsExtendedResourceName(v1.ResourceName(r.ResourceName)) {
|
||||
return &pluginapi.Empty{}, fmt.Errorf(errInvalidResourceName, r.ResourceName)
|
||||
errorString := fmt.Sprintf(errInvalidResourceName, r.ResourceName)
|
||||
glog.Infof("Bad registration request from device plugin: %v", errorString)
|
||||
return &pluginapi.Empty{}, fmt.Errorf(errorString)
|
||||
}
|
||||
|
||||
// TODO: for now, always accepts newest device plugin. Later may consider to
|
||||
|
@ -64,13 +64,13 @@ const (
|
||||
errFailedToDialDevicePlugin = "failed to dial device plugin:"
|
||||
// errUnsuportedVersion is the error raised when the device plugin uses an API version not
|
||||
// supported by the Kubelet registry
|
||||
errUnsuportedVersion = "unsupported API version by the Kubelet registry"
|
||||
errUnsuportedVersion = "requested API version %q is not supported by kubelet. Supported version is %q"
|
||||
// errDevicePluginAlreadyExists is the error raised when a device plugin with the
|
||||
// same Resource Name tries to register itself
|
||||
errDevicePluginAlreadyExists = "another device plugin already registered this Resource Name"
|
||||
// errInvalidResourceName is the error raised when a device plugin is registering
|
||||
// itself with an invalid ResourceName
|
||||
errInvalidResourceName = "the ResourceName %s is invalid"
|
||||
errInvalidResourceName = "the ResourceName %q is invalid"
|
||||
// errEmptyResourceName is the error raised when the resource name field is empty
|
||||
errEmptyResourceName = "invalid Empty ResourceName"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user