mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 02:34:03 +00:00
Merge pull request #121065 from byako/issue121063
DRA: notify ResourceClaim or ResourceClass of params error
This commit is contained in:
commit
4106366b6d
@ -94,7 +94,7 @@ type Driver interface {
|
|||||||
// If selectedNode is set, the driver must attempt to allocate for that
|
// If selectedNode is set, the driver must attempt to allocate for that
|
||||||
// node. If that is not possible, it must return an error. The
|
// node. If that is not possible, it must return an error. The
|
||||||
// controller will call UnsuitableNodes and pass the new information to
|
// controller will call UnsuitableNodes and pass the new information to
|
||||||
// the scheduler, which then will lead to selecting a diffent node
|
// the scheduler, which then will lead to selecting a different node
|
||||||
// if the current one is not suitable.
|
// if the current one is not suitable.
|
||||||
//
|
//
|
||||||
// The Claim, ClaimParameters, Class, ClassParameters fields of "claims" parameter
|
// The Claim, ClaimParameters, Class, ClassParameters fields of "claims" parameter
|
||||||
@ -357,7 +357,6 @@ func (ctrl *controller) Run(workers int) {
|
|||||||
var errRequeue = errors.New("requeue")
|
var errRequeue = errors.New("requeue")
|
||||||
|
|
||||||
// errPeriodic is a special error instance that functions can return
|
// errPeriodic is a special error instance that functions can return
|
||||||
// to request silent instance that functions can return
|
|
||||||
// to request silent retrying at a fixed rate.
|
// to request silent retrying at a fixed rate.
|
||||||
var errPeriodic = errors.New("periodic")
|
var errPeriodic = errors.New("periodic")
|
||||||
|
|
||||||
@ -536,8 +535,9 @@ func (ctrl *controller) syncClaim(ctx context.Context, claim *resourcev1alpha2.R
|
|||||||
return errRequeue
|
return errRequeue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check parameters.
|
// Check parameters. Do not record event to Claim if its parameters are invalid,
|
||||||
claimParameters, classParameters, err := ctrl.getParameters(ctx, claim, class)
|
// syncKey will record the error.
|
||||||
|
claimParameters, classParameters, err := ctrl.getParameters(ctx, claim, class, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -558,14 +558,18 @@ func (ctrl *controller) syncClaim(ctx context.Context, claim *resourcev1alpha2.R
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctrl *controller) getParameters(ctx context.Context, claim *resourcev1alpha2.ResourceClaim, class *resourcev1alpha2.ResourceClass) (claimParameters, classParameters interface{}, err error) {
|
func (ctrl *controller) getParameters(ctx context.Context, claim *resourcev1alpha2.ResourceClaim, class *resourcev1alpha2.ResourceClass, notifyClaim bool) (claimParameters, classParameters interface{}, err error) {
|
||||||
classParameters, err = ctrl.driver.GetClassParameters(ctx, class)
|
classParameters, err = ctrl.driver.GetClassParameters(ctx, class)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
ctrl.eventRecorder.Event(class, v1.EventTypeWarning, "Failed", err.Error())
|
||||||
err = fmt.Errorf("class parameters %s: %v", class.ParametersRef, err)
|
err = fmt.Errorf("class parameters %s: %v", class.ParametersRef, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
claimParameters, err = ctrl.driver.GetClaimParameters(ctx, claim, class, classParameters)
|
claimParameters, err = ctrl.driver.GetClaimParameters(ctx, claim, class, classParameters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if notifyClaim {
|
||||||
|
ctrl.eventRecorder.Event(claim, v1.EventTypeWarning, "Failed", err.Error())
|
||||||
|
}
|
||||||
err = fmt.Errorf("claim parameters %s: %v", claim.Spec.ParametersRef, err)
|
err = fmt.Errorf("claim parameters %s: %v", claim.Spec.ParametersRef, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -688,9 +692,10 @@ func (ctrl *controller) checkPodClaim(ctx context.Context, pod *v1.Pod, podClaim
|
|||||||
if class.DriverName != ctrl.name {
|
if class.DriverName != ctrl.name {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
// Check parameters.
|
// Check parameters. Record event to claim and pod if parameters are invalid.
|
||||||
claimParameters, classParameters, err := ctrl.getParameters(ctx, claim, class)
|
claimParameters, classParameters, err := ctrl.getParameters(ctx, claim, class, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
ctrl.eventRecorder.Event(pod, v1.EventTypeWarning, "Failed", fmt.Sprintf("claim %v: %v", claim.Name, err.Error()))
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &ClaimAllocation{
|
return &ClaimAllocation{
|
||||||
|
@ -482,7 +482,7 @@ const _ = grpc.SupportPackageIsVersion4
|
|||||||
type NodeClient interface {
|
type NodeClient interface {
|
||||||
// NodePrepareResources prepares several ResourceClaims
|
// NodePrepareResources prepares several ResourceClaims
|
||||||
// for use on the node. If an error is returned, the
|
// for use on the node. If an error is returned, the
|
||||||
// response is ignored. Failures for individidual claims
|
// response is ignored. Failures for individual claims
|
||||||
// can be reported inside NodePrepareResourcesResponse.
|
// can be reported inside NodePrepareResourcesResponse.
|
||||||
NodePrepareResources(ctx context.Context, in *NodePrepareResourcesRequest, opts ...grpc.CallOption) (*NodePrepareResourcesResponse, error)
|
NodePrepareResources(ctx context.Context, in *NodePrepareResourcesRequest, opts ...grpc.CallOption) (*NodePrepareResourcesResponse, error)
|
||||||
// NodeUnprepareResources is the opposite of NodePrepareResources.
|
// NodeUnprepareResources is the opposite of NodePrepareResources.
|
||||||
@ -520,7 +520,7 @@ func (c *nodeClient) NodeUnprepareResources(ctx context.Context, in *NodeUnprepa
|
|||||||
type NodeServer interface {
|
type NodeServer interface {
|
||||||
// NodePrepareResources prepares several ResourceClaims
|
// NodePrepareResources prepares several ResourceClaims
|
||||||
// for use on the node. If an error is returned, the
|
// for use on the node. If an error is returned, the
|
||||||
// response is ignored. Failures for individidual claims
|
// response is ignored. Failures for individual claims
|
||||||
// can be reported inside NodePrepareResourcesResponse.
|
// can be reported inside NodePrepareResourcesResponse.
|
||||||
NodePrepareResources(context.Context, *NodePrepareResourcesRequest) (*NodePrepareResourcesResponse, error)
|
NodePrepareResources(context.Context, *NodePrepareResourcesRequest) (*NodePrepareResourcesResponse, error)
|
||||||
// NodeUnprepareResources is the opposite of NodePrepareResources.
|
// NodeUnprepareResources is the opposite of NodePrepareResources.
|
||||||
|
@ -34,7 +34,7 @@ option (gogoproto.goproto_unrecognized_all) = false;
|
|||||||
service Node {
|
service Node {
|
||||||
// NodePrepareResources prepares several ResourceClaims
|
// NodePrepareResources prepares several ResourceClaims
|
||||||
// for use on the node. If an error is returned, the
|
// for use on the node. If an error is returned, the
|
||||||
// response is ignored. Failures for individidual claims
|
// response is ignored. Failures for individual claims
|
||||||
// can be reported inside NodePrepareResourcesResponse.
|
// can be reported inside NodePrepareResourcesResponse.
|
||||||
rpc NodePrepareResources (NodePrepareResourcesRequest)
|
rpc NodePrepareResources (NodePrepareResourcesRequest)
|
||||||
returns (NodePrepareResourcesResponse) {}
|
returns (NodePrepareResourcesResponse) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user