mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-17 15:13:08 +00:00
Merge pull request #2788 from smarterclayton/roundtrip_node_nodelist
Rename Minions -> Nodes internally
This commit is contained in:
@@ -60,7 +60,7 @@ type REST struct {
|
||||
podInfoGetter client.PodInfoGetter
|
||||
podPollPeriod time.Duration
|
||||
registry Registry
|
||||
minions client.MinionInterface
|
||||
nodes client.NodeInterface
|
||||
ipCache ipCache
|
||||
clock clock
|
||||
}
|
||||
@@ -70,7 +70,7 @@ type RESTConfig struct {
|
||||
PodCache client.PodInfoGetter
|
||||
PodInfoGetter client.PodInfoGetter
|
||||
Registry Registry
|
||||
Minions client.MinionInterface
|
||||
Nodes client.NodeInterface
|
||||
}
|
||||
|
||||
// NewREST returns a new REST.
|
||||
@@ -81,7 +81,7 @@ func NewREST(config *RESTConfig) *REST {
|
||||
podInfoGetter: config.PodInfoGetter,
|
||||
podPollPeriod: time.Second * 10,
|
||||
registry: config.Registry,
|
||||
minions: config.Minions,
|
||||
nodes: config.Nodes,
|
||||
ipCache: ipCache{},
|
||||
clock: realClock{},
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
|
||||
}
|
||||
if rs.podCache != nil || rs.podInfoGetter != nil {
|
||||
rs.fillPodInfo(pod)
|
||||
status, err := getPodStatus(pod, rs.minions)
|
||||
status, err := getPodStatus(pod, rs.nodes)
|
||||
if err != nil {
|
||||
return pod, err
|
||||
}
|
||||
@@ -169,7 +169,7 @@ func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Obj
|
||||
for i := range pods.Items {
|
||||
pod := &pods.Items[i]
|
||||
rs.fillPodInfo(pod)
|
||||
status, err := getPodStatus(pod, rs.minions)
|
||||
status, err := getPodStatus(pod, rs.nodes)
|
||||
if err != nil {
|
||||
return pod, err
|
||||
}
|
||||
@@ -275,26 +275,19 @@ func getInstanceIPFromCloud(cloud cloudprovider.Interface, host string) string {
|
||||
return addr.String()
|
||||
}
|
||||
|
||||
func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodPhase, error) {
|
||||
func getPodStatus(pod *api.Pod, nodes client.NodeInterface) (api.PodPhase, error) {
|
||||
if pod.Status.Host == "" {
|
||||
return api.PodPending, nil
|
||||
}
|
||||
if minions != nil {
|
||||
res, err := minions.List()
|
||||
if nodes != nil {
|
||||
_, err := nodes.Get(pod.Status.Host)
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
return api.PodFailed, nil
|
||||
}
|
||||
glog.Errorf("Error listing minions: %v", err)
|
||||
return "", err
|
||||
}
|
||||
found := false
|
||||
for _, minion := range res.Items {
|
||||
if minion.Name == pod.Status.Host {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return api.PodFailed, nil
|
||||
}
|
||||
} else {
|
||||
glog.Errorf("Unexpected missing minion interface, status may be in-accurate")
|
||||
}
|
||||
|
@@ -370,8 +370,8 @@ func TestGetPodCloud(t *testing.T) {
|
||||
|
||||
func TestMakePodStatus(t *testing.T) {
|
||||
fakeClient := client.Fake{
|
||||
MinionsList: api.MinionList{
|
||||
Items: []api.Minion{
|
||||
MinionsList: api.NodeList{
|
||||
Items: []api.Node{
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "machine"},
|
||||
},
|
||||
@@ -499,7 +499,7 @@ func TestMakePodStatus(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
if status, err := getPodStatus(test.pod, fakeClient.Minions()); status != test.status {
|
||||
if status, err := getPodStatus(test.pod, fakeClient.Nodes()); status != test.status {
|
||||
t.Errorf("In test %s, expected %v, got %v", test.test, test.status, status)
|
||||
if err != nil {
|
||||
t.Errorf("In test %s, unexpected error: %v", test.test, err)
|
||||
|
Reference in New Issue
Block a user