mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #106048 from dcbw/pod-storage-empty-oldMachine
pod/storage: remove always-empty 'oldMachine' in setPodHostAndAnnotations()
This commit is contained in:
commit
d19e16b86d
@ -186,10 +186,10 @@ func (r *BindingREST) Create(ctx context.Context, name string, obj runtime.Objec
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// setPodHostAndAnnotations sets the given pod's host to 'machine' if and only if it was
|
// setPodHostAndAnnotations sets the given pod's host to 'machine' if and only if
|
||||||
// previously 'oldMachine' and merges the provided annotations with those of the pod.
|
// the pod is unassigned and merges the provided annotations with those of the pod.
|
||||||
// Returns the current state of the pod, or an error.
|
// Returns the current state of the pod, or an error.
|
||||||
func (r *BindingREST) setPodHostAndAnnotations(ctx context.Context, podUID types.UID, podResourceVersion, podID, oldMachine, machine string, annotations map[string]string, dryRun bool) (finalPod *api.Pod, err error) {
|
func (r *BindingREST) setPodHostAndAnnotations(ctx context.Context, podUID types.UID, podResourceVersion, podID, machine string, annotations map[string]string, dryRun bool) (finalPod *api.Pod, err error) {
|
||||||
podKey, err := r.store.KeyFunc(ctx, podID)
|
podKey, err := r.store.KeyFunc(ctx, podID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -214,7 +214,7 @@ func (r *BindingREST) setPodHostAndAnnotations(ctx context.Context, podUID types
|
|||||||
if pod.DeletionTimestamp != nil {
|
if pod.DeletionTimestamp != nil {
|
||||||
return nil, fmt.Errorf("pod %s is being deleted, cannot be assigned to a host", pod.Name)
|
return nil, fmt.Errorf("pod %s is being deleted, cannot be assigned to a host", pod.Name)
|
||||||
}
|
}
|
||||||
if pod.Spec.NodeName != oldMachine {
|
if pod.Spec.NodeName != "" {
|
||||||
return nil, fmt.Errorf("pod %v is already assigned to node %q", pod.Name, pod.Spec.NodeName)
|
return nil, fmt.Errorf("pod %v is already assigned to node %q", pod.Name, pod.Spec.NodeName)
|
||||||
}
|
}
|
||||||
pod.Spec.NodeName = machine
|
pod.Spec.NodeName = machine
|
||||||
@ -236,7 +236,7 @@ func (r *BindingREST) setPodHostAndAnnotations(ctx context.Context, podUID types
|
|||||||
|
|
||||||
// assignPod assigns the given pod to the given machine.
|
// assignPod assigns the given pod to the given machine.
|
||||||
func (r *BindingREST) assignPod(ctx context.Context, podUID types.UID, podResourceVersion, podID string, machine string, annotations map[string]string, dryRun bool) (err error) {
|
func (r *BindingREST) assignPod(ctx context.Context, podUID types.UID, podResourceVersion, podID string, machine string, annotations map[string]string, dryRun bool) (err error) {
|
||||||
if _, err = r.setPodHostAndAnnotations(ctx, podUID, podResourceVersion, podID, "", machine, annotations, dryRun); err != nil {
|
if _, err = r.setPodHostAndAnnotations(ctx, podUID, podResourceVersion, podID, machine, annotations, dryRun); err != nil {
|
||||||
err = storeerr.InterpretGetError(err, api.Resource("pods"), podID)
|
err = storeerr.InterpretGetError(err, api.Resource("pods"), podID)
|
||||||
err = storeerr.InterpretUpdateError(err, api.Resource("pods"), podID)
|
err = storeerr.InterpretUpdateError(err, api.Resource("pods"), podID)
|
||||||
if _, ok := err.(*errors.StatusError); !ok {
|
if _, ok := err.(*errors.StatusError); !ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user