Merge pull request #5205 from fgrzadkowski/sync_pod_status

Periodically update pod status from kubelet.
This commit is contained in:
Victor Marmol
2015-03-16 17:04:31 -07:00
11 changed files with 116 additions and 38 deletions

View File

@@ -39,6 +39,7 @@ type PodInterface interface {
Update(pod *api.Pod) (*api.Pod, error)
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
Bind(binding *api.Binding) error
UpdateStatus(name string, status *api.PodStatus) (*api.Pod, error)
}
// pods implements PodsNamespacer interface
@@ -62,7 +63,7 @@ func (c *pods) List(selector labels.Selector) (result *api.PodList, err error) {
return
}
// GetPod takes the name of the pod, and returns the corresponding Pod object, and an error if it occurs
// Get takes the name of the pod, and returns the corresponding Pod object, and an error if it occurs
func (c *pods) Get(name string) (result *api.Pod, err error) {
if len(name) == 0 {
return nil, errors.New("name is required parameter to Get")
@@ -73,19 +74,19 @@ func (c *pods) Get(name string) (result *api.Pod, err error) {
return
}
// DeletePod takes the name of the pod, and returns an error if one occurs
// Delete takes the name of the pod, and returns an error if one occurs
func (c *pods) Delete(name string) error {
return c.r.Delete().Namespace(c.ns).Resource("pods").Name(name).Do().Error()
}
// CreatePod takes the representation of a pod. Returns the server's representation of the pod, and an error, if it occurs.
// Create takes the representation of a pod. Returns the server's representation of the pod, and an error, if it occurs.
func (c *pods) Create(pod *api.Pod) (result *api.Pod, err error) {
result = &api.Pod{}
err = c.r.Post().Namespace(c.ns).Resource("pods").Body(pod).Do().Into(result)
return
}
// UpdatePod takes the representation of a pod to update. Returns the server's representation of the pod, and an error, if it occurs.
// Update takes the representation of a pod to update. Returns the server's representation of the pod, and an error, if it occurs.
func (c *pods) Update(pod *api.Pod) (result *api.Pod, err error) {
result = &api.Pod{}
if len(pod.ResourceVersion) == 0 {
@@ -112,3 +113,15 @@ func (c *pods) Watch(label, field labels.Selector, resourceVersion string) (watc
func (c *pods) Bind(binding *api.Binding) error {
return c.r.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).SubResource("binding").Body(binding).Do().Error()
}
// UpdateStatus takes the name of the pod and the new status. Returns the server's representation of the pod, and an error, if it occurs.
func (c *pods) UpdateStatus(name string, newStatus *api.PodStatus) (result *api.Pod, err error) {
result = &api.Pod{}
pod, err := c.Get(name)
if err != nil {
return
}
pod.Status = *newStatus
err = c.r.Put().Namespace(c.ns).Resource("pods").Name(pod.Name).SubResource("status").Body(pod).Do().Into(result)
return
}