-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove BoundPods from Kubelet #5433
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,12 +39,8 @@ func init() { | |
*out = *in.Copy() | ||
return nil | ||
}, | ||
// Convert ContainerManifest to BoundPod | ||
// | ||
// This function generates a dummy selfLink using the same method as the | ||
// boundPod registry, in order for the Kubelet to work with well-formed | ||
// boundPods during the integration test. | ||
func(in *ContainerManifest, out *BoundPod, s conversion.Scope) error { | ||
// Convert ContainerManifest to Pod | ||
func(in *ContainerManifest, out *Pod, s conversion.Scope) error { | ||
out.Spec.Containers = in.Containers | ||
out.Spec.Volumes = in.Volumes | ||
out.Spec.RestartPolicy = in.RestartPolicy | ||
|
@@ -53,12 +49,12 @@ func init() { | |
out.UID = in.UUID | ||
|
||
if in.ID != "" { | ||
out.SelfLink = "/api/v1beta1/boundPods/" + in.ID | ||
out.SelfLink = "/api/v1beta1/pods/" + in.ID | ||
} | ||
|
||
return nil | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm actually these shouldn't change. Bad search replace? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this shouldn't change? [I thought it should be changed] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an apiserver endpoint, the other is a Kubelet endpoint. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I though that it's an apiserver endpoint, but still - I didn't found /boundPods handler in apiserver. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I asked @yujuhong and she verified it should be "pods", sorry for the churn. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for verifying! |
||
func(in *BoundPod, out *ContainerManifest, s conversion.Scope) error { | ||
func(in *Pod, out *ContainerManifest, s conversion.Scope) error { | ||
out.Containers = in.Spec.Containers | ||
out.Volumes = in.Spec.Volumes | ||
out.RestartPolicy = in.Spec.RestartPolicy | ||
|
@@ -70,7 +66,7 @@ func init() { | |
}, | ||
|
||
// ContainerManifestList | ||
func(in *ContainerManifestList, out *BoundPods, s conversion.Scope) error { | ||
func(in *ContainerManifestList, out *PodList, s conversion.Scope) error { | ||
if err := s.Convert(&in.Items, &out.Items, 0); err != nil { | ||
return err | ||
} | ||
|
@@ -80,7 +76,7 @@ func init() { | |
} | ||
return nil | ||
}, | ||
func(in *BoundPods, out *ContainerManifestList, s conversion.Scope) error { | ||
func(in *PodList, out *ContainerManifestList, s conversion.Scope) error { | ||
if err := s.Convert(&in.Items, &out.Items, 0); err != nil { | ||
return err | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1079,7 +1079,7 @@ type BoundPods struct { | |
Host string `json:"host" description:"name of a node that these pods were bound to"` | ||
|
||
// Items is the list of all pods bound to a given host. | ||
Items []BoundPod `json:"items" description:"list of all pods bound to a given host"` | ||
Items []Pod `json:"items" description:"list of all pods bound to a given host"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if it is okay to redefine v1beta1. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess no endpoints use it, so this is ok. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes - in fact in #5502 I'm removing BoundPods struct completely. |
||
} | ||
|
||
// List holds a list of objects, which may not be known by the server. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,7 @@ func (c *PodConfig) Sync() { | |
type podStorage struct { | ||
podLock sync.RWMutex | ||
// map of source name to pod name to pod reference | ||
pods map[string]map[string]*api.BoundPod | ||
pods map[string]map[string]*api.Pod | ||
mode PodConfigNotificationMode | ||
|
||
// ensures that updates are delivered in strict order | ||
|
@@ -134,7 +134,7 @@ type podStorage struct { | |
// TODO: allow initialization of the current state of the store with snapshotted version. | ||
func newPodStorage(updates chan<- kubelet.PodUpdate, mode PodConfigNotificationMode, recorder record.EventRecorder) *podStorage { | ||
return &podStorage{ | ||
pods: make(map[string]map[string]*api.BoundPod), | ||
pods: make(map[string]map[string]*api.Pod), | ||
mode: mode, | ||
updates: updates, | ||
sourcesSeen: util.StringSet{}, | ||
|
@@ -169,12 +169,12 @@ func (s *podStorage) Merge(source string, change interface{}) error { | |
s.updates <- *updates | ||
} | ||
if len(deletes.Pods) > 0 || len(adds.Pods) > 0 { | ||
s.updates <- kubelet.PodUpdate{s.MergedState().([]api.BoundPod), kubelet.SET, source} | ||
s.updates <- kubelet.PodUpdate{s.MergedState().([]api.Pod), kubelet.SET, source} | ||
} | ||
|
||
case PodConfigNotificationSnapshot: | ||
if len(updates.Pods) > 0 || len(deletes.Pods) > 0 || len(adds.Pods) > 0 { | ||
s.updates <- kubelet.PodUpdate{s.MergedState().([]api.BoundPod), kubelet.SET, source} | ||
s.updates <- kubelet.PodUpdate{s.MergedState().([]api.Pod), kubelet.SET, source} | ||
} | ||
|
||
default: | ||
|
@@ -194,7 +194,7 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de | |
|
||
pods := s.pods[source] | ||
if pods == nil { | ||
pods = make(map[string]*api.BoundPod) | ||
pods = make(map[string]*api.Pod) | ||
} | ||
|
||
update := change.(kubelet.PodUpdate) | ||
|
@@ -246,7 +246,7 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de | |
s.markSourceSet(source) | ||
// Clear the old map entries by just creating a new map | ||
oldPods := pods | ||
pods = make(map[string]*api.BoundPod) | ||
pods = make(map[string]*api.Pod) | ||
|
||
filtered := filterInvalidPods(update.Pods, source, s.recorder) | ||
for _, ref := range filtered { | ||
|
@@ -298,12 +298,12 @@ func (s *podStorage) seenSources(sources ...string) bool { | |
return s.sourcesSeen.HasAll(sources...) | ||
} | ||
|
||
func filterInvalidPods(pods []api.BoundPod, source string, recorder record.EventRecorder) (filtered []*api.BoundPod) { | ||
func filterInvalidPods(pods []api.Pod, source string, recorder record.EventRecorder) (filtered []*api.Pod) { | ||
names := util.StringSet{} | ||
for i := range pods { | ||
pod := &pods[i] | ||
var errlist []error | ||
if errs := validation.ValidateBoundPod(pod); len(errs) != 0 { | ||
if errs := validation.ValidatePod(pod); len(errs) != 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there are any checks that are being added here as a result of this change, which might cause problems for e.g. ContainerVM? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ValidatePod (at least currently) is validating only:
|
||
errlist = append(errlist, errs...) | ||
// If validation fails, don't trust it any further - | ||
// even Name could be bad. | ||
|
@@ -331,27 +331,27 @@ func filterInvalidPods(pods []api.BoundPod, source string, recorder record.Event | |
func (s *podStorage) Sync() { | ||
s.updateLock.Lock() | ||
defer s.updateLock.Unlock() | ||
s.updates <- kubelet.PodUpdate{s.MergedState().([]api.BoundPod), kubelet.SET, kubelet.AllSource} | ||
s.updates <- kubelet.PodUpdate{s.MergedState().([]api.Pod), kubelet.SET, kubelet.AllSource} | ||
} | ||
|
||
// Object implements config.Accessor | ||
func (s *podStorage) MergedState() interface{} { | ||
s.podLock.RLock() | ||
defer s.podLock.RUnlock() | ||
pods := make([]api.BoundPod, 0) | ||
pods := make([]api.Pod, 0) | ||
for _, sourcePods := range s.pods { | ||
for _, podRef := range sourcePods { | ||
pod, err := api.Scheme.Copy(podRef) | ||
if err != nil { | ||
glog.Errorf("unable to copy pod: %v", err) | ||
} | ||
pods = append(pods, *pod.(*api.BoundPod)) | ||
pods = append(pods, *pod.(*api.Pod)) | ||
} | ||
} | ||
return pods | ||
} | ||
|
||
func bestPodIdentString(pod *api.BoundPod) string { | ||
func bestPodIdentString(pod *api.Pod) string { | ||
namespace := pod.Namespace | ||
if namespace == "" { | ||
namespace = "<empty-namespace>" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out.SelfLink = "/api/v1beta1/boundPods/" + in.ID
needs to be changed too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.