-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extended scheduled job status messages #603
Changes from all commits
36b110f
1bd563d
169d666
5633880
30c8f49
198286c
fff54b8
a79b377
a8e9fed
d220bec
d125069
552b05e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import ( | |
"strings" | ||
|
||
radixutils "github.com/equinor/radix-common/utils" | ||
"github.com/equinor/radix-common/utils/pointers" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
|
@@ -280,7 +281,19 @@ type ReplicaSummary struct { | |
// | ||
// required: false | ||
// example: 2006-01-02T15:04:05Z | ||
Created string `json:"created"` | ||
Created string `json:"created,omitempty"` | ||
|
||
// The time at which the batch job's pod startedAt | ||
// | ||
// required: false | ||
// example: 2006-01-02T15:04:05Z | ||
StartTime string `json:"startTime,omitempty"` | ||
|
||
// The time at which the batch job's pod finishedAt. | ||
// | ||
// required: false | ||
// example: 2006-01-02T15:04:05Z | ||
EndTime string `json:"endTime,omitempty"` | ||
|
||
// Container started timestamp | ||
// | ||
|
@@ -291,47 +304,58 @@ type ReplicaSummary struct { | |
// Status describes the component container status | ||
// | ||
// required: false | ||
Status ReplicaStatus `json:"replicaStatus"` | ||
Status ReplicaStatus `json:"replicaStatus,omitempty"` | ||
|
||
// StatusMessage provides message describing the status of a component container inside a pod | ||
// | ||
// required: false | ||
StatusMessage string `json:"statusMessage"` | ||
StatusMessage string `json:"statusMessage,omitempty"` | ||
|
||
// RestartCount count of restarts of a component container inside a pod | ||
// | ||
// required: false | ||
RestartCount int32 `json:"restartCount"` | ||
RestartCount int32 `json:"restartCount,omitempty"` | ||
|
||
// The image the container is running. | ||
// | ||
// required: false | ||
// example: radixdev.azurecr.io/app-server:cdgkg | ||
Image string `json:"image"` | ||
Image string `json:"image,omitempty"` | ||
|
||
// ImageID of the container's image. | ||
// | ||
// required: false | ||
// example: radixdev.azurecr.io/app-server@sha256:d40cda01916ef63da3607c03785efabc56eb2fc2e0dab0726b1a843e9ded093f | ||
ImageId string `json:"imageId"` | ||
ImageId string `json:"imageId,omitempty"` | ||
|
||
// The index of the pod in the re-starts | ||
PodIndex int `json:"podIndex,omitempty"` | ||
|
||
// Exit status from the last termination of the container | ||
ExitCode int32 `json:"exitCode"` | ||
|
||
// A brief CamelCase message indicating details about why the job is in this phase | ||
Reason string `json:"reason,omitempty"` | ||
|
||
// Resources Resource requirements for the pod | ||
// | ||
// required: false | ||
Resources ResourceRequirements `json:"resources,omitempty"` | ||
Resources *ResourceRequirements `json:"resources,omitempty"` | ||
} | ||
|
||
// ReplicaStatus describes the status of a component container inside a pod | ||
// swagger:model ReplicaStatus | ||
type ReplicaStatus struct { | ||
// Status of the container | ||
// - Pending = Container in Waiting state and the reason is ContainerCreating | ||
// - Failing = Container in Waiting state and the reason is anything else but ContainerCreating | ||
// - Failed = Container is failed | ||
// - Failing = Container is failed | ||
// - Running = Container in Running state | ||
// - Succeeded = Container in Succeeded state | ||
// - Terminated = Container in Terminated state | ||
// | ||
// required: true | ||
// enum: Pending,Failing,Running,Terminated,Starting | ||
// enum: Pending,Succeeded,Failing,Failed,Running,Terminated,Starting | ||
// example: Running | ||
Status string `json:"status"` | ||
} | ||
|
@@ -396,7 +420,7 @@ type ResourceRequirements struct { | |
Requests Resources `json:"requests,omitempty"` | ||
} | ||
|
||
func GetReplicaSummary(pod corev1.Pod) ReplicaSummary { | ||
func GetReplicaSummary(pod corev1.Pod, lastEventWarning string) ReplicaSummary { | ||
replicaSummary := ReplicaSummary{} | ||
replicaSummary.Name = pod.GetName() | ||
creationTimestamp := pod.GetCreationTimestamp() | ||
|
@@ -450,7 +474,10 @@ func GetReplicaSummary(pod corev1.Pod) ReplicaSummary { | |
replicaSummary.Image = containerStatus.Image | ||
replicaSummary.ImageId = containerStatus.ImageID | ||
if len(pod.Spec.Containers) > 0 { | ||
replicaSummary.Resources = ConvertResourceRequirements(pod.Spec.Containers[0].Resources) | ||
replicaSummary.Resources = pointers.Ptr(ConvertResourceRequirements(pod.Spec.Containers[0].Resources)) | ||
} | ||
if len(replicaSummary.StatusMessage) == 0 && (replicaSummary.Status.Status == Failing.String() || replicaSummary.Status.Status == Pending.String()) { | ||
replicaSummary.StatusMessage = lastEventWarning | ||
Comment on lines
+479
to
+480
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure its a good idea to set last warning event in StatusMessage. We should instead discuss if we shall show events per component and/or replica, as described in my other comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same reason as above - to keep the failure reason in the radix-batch status, when replicas and events do not longer exist |
||
} | ||
return replicaSummary | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how useful it is to include the last warning event. There can be multiple warning events, and only showing the last will potentially hide other important events. Perhaps a better approach is to have an endpoint for the component and/or replica that returns events for the particular object. We can then show it in web console as an event list, similar to the event list on the environment page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternative can be to show events within the replica page, but it will not show the rootcause of some issues with replica after it was deleted