Add more validation for updating node.
This commit is contained in:
@@ -105,16 +105,22 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("not a minion: %#v", obj)
|
||||
}
|
||||
if errs := validation.ValidateMinion(minion); len(errs) > 0 {
|
||||
|
||||
// TODO: GetMinion will health check the minion, but we shouldn't require the minion to be
|
||||
// running for updating labels.
|
||||
oldMinion, err := rs.registry.GetMinion(ctx, minion.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if errs := validation.ValidateMinionUpdate(oldMinion, minion); len(errs) > 0 {
|
||||
return nil, kerrors.NewInvalid("minion", minion.Name, errs)
|
||||
}
|
||||
|
||||
return apiserver.MakeAsync(func() (runtime.Object, error) {
|
||||
err := rs.registry.UpdateMinion(ctx, minion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// TODO: GetMinion will health check the minion, but we shouldn't require the minion to be
|
||||
// running for updating labels.
|
||||
return rs.registry.GetMinion(ctx, minion.Name)
|
||||
}), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user