mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #101156 from alculquicondor/unused_create_pod
Remove unused CreatePodsOnNode function
This commit is contained in:
commit
22d120b4d6
@ -447,9 +447,6 @@ func (r RealControllerRevisionControl) PatchControllerRevision(namespace, name s
|
|||||||
type PodControlInterface interface {
|
type PodControlInterface interface {
|
||||||
// CreatePods creates new pods according to the spec.
|
// CreatePods creates new pods according to the spec.
|
||||||
CreatePods(namespace string, template *v1.PodTemplateSpec, object runtime.Object) error
|
CreatePods(namespace string, template *v1.PodTemplateSpec, object runtime.Object) error
|
||||||
// CreatePodsOnNode creates a new pod according to the spec on the specified node,
|
|
||||||
// and sets the ControllerRef.
|
|
||||||
CreatePodsOnNode(nodeName, namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error
|
|
||||||
// CreatePodsWithControllerRef creates new pods according to the spec, and sets object as the pod's controller.
|
// CreatePodsWithControllerRef creates new pods according to the spec, and sets object as the pod's controller.
|
||||||
CreatePodsWithControllerRef(namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error
|
CreatePodsWithControllerRef(namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error
|
||||||
// DeletePod deletes the pod identified by podID.
|
// DeletePod deletes the pod identified by podID.
|
||||||
@ -517,21 +514,14 @@ func validateControllerRef(controllerRef *metav1.OwnerReference) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r RealPodControl) CreatePods(namespace string, template *v1.PodTemplateSpec, object runtime.Object) error {
|
func (r RealPodControl) CreatePods(namespace string, template *v1.PodTemplateSpec, object runtime.Object) error {
|
||||||
return r.createPods("", namespace, template, object, nil)
|
return r.createPods(namespace, template, object, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r RealPodControl) CreatePodsWithControllerRef(namespace string, template *v1.PodTemplateSpec, controllerObject runtime.Object, controllerRef *metav1.OwnerReference) error {
|
func (r RealPodControl) CreatePodsWithControllerRef(namespace string, template *v1.PodTemplateSpec, controllerObject runtime.Object, controllerRef *metav1.OwnerReference) error {
|
||||||
if err := validateControllerRef(controllerRef); err != nil {
|
if err := validateControllerRef(controllerRef); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return r.createPods("", namespace, template, controllerObject, controllerRef)
|
return r.createPods(namespace, template, controllerObject, controllerRef)
|
||||||
}
|
|
||||||
|
|
||||||
func (r RealPodControl) CreatePodsOnNode(nodeName, namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error {
|
|
||||||
if err := validateControllerRef(controllerRef); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return r.createPods(nodeName, namespace, template, object, controllerRef)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r RealPodControl) PatchPod(namespace, name string, data []byte) error {
|
func (r RealPodControl) PatchPod(namespace, name string, data []byte) error {
|
||||||
@ -564,14 +554,11 @@ func GetPodFromTemplate(template *v1.PodTemplateSpec, parentObject runtime.Objec
|
|||||||
return pod, nil
|
return pod, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r RealPodControl) createPods(nodeName, namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error {
|
func (r RealPodControl) createPods(namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error {
|
||||||
pod, err := GetPodFromTemplate(template, object, controllerRef)
|
pod, err := GetPodFromTemplate(template, object, controllerRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(nodeName) != 0 {
|
|
||||||
pod.Spec.NodeName = nodeName
|
|
||||||
}
|
|
||||||
if len(labels.Set(pod.Labels)) == 0 {
|
if len(labels.Set(pod.Labels)) == 0 {
|
||||||
return fmt.Errorf("unable to create pods, no labels")
|
return fmt.Errorf("unable to create pods, no labels")
|
||||||
}
|
}
|
||||||
@ -665,21 +652,6 @@ func (f *FakePodControl) CreatePodsWithControllerRef(namespace string, spec *v1.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakePodControl) CreatePodsOnNode(nodeName, namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error {
|
|
||||||
f.Lock()
|
|
||||||
defer f.Unlock()
|
|
||||||
f.CreateCallCount++
|
|
||||||
if f.CreateLimit != 0 && f.CreateCallCount > f.CreateLimit {
|
|
||||||
return fmt.Errorf("not creating pod, limit %d already reached (create call %d)", f.CreateLimit, f.CreateCallCount)
|
|
||||||
}
|
|
||||||
f.Templates = append(f.Templates, *template)
|
|
||||||
f.ControllerRefs = append(f.ControllerRefs, *controllerRef)
|
|
||||||
if f.Err != nil {
|
|
||||||
return f.Err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *FakePodControl) DeletePod(namespace string, podID string, object runtime.Object) error {
|
func (f *FakePodControl) DeletePod(namespace string, podID string, object runtime.Object) error {
|
||||||
f.Lock()
|
f.Lock()
|
||||||
defer f.Unlock()
|
defer f.Unlock()
|
||||||
|
@ -241,37 +241,6 @@ func newFakePodControl() *fakePodControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakePodControl) CreatePodsOnNode(nodeName, namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error {
|
|
||||||
f.Lock()
|
|
||||||
defer f.Unlock()
|
|
||||||
if err := f.FakePodControl.CreatePodsOnNode(nodeName, namespace, template, object, controllerRef); err != nil {
|
|
||||||
return fmt.Errorf("failed to create pod on node %q", nodeName)
|
|
||||||
}
|
|
||||||
|
|
||||||
pod := &v1.Pod{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Labels: template.Labels,
|
|
||||||
Namespace: namespace,
|
|
||||||
GenerateName: fmt.Sprintf("%s-", nodeName),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
template.Spec.DeepCopyInto(&pod.Spec)
|
|
||||||
if len(nodeName) != 0 {
|
|
||||||
pod.Spec.NodeName = nodeName
|
|
||||||
}
|
|
||||||
pod.Name = names.SimpleNameGenerator.GenerateName(fmt.Sprintf("%s-", nodeName))
|
|
||||||
|
|
||||||
f.podStore.Update(pod)
|
|
||||||
f.podIDMap[pod.Name] = pod
|
|
||||||
|
|
||||||
ds := object.(*apps.DaemonSet)
|
|
||||||
dsKey, _ := controller.KeyFunc(ds)
|
|
||||||
f.expectations.CreationObserved(dsKey)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *fakePodControl) CreatePodsWithControllerRef(namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error {
|
func (f *fakePodControl) CreatePodsWithControllerRef(namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error {
|
||||||
f.Lock()
|
f.Lock()
|
||||||
defer f.Unlock()
|
defer f.Unlock()
|
||||||
|
@ -342,11 +342,6 @@ func (pc podControlAdapter) CreatePods(namespace string, template *v1.PodTemplat
|
|||||||
return errors.New("CreatePods() is not implemented for podControlAdapter")
|
return errors.New("CreatePods() is not implemented for podControlAdapter")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pc podControlAdapter) CreatePodsOnNode(nodeName, namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error {
|
|
||||||
// This is not used by RSC.
|
|
||||||
return errors.New("CreatePodsOnNode() is not implemented for podControlAdapter")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pc podControlAdapter) CreatePodsWithControllerRef(namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error {
|
func (pc podControlAdapter) CreatePodsWithControllerRef(namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error {
|
||||||
rc, err := convertRStoRC(object.(*apps.ReplicaSet))
|
rc, err := convertRStoRC(object.(*apps.ReplicaSet))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user