This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
capacity controller: better summarization of conditions
Before this, the capacity controller would only put a list of unready clusters in the CapacityTarget's Ready condition when it would set it to False. This requires users to go digging into each cluster condition, and most likely they would only be directed to SadPods, where they could finally get some useful information. Now, that information is summarized in a very brief format, in the hopes that users will have to do less jumping around when investigating why their CapacityTarget is not progressing. For instance, if the CapacityTarget is stuck because one container can't pull its image, we'll now have the following in the CapacityTarget's .stauts.conditions: ``` [ { "lastTransitionTime": "2020-02-12T13:16:44Z", "status": "True", "type": "Operational" }, { "lastTransitionTime": "2020-02-12T13:16:44Z", "message": "docker-desktop: PodsNotReady 3/3: 3x\"test-nginx\" containers with [ImagePullBackOff]", "reason": "ClustersNotReady", "status": "False", "type": "Ready" } ] ``` As a bonus, this is also shown on a `kubectl get ct`: ``` % kubectl get ct snowflake-db84be2b-0 NAME OPERATIONAL READY REASON AGE snowflake-db84be2b-0 True False docker-desktop: PodsNotReady 3/3: 3x"test-nginx" containers with [ImagePullBackOff] 8d ```
- Loading branch information
1 parent
3e58d0a
commit abe5790
Showing
8 changed files
with
253 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package capacity | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
|
||
shipper "github.com/bookingcom/shipper/pkg/apis/shipper/v1alpha1" | ||
) | ||
|
||
func TestSummarizeSadPods(t *testing.T) { | ||
sadPods := []shipper.PodStatus{ | ||
{ | ||
InitContainers: []corev1.ContainerStatus{ | ||
{ | ||
Name: "ready-init-container", | ||
Ready: true, | ||
}, | ||
{ | ||
Name: "waiting-init-container", | ||
Ready: false, | ||
State: corev1.ContainerState{ | ||
Waiting: &corev1.ContainerStateWaiting{ | ||
Reason: "ImagePullBackOff", | ||
}, | ||
}, | ||
}, | ||
}, | ||
Containers: []corev1.ContainerStatus{ | ||
{ | ||
Name: "ready-container", | ||
Ready: true, | ||
}, | ||
{ | ||
Name: "waiting-container", | ||
Ready: false, | ||
State: corev1.ContainerState{ | ||
Waiting: &corev1.ContainerStateWaiting{ | ||
Reason: "ImagePullBackOff", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "terminated-container", | ||
Ready: false, | ||
State: corev1.ContainerState{ | ||
Terminated: &corev1.ContainerStateTerminated{ | ||
Reason: "Completed", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
InitContainers: []corev1.ContainerStatus{ | ||
{ | ||
Name: "waiting-init-container", // but not really :D | ||
Ready: true, | ||
}, | ||
}, | ||
Containers: []corev1.ContainerStatus{ | ||
{ | ||
Name: "waiting-container", | ||
Ready: false, | ||
State: corev1.ContainerState{ | ||
Waiting: &corev1.ContainerStateWaiting{ | ||
Reason: "ErrImagePull", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
expected := strings.Join([]string{ | ||
`1x"terminated-container" containers with [Completed]`, | ||
`2x"waiting-container" containers with [ErrImagePull ImagePullBackOff]`, | ||
`1x"waiting-init-container" containers with [ImagePullBackOff]`, | ||
}, "; ") | ||
actual := summarizeSadPods(sadPods) | ||
if expected != actual { | ||
t.Fatalf( | ||
"summary does not match.\nexpected: %s\nactual: %s", | ||
expected, actual) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters