mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-25 12:17:52 +00:00
Merge pull request #5477 from dchen1107/clean
Convert RestartPolicy to string for v1beta3.
This commit is contained in:
@@ -85,13 +85,13 @@ func FilterQuotaPods(pods []api.Pod) []api.Pod {
|
||||
var result []api.Pod
|
||||
for _, value := range pods {
|
||||
// a pod that has a restart policy always no matter its state counts against usage
|
||||
if value.Spec.RestartPolicy.Always != nil {
|
||||
if value.Spec.RestartPolicy == api.RestartPolicyAlways {
|
||||
result = append(result, value)
|
||||
continue
|
||||
}
|
||||
// a failed pod with a restart policy of on failure will count against usage
|
||||
if api.PodFailed == value.Status.Phase &&
|
||||
value.Spec.RestartPolicy.OnFailure != nil {
|
||||
value.Spec.RestartPolicy == api.RestartPolicyOnFailure {
|
||||
result = append(result, value)
|
||||
continue
|
||||
}
|
||||
|
@@ -63,27 +63,21 @@ func TestFilterQuotaPods(t *testing.T) {
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "pod-failed-with-restart-always"},
|
||||
Spec: api.PodSpec{
|
||||
RestartPolicy: api.RestartPolicy{
|
||||
Always: &api.RestartPolicyAlways{},
|
||||
},
|
||||
RestartPolicy: api.RestartPolicyAlways,
|
||||
},
|
||||
Status: api.PodStatus{Phase: api.PodFailed},
|
||||
},
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "pod-failed-with-restart-on-failure"},
|
||||
Spec: api.PodSpec{
|
||||
RestartPolicy: api.RestartPolicy{
|
||||
OnFailure: &api.RestartPolicyOnFailure{},
|
||||
},
|
||||
RestartPolicy: api.RestartPolicyOnFailure,
|
||||
},
|
||||
Status: api.PodStatus{Phase: api.PodFailed},
|
||||
},
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "pod-failed-with-restart-never"},
|
||||
Spec: api.PodSpec{
|
||||
RestartPolicy: api.RestartPolicy{
|
||||
Never: &api.RestartPolicyNever{},
|
||||
},
|
||||
RestartPolicy: api.RestartPolicyNever,
|
||||
},
|
||||
Status: api.PodStatus{Phase: api.PodFailed},
|
||||
},
|
||||
|
Reference in New Issue
Block a user