Skip to content

Commit b99968a

Browse files
Explicitly checking PodPending when reporting Build/Sign status. (#552)
Currently, PodPending phase of a running pod is not explicitly checked, which may cause an unnecessary errors reported. It does not affect the correctness of the flow, but does causes confusion in logs
1 parent 1392250 commit b99968a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

internal/utils/podhelper.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ func (ph *podHelper) CreatePod(ctx context.Context, pod *v1.Pod) error {
119119
// GetPodStatus returns the status of a Pod, whether the latter is in progress or not and
120120
// whether there was an error or not
121121
func (ph *podHelper) GetPodStatus(pod *v1.Pod) (Status, error) {
122-
switch {
123-
case pod.Status.Phase == v1.PodSucceeded:
122+
switch pod.Status.Phase {
123+
case v1.PodSucceeded:
124124
return StatusCompleted, nil
125-
case pod.Status.Phase == v1.PodRunning:
125+
case v1.PodRunning, v1.PodPending:
126126
return StatusInProgress, nil
127-
case pod.Status.Phase == v1.PodFailed:
127+
case v1.PodFailed:
128128
return StatusFailed, nil
129129
default:
130130
return "", fmt.Errorf("unknown status: %v", pod.Status)

internal/utils/podhelper_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,9 @@ var _ = Describe("PodStatus", func() {
425425
},
426426
Entry("succeeded", &v1.Pod{Status: v1.PodStatus{Phase: v1.PodSucceeded}}, StatusCompleted, false),
427427
Entry("in progress", &v1.Pod{Status: v1.PodStatus{Phase: v1.PodRunning}}, StatusInProgress, false),
428+
Entry("pending", &v1.Pod{Status: v1.PodStatus{Phase: v1.PodPending}}, StatusInProgress, false),
428429
Entry("Failed", &v1.Pod{Status: v1.PodStatus{Phase: v1.PodFailed}}, StatusFailed, false),
430+
Entry("Unknown", &v1.Pod{Status: v1.PodStatus{Phase: v1.PodUnknown}}, "", true),
429431
)
430432
})
431433

0 commit comments

Comments
 (0)