Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
f4cffdc7
Commit
f4cffdc7
authored
Nov 05, 2014
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2179 from markturansky/v1beta3_refactor_podcontants
Refactor PodStatus to PodCondition in internal API for v1beta3
parents
0420005a
119f654a
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
139 additions
and
46 deletions
+139
-46
latest_test.go
pkg/api/latest/latest_test.go
+6
-2
serialization_test.go
pkg/api/serialization_test.go
+6
-2
types.go
pkg/api/types.go
+16
-9
conversion.go
pkg/api/v1beta1/conversion.go
+38
-0
conversion.go
pkg/api/v1beta2/conversion.go
+38
-1
types.go
pkg/api/v1beta3/types.go
+2
-2
client_test.go
pkg/client/client_test.go
+5
-5
replication_controller.go
pkg/controller/replication_controller.go
+2
-1
describe.go
pkg/kubectl/describe.go
+8
-6
etcd.go
pkg/registry/etcd/etcd.go
+1
-1
rest.go
pkg/registry/pod/rest.go
+7
-7
rest_test.go
pkg/registry/pod/rest_test.go
+7
-7
scheduler.go
plugin/pkg/scheduler/scheduler.go
+3
-3
No files found.
pkg/api/latest/latest_test.go
View file @
f4cffdc7
...
@@ -26,8 +26,8 @@ import (
...
@@ -26,8 +26,8 @@ import (
_
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
_
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
_
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
_
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
"github.com/google/gofuzz"
fuzz
"github.com/google/gofuzz"
)
)
// apiObjectFuzzer can randomly populate api objects.
// apiObjectFuzzer can randomly populate api objects.
...
@@ -71,6 +71,10 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
...
@@ -71,6 +71,10 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
j
.
ResourceVersion
=
strconv
.
FormatUint
(
c
.
RandUint64
()
>>
8
,
10
)
j
.
ResourceVersion
=
strconv
.
FormatUint
(
c
.
RandUint64
()
>>
8
,
10
)
j
.
FieldPath
=
c
.
RandString
()
j
.
FieldPath
=
c
.
RandString
()
},
},
func
(
j
*
internal
.
PodCondition
,
c
fuzz
.
Continue
)
{
statuses
:=
[]
internal
.
PodCondition
{
internal
.
PodPending
,
internal
.
PodRunning
,
internal
.
PodFailed
}
*
j
=
statuses
[
c
.
Rand
.
Intn
(
len
(
statuses
))]
},
func
(
intstr
*
util
.
IntOrString
,
c
fuzz
.
Continue
)
{
func
(
intstr
*
util
.
IntOrString
,
c
fuzz
.
Continue
)
{
// util.IntOrString will panic if its kind is set wrong.
// util.IntOrString will panic if its kind is set wrong.
if
c
.
RandBool
()
{
if
c
.
RandBool
()
{
...
...
pkg/api/serialization_test.go
View file @
f4cffdc7
...
@@ -31,8 +31,8 @@ import (
...
@@ -31,8 +31,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
"github.com/google/gofuzz"
fuzz
"github.com/google/gofuzz"
)
)
var
fuzzIters
=
flag
.
Int
(
"fuzz_iters"
,
40
,
"How many fuzzing iterations to do."
)
var
fuzzIters
=
flag
.
Int
(
"fuzz_iters"
,
40
,
"How many fuzzing iterations to do."
)
...
@@ -86,6 +86,10 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
...
@@ -86,6 +86,10 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
j
.
ResourceVersion
=
strconv
.
FormatUint
(
c
.
RandUint64
()
>>
8
,
10
)
j
.
ResourceVersion
=
strconv
.
FormatUint
(
c
.
RandUint64
()
>>
8
,
10
)
j
.
SelfLink
=
c
.
RandString
()
j
.
SelfLink
=
c
.
RandString
()
},
},
func
(
j
*
api
.
PodCondition
,
c
fuzz
.
Continue
)
{
statuses
:=
[]
api
.
PodCondition
{
api
.
PodPending
,
api
.
PodRunning
,
api
.
PodFailed
}
*
j
=
statuses
[
c
.
Rand
.
Intn
(
len
(
statuses
))]
},
func
(
intstr
*
util
.
IntOrString
,
c
fuzz
.
Continue
)
{
func
(
intstr
*
util
.
IntOrString
,
c
fuzz
.
Continue
)
{
// util.IntOrString will panic if its kind is set wrong.
// util.IntOrString will panic if its kind is set wrong.
if
c
.
RandBool
()
{
if
c
.
RandBool
()
{
...
...
pkg/api/types.go
View file @
f4cffdc7
...
@@ -331,17 +331,24 @@ type Lifecycle struct {
...
@@ -331,17 +331,24 @@ type Lifecycle struct {
// The below types are used by kube_client and api_server.
// The below types are used by kube_client and api_server.
// Pod
Status represents a status of a pod
.
// Pod
Condition is a label for the condition of a pod at the current time
.
type
Pod
Status
string
type
Pod
Condition
string
// These are the valid statuses of pods.
// These are the valid statuses of pods.
const
(
const
(
// PodWaiting means that we're waiting for the pod to begin running.
// PodPending means the pod has been accepted by the system, but one or more of the containers
PodWaiting
PodStatus
=
"Waiting"
// has not been started. This includes time before being bound to a node, as well as time spent
// PodRunning means that the pod is up and running.
// pulling images onto the host.
PodRunning
PodStatus
=
"Running"
PodPending
PodCondition
=
"Pending"
// PodTerminated means that the pod has stopped.
// PodRunning means the pod has been bound to a node and all of the containers have been started.
PodTerminated
PodStatus
=
"Terminated"
// At least one container is still running or is in the process of being restarted.
PodRunning
PodCondition
=
"Running"
// PodSucceeded means that all containers in the pod have voluntarily terminated
// with a container exit code of 0, and the system is not going to restart any of these containers.
PodSucceeded
PodCondition
=
"Succeeded"
// PodFailed means that all containers in the pod have terminated, and at least one container has
// terminated in a failure (exited with a non-zero exit code or was stopped by the system).
PodFailed
PodCondition
=
"Failed"
)
)
type
ContainerStateWaiting
struct
{
type
ContainerStateWaiting
struct
{
...
@@ -408,7 +415,7 @@ type RestartPolicy struct {
...
@@ -408,7 +415,7 @@ type RestartPolicy struct {
// PodState is the state of a pod, used as either input (desired state) or output (current state).
// PodState is the state of a pod, used as either input (desired state) or output (current state).
type
PodState
struct
{
type
PodState
struct
{
Manifest
ContainerManifest
`json:"manifest,omitempty" yaml:"manifest,omitempty"`
Manifest
ContainerManifest
`json:"manifest,omitempty" yaml:"manifest,omitempty"`
Status
Pod
Status
`json:"status,omitempty" yaml:"status,omitempty"`
Status
Pod
Condition
`json:"status,omitempty" yaml:"status,omitempty"`
Host
string
`json:"host,omitempty" yaml:"host,omitempty"`
Host
string
`json:"host,omitempty" yaml:"host,omitempty"`
HostIP
string
`json:"hostIP,omitempty" yaml:"hostIP,omitempty"`
HostIP
string
`json:"hostIP,omitempty" yaml:"hostIP,omitempty"`
PodIP
string
`json:"podIP,omitempty" yaml:"podIP,omitempty"`
PodIP
string
`json:"podIP,omitempty" yaml:"podIP,omitempty"`
...
...
pkg/api/v1beta1/conversion.go
View file @
f4cffdc7
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
v1beta1
package
v1beta1
import
(
import
(
"errors"
"strconv"
"strconv"
newer
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
newer
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -159,6 +160,43 @@ func init() {
...
@@ -159,6 +160,43 @@ func init() {
return
nil
return
nil
},
},
// Convert all to the new PodCondition constants
func
(
in
*
newer
.
PodCondition
,
out
*
PodStatus
,
s
conversion
.
Scope
)
error
{
switch
*
in
{
case
""
:
*
out
=
""
case
newer
.
PodPending
:
*
out
=
PodWaiting
case
newer
.
PodRunning
:
*
out
=
PodRunning
case
newer
.
PodSucceeded
:
*
out
=
PodTerminated
case
newer
.
PodFailed
:
*
out
=
PodTerminated
default
:
return
errors
.
New
(
"The string provided is not a valid PodCondition constant value"
)
}
return
nil
},
func
(
in
*
PodStatus
,
out
*
newer
.
PodCondition
,
s
conversion
.
Scope
)
error
{
switch
*
in
{
case
""
:
*
out
=
""
case
PodWaiting
:
*
out
=
newer
.
PodPending
case
PodRunning
:
*
out
=
newer
.
PodRunning
case
PodTerminated
:
// Older API versions did not contain enough info to map to PodFailed
*
out
=
newer
.
PodFailed
default
:
return
errors
.
New
(
"The string provided is not a valid PodCondition constant value"
)
}
return
nil
},
// Convert all the standard objects
// Convert all the standard objects
func
(
in
*
newer
.
Pod
,
out
*
Pod
,
s
conversion
.
Scope
)
error
{
func
(
in
*
newer
.
Pod
,
out
*
Pod
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
...
...
pkg/api/v1beta2/conversion.go
View file @
f4cffdc7
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
v1beta2
package
v1beta2
import
(
import
(
"errors"
"strconv"
"strconv"
newer
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
newer
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -89,7 +90,43 @@ func init() {
...
@@ -89,7 +90,43 @@ func init() {
return
s
.
Convert
(
&
in
.
Annotations
,
&
out
.
Annotations
,
0
)
return
s
.
Convert
(
&
in
.
Annotations
,
&
out
.
Annotations
,
0
)
},
},
// Convert all the standard objects
// Convert all to the new PodCondition constants
func
(
in
*
newer
.
PodCondition
,
out
*
PodStatus
,
s
conversion
.
Scope
)
error
{
switch
*
in
{
case
""
:
*
out
=
""
case
newer
.
PodPending
:
*
out
=
PodWaiting
case
newer
.
PodRunning
:
*
out
=
PodRunning
case
newer
.
PodSucceeded
:
*
out
=
PodTerminated
case
newer
.
PodFailed
:
*
out
=
PodTerminated
default
:
return
errors
.
New
(
"The string provided is not a valid PodCondition constant value"
)
}
return
nil
},
func
(
in
*
PodStatus
,
out
*
newer
.
PodCondition
,
s
conversion
.
Scope
)
error
{
switch
*
in
{
case
""
:
*
out
=
""
case
PodWaiting
:
*
out
=
newer
.
PodPending
case
PodRunning
:
*
out
=
newer
.
PodRunning
case
PodTerminated
:
// Older API versions did not contain enough info to map to PodFailed
*
out
=
newer
.
PodFailed
default
:
return
errors
.
New
(
"The string provided is not a valid PodCondition constant value"
)
}
return
nil
},
// Convert all the standard objects
// Convert all the standard objects
func
(
in
*
newer
.
Pod
,
out
*
Pod
,
s
conversion
.
Scope
)
error
{
func
(
in
*
newer
.
Pod
,
out
*
Pod
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
...
...
pkg/api/v1beta3/types.go
View file @
f4cffdc7
...
@@ -374,8 +374,8 @@ const (
...
@@ -374,8 +374,8 @@ const (
// PodRunning means the pod has been bound to a node and all of the containers have been started.
// PodRunning means the pod has been bound to a node and all of the containers have been started.
// At least one container is still running or is in the process of being restarted.
// At least one container is still running or is in the process of being restarted.
PodRunning
PodCondition
=
"Running"
PodRunning
PodCondition
=
"Running"
// PodSucceeded means that all containers in the pod have voluntarily terminated
with a container
// PodSucceeded means that all containers in the pod have voluntarily terminated
//
exit code of 0
.
//
with a container exit code of 0, and the system is not going to restart any of these containers
.
PodSucceeded
PodCondition
=
"Succeeded"
PodSucceeded
PodCondition
=
"Succeeded"
// PodFailed means that all containers in the pod have terminated, and at least one container has
// PodFailed means that all containers in the pod have terminated, and at least one container has
// terminated in a failure (exited with a non-zero exit code or was stopped by the system).
// terminated in a failure (exited with a non-zero exit code or was stopped by the system).
...
...
pkg/client/client_test.go
View file @
f4cffdc7
...
@@ -165,7 +165,7 @@ func TestListPods(t *testing.T) {
...
@@ -165,7 +165,7 @@ func TestListPods(t *testing.T) {
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
{
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
Status
:
"Foobar"
,
Status
:
api
.
PodRunning
,
},
},
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
...
@@ -198,7 +198,7 @@ func TestListPodsLabels(t *testing.T) {
...
@@ -198,7 +198,7 @@ func TestListPodsLabels(t *testing.T) {
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
{
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
Status
:
"Foobar"
,
Status
:
api
.
PodRunning
,
},
},
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
...
@@ -226,7 +226,7 @@ func TestGetPod(t *testing.T) {
...
@@ -226,7 +226,7 @@ func TestGetPod(t *testing.T) {
StatusCode
:
200
,
StatusCode
:
200
,
Body
:
&
api
.
Pod
{
Body
:
&
api
.
Pod
{
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
Status
:
"Foobar"
,
Status
:
api
.
PodRunning
,
},
},
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
...
@@ -253,7 +253,7 @@ func TestDeletePod(t *testing.T) {
...
@@ -253,7 +253,7 @@ func TestDeletePod(t *testing.T) {
func
TestCreatePod
(
t
*
testing
.
T
)
{
func
TestCreatePod
(
t
*
testing
.
T
)
{
requestPod
:=
&
api
.
Pod
{
requestPod
:=
&
api
.
Pod
{
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
Status
:
"Foobar"
,
Status
:
api
.
PodRunning
,
},
},
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
...
@@ -284,7 +284,7 @@ func TestUpdatePod(t *testing.T) {
...
@@ -284,7 +284,7 @@ func TestUpdatePod(t *testing.T) {
},
},
},
},
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
Status
:
"Foobar"
,
Status
:
api
.
PodRunning
,
},
},
}
}
c
:=
&
testClient
{
c
:=
&
testClient
{
...
...
pkg/controller/replication_controller.go
View file @
f4cffdc7
...
@@ -134,7 +134,8 @@ func (rm *ReplicationManager) watchControllers(resourceVersion *string) {
...
@@ -134,7 +134,8 @@ func (rm *ReplicationManager) watchControllers(resourceVersion *string) {
func
(
rm
*
ReplicationManager
)
filterActivePods
(
pods
[]
api
.
Pod
)
[]
api
.
Pod
{
func
(
rm
*
ReplicationManager
)
filterActivePods
(
pods
[]
api
.
Pod
)
[]
api
.
Pod
{
var
result
[]
api
.
Pod
var
result
[]
api
.
Pod
for
_
,
value
:=
range
pods
{
for
_
,
value
:=
range
pods
{
if
api
.
PodTerminated
!=
value
.
CurrentState
.
Status
{
if
api
.
PodSucceeded
!=
value
.
CurrentState
.
Status
&&
api
.
PodFailed
!=
value
.
CurrentState
.
Status
{
result
=
append
(
result
,
value
)
result
=
append
(
result
,
value
)
}
}
}
}
...
...
pkg/kubectl/describe.go
View file @
f4cffdc7
...
@@ -120,7 +120,7 @@ func (d *ReplicationControllerDescriber) Describe(namespace, name string) (strin
...
@@ -120,7 +120,7 @@ func (d *ReplicationControllerDescriber) Describe(namespace, name string) (strin
return
""
,
err
return
""
,
err
}
}
running
,
waiting
,
terminat
ed
,
err
:=
getPodStatusForReplicationController
(
pc
,
controller
)
running
,
waiting
,
succeeded
,
fail
ed
,
err
:=
getPodStatusForReplicationController
(
pc
,
controller
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -131,7 +131,7 @@ func (d *ReplicationControllerDescriber) Describe(namespace, name string) (strin
...
@@ -131,7 +131,7 @@ func (d *ReplicationControllerDescriber) Describe(namespace, name string) (strin
fmt
.
Fprintf
(
out
,
"Selector:
\t
%s
\n
"
,
formatLabels
(
controller
.
DesiredState
.
ReplicaSelector
))
fmt
.
Fprintf
(
out
,
"Selector:
\t
%s
\n
"
,
formatLabels
(
controller
.
DesiredState
.
ReplicaSelector
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
formatLabels
(
controller
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
formatLabels
(
controller
.
Labels
))
fmt
.
Fprintf
(
out
,
"Replicas:
\t
%d current / %d desired
\n
"
,
controller
.
CurrentState
.
Replicas
,
controller
.
DesiredState
.
Replicas
)
fmt
.
Fprintf
(
out
,
"Replicas:
\t
%d current / %d desired
\n
"
,
controller
.
CurrentState
.
Replicas
,
controller
.
DesiredState
.
Replicas
)
fmt
.
Fprintf
(
out
,
"Pods Status:
\t
%d Running / %d Waiting / %d
Terminated
\n
"
,
running
,
waiting
,
terminat
ed
)
fmt
.
Fprintf
(
out
,
"Pods Status:
\t
%d Running / %d Waiting / %d
Succeeded / %d Failed
\n
"
,
running
,
waiting
,
succeeded
,
fail
ed
)
return
nil
return
nil
})
})
}
}
...
@@ -216,7 +216,7 @@ func getReplicationControllersForLabels(c client.ReplicationControllerInterface,
...
@@ -216,7 +216,7 @@ func getReplicationControllersForLabels(c client.ReplicationControllerInterface,
return
list
return
list
}
}
func
getPodStatusForReplicationController
(
c
client
.
PodInterface
,
controller
*
api
.
ReplicationController
)
(
running
,
waiting
,
terminat
ed
int
,
err
error
)
{
func
getPodStatusForReplicationController
(
c
client
.
PodInterface
,
controller
*
api
.
ReplicationController
)
(
running
,
waiting
,
succeeded
,
fail
ed
int
,
err
error
)
{
rcPods
,
err
:=
c
.
List
(
labels
.
SelectorFromSet
(
controller
.
DesiredState
.
ReplicaSelector
))
rcPods
,
err
:=
c
.
List
(
labels
.
SelectorFromSet
(
controller
.
DesiredState
.
ReplicaSelector
))
if
err
!=
nil
{
if
err
!=
nil
{
return
return
...
@@ -224,10 +224,12 @@ func getPodStatusForReplicationController(c client.PodInterface, controller *api
...
@@ -224,10 +224,12 @@ func getPodStatusForReplicationController(c client.PodInterface, controller *api
for
_
,
pod
:=
range
rcPods
.
Items
{
for
_
,
pod
:=
range
rcPods
.
Items
{
if
pod
.
CurrentState
.
Status
==
api
.
PodRunning
{
if
pod
.
CurrentState
.
Status
==
api
.
PodRunning
{
running
++
running
++
}
else
if
pod
.
CurrentState
.
Status
==
api
.
Pod
Wait
ing
{
}
else
if
pod
.
CurrentState
.
Status
==
api
.
Pod
Pend
ing
{
waiting
++
waiting
++
}
else
if
pod
.
CurrentState
.
Status
==
api
.
PodTerminated
{
}
else
if
pod
.
CurrentState
.
Status
==
api
.
PodSucceeded
{
terminated
++
succeeded
++
}
else
if
pod
.
CurrentState
.
Status
==
api
.
PodFailed
{
failed
++
}
}
}
}
return
return
...
...
pkg/registry/etcd/etcd.go
View file @
f4cffdc7
...
@@ -183,7 +183,7 @@ func makeContainerKey(machine string) string {
...
@@ -183,7 +183,7 @@ func makeContainerKey(machine string) string {
// CreatePod creates a pod based on a specification.
// CreatePod creates a pod based on a specification.
func
(
r
*
Registry
)
CreatePod
(
ctx
api
.
Context
,
pod
*
api
.
Pod
)
error
{
func
(
r
*
Registry
)
CreatePod
(
ctx
api
.
Context
,
pod
*
api
.
Pod
)
error
{
// Set current status to "Waiting".
// Set current status to "Waiting".
pod
.
CurrentState
.
Status
=
api
.
Pod
Wait
ing
pod
.
CurrentState
.
Status
=
api
.
Pod
Pend
ing
pod
.
CurrentState
.
Host
=
""
pod
.
CurrentState
.
Host
=
""
// DesiredState.Host == "" is a signal to the scheduler that this pod needs scheduling.
// DesiredState.Host == "" is a signal to the scheduler that this pod needs scheduling.
pod
.
DesiredState
.
Status
=
api
.
PodRunning
pod
.
DesiredState
.
Status
=
api
.
PodRunning
...
...
pkg/registry/pod/rest.go
View file @
f4cffdc7
...
@@ -267,9 +267,9 @@ func getInstanceIPFromCloud(cloud cloudprovider.Interface, host string) string {
...
@@ -267,9 +267,9 @@ func getInstanceIPFromCloud(cloud cloudprovider.Interface, host string) string {
return
addr
.
String
()
return
addr
.
String
()
}
}
func
getPodStatus
(
pod
*
api
.
Pod
,
minions
client
.
MinionInterface
)
(
api
.
Pod
Status
,
error
)
{
func
getPodStatus
(
pod
*
api
.
Pod
,
minions
client
.
MinionInterface
)
(
api
.
Pod
Condition
,
error
)
{
if
pod
.
CurrentState
.
Host
==
""
{
if
pod
.
CurrentState
.
Host
==
""
{
return
api
.
Pod
Wait
ing
,
nil
return
api
.
Pod
Pend
ing
,
nil
}
}
if
minions
!=
nil
{
if
minions
!=
nil
{
res
,
err
:=
minions
.
List
()
res
,
err
:=
minions
.
List
()
...
@@ -285,13 +285,13 @@ func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodStatus,
...
@@ -285,13 +285,13 @@ func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodStatus,
}
}
}
}
if
!
found
{
if
!
found
{
return
api
.
Pod
Terminat
ed
,
nil
return
api
.
Pod
Fail
ed
,
nil
}
}
}
else
{
}
else
{
glog
.
Errorf
(
"Unexpected missing minion interface, status may be in-accurate"
)
glog
.
Errorf
(
"Unexpected missing minion interface, status may be in-accurate"
)
}
}
if
pod
.
CurrentState
.
Info
==
nil
{
if
pod
.
CurrentState
.
Info
==
nil
{
return
api
.
Pod
Wait
ing
,
nil
return
api
.
Pod
Pend
ing
,
nil
}
}
running
:=
0
running
:=
0
stopped
:=
0
stopped
:=
0
...
@@ -313,10 +313,10 @@ func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodStatus,
...
@@ -313,10 +313,10 @@ func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodStatus,
case
running
>
0
&&
unknown
==
0
:
case
running
>
0
&&
unknown
==
0
:
return
api
.
PodRunning
,
nil
return
api
.
PodRunning
,
nil
case
running
==
0
&&
stopped
>
0
&&
unknown
==
0
:
case
running
==
0
&&
stopped
>
0
&&
unknown
==
0
:
return
api
.
Pod
Terminat
ed
,
nil
return
api
.
Pod
Fail
ed
,
nil
case
running
==
0
&&
stopped
==
0
&&
unknown
>
0
:
case
running
==
0
&&
stopped
==
0
&&
unknown
>
0
:
return
api
.
Pod
Wait
ing
,
nil
return
api
.
Pod
Pend
ing
,
nil
default
:
default
:
return
api
.
Pod
Wait
ing
,
nil
return
api
.
Pod
Pend
ing
,
nil
}
}
}
}
pkg/registry/pod/rest_test.go
View file @
f4cffdc7
...
@@ -418,10 +418,10 @@ func TestMakePodStatus(t *testing.T) {
...
@@ -418,10 +418,10 @@ func TestMakePodStatus(t *testing.T) {
tests
:=
[]
struct
{
tests
:=
[]
struct
{
pod
*
api
.
Pod
pod
*
api
.
Pod
status
api
.
Pod
Status
status
api
.
Pod
Condition
test
string
test
string
}{
}{
{
&
api
.
Pod
{
DesiredState
:
desiredState
,
CurrentState
:
currentState
},
api
.
Pod
Wait
ing
,
"waiting"
},
{
&
api
.
Pod
{
DesiredState
:
desiredState
,
CurrentState
:
currentState
},
api
.
Pod
Pend
ing
,
"waiting"
},
{
{
&
api
.
Pod
{
&
api
.
Pod
{
DesiredState
:
desiredState
,
DesiredState
:
desiredState
,
...
@@ -429,7 +429,7 @@ func TestMakePodStatus(t *testing.T) {
...
@@ -429,7 +429,7 @@ func TestMakePodStatus(t *testing.T) {
Host
:
"machine-2"
,
Host
:
"machine-2"
,
},
},
},
},
api
.
Pod
Terminat
ed
,
api
.
Pod
Fail
ed
,
"no info, but bad machine"
,
"no info, but bad machine"
,
},
},
{
{
...
@@ -457,7 +457,7 @@ func TestMakePodStatus(t *testing.T) {
...
@@ -457,7 +457,7 @@ func TestMakePodStatus(t *testing.T) {
Host
:
"machine-two"
,
Host
:
"machine-two"
,
},
},
},
},
api
.
Pod
Terminat
ed
,
api
.
Pod
Fail
ed
,
"all running but minion is missing"
,
"all running but minion is missing"
,
},
},
{
{
...
@@ -471,7 +471,7 @@ func TestMakePodStatus(t *testing.T) {
...
@@ -471,7 +471,7 @@ func TestMakePodStatus(t *testing.T) {
Host
:
"machine"
,
Host
:
"machine"
,
},
},
},
},
api
.
Pod
Terminat
ed
,
api
.
Pod
Fail
ed
,
"all stopped"
,
"all stopped"
,
},
},
{
{
...
@@ -485,7 +485,7 @@ func TestMakePodStatus(t *testing.T) {
...
@@ -485,7 +485,7 @@ func TestMakePodStatus(t *testing.T) {
Host
:
"machine-two"
,
Host
:
"machine-two"
,
},
},
},
},
api
.
Pod
Terminat
ed
,
api
.
Pod
Fail
ed
,
"all stopped but minion missing"
,
"all stopped but minion missing"
,
},
},
{
{
...
@@ -512,7 +512,7 @@ func TestMakePodStatus(t *testing.T) {
...
@@ -512,7 +512,7 @@ func TestMakePodStatus(t *testing.T) {
Host
:
"machine"
,
Host
:
"machine"
,
},
},
},
},
api
.
Pod
Wait
ing
,
api
.
Pod
Pend
ing
,
"mixed state #2"
,
"mixed state #2"
,
},
},
}
}
...
...
plugin/pkg/scheduler/scheduler.go
View file @
f4cffdc7
...
@@ -68,7 +68,7 @@ func (s *Scheduler) scheduleOne() {
...
@@ -68,7 +68,7 @@ func (s *Scheduler) scheduleOne() {
pod
:=
s
.
config
.
NextPod
()
pod
:=
s
.
config
.
NextPod
()
dest
,
err
:=
s
.
config
.
Algorithm
.
Schedule
(
*
pod
,
s
.
config
.
MinionLister
)
dest
,
err
:=
s
.
config
.
Algorithm
.
Schedule
(
*
pod
,
s
.
config
.
MinionLister
)
if
err
!=
nil
{
if
err
!=
nil
{
record
.
Eventf
(
pod
,
""
,
string
(
api
.
Pod
Wait
ing
),
"failedScheduling"
,
"Error scheduling: %v"
,
err
)
record
.
Eventf
(
pod
,
""
,
string
(
api
.
Pod
Pend
ing
),
"failedScheduling"
,
"Error scheduling: %v"
,
err
)
s
.
config
.
Error
(
pod
,
err
)
s
.
config
.
Error
(
pod
,
err
)
return
return
}
}
...
@@ -78,9 +78,9 @@ func (s *Scheduler) scheduleOne() {
...
@@ -78,9 +78,9 @@ func (s *Scheduler) scheduleOne() {
Host
:
dest
,
Host
:
dest
,
}
}
if
err
:=
s
.
config
.
Binder
.
Bind
(
b
);
err
!=
nil
{
if
err
:=
s
.
config
.
Binder
.
Bind
(
b
);
err
!=
nil
{
record
.
Eventf
(
pod
,
""
,
string
(
api
.
Pod
Wait
ing
),
"failedScheduling"
,
"Binding rejected: %v"
,
err
)
record
.
Eventf
(
pod
,
""
,
string
(
api
.
Pod
Pend
ing
),
"failedScheduling"
,
"Binding rejected: %v"
,
err
)
s
.
config
.
Error
(
pod
,
err
)
s
.
config
.
Error
(
pod
,
err
)
return
return
}
}
record
.
Eventf
(
pod
,
""
,
string
(
api
.
Pod
Wait
ing
),
"scheduled"
,
"Successfully assigned %v to %v"
,
pod
.
Name
,
dest
)
record
.
Eventf
(
pod
,
""
,
string
(
api
.
Pod
Pend
ing
),
"scheduled"
,
"Successfully assigned %v to %v"
,
pod
.
Name
,
dest
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment