Skip to content

Commit 7d98d21

Browse files
committed
refactor: Remove unneeded statements, unreachable code
1 parent f3eb3cd commit 7d98d21

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

notebooks.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -115,40 +115,39 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) (Statu
115115
// Return Container State if it's available
116116
if notebook.Status.ContainerState.Running != nil {
117117
return StatusRunning, "Running"
118-
} else if notebook.Status.ContainerState.Terminated != nil {
118+
}
119+
if notebook.Status.ContainerState.Terminated != nil {
119120
return StatusError, "The Pod has Terminated"
120-
} else {
121-
status, reason := StatusWarning, ""
121+
}
122+
status, reason := StatusWarning, ""
122123

123-
if notebook.Status.ContainerState.Waiting != nil {
124-
status, reason = StatusWaiting, notebook.Status.ContainerState.Waiting.Reason
125-
if notebook.Status.ContainerState.Waiting.Reason == "ImagePullBackoff" {
126-
status, reason = StatusError, notebook.Status.ContainerState.Waiting.Reason
127-
}
128-
} else {
129-
status, reason = StatusWaiting, "Scheduling the Pod"
124+
if notebook.Status.ContainerState.Waiting != nil {
125+
status, reason = StatusWaiting, notebook.Status.ContainerState.Waiting.Reason
126+
if notebook.Status.ContainerState.Waiting.Reason == "ImagePullBackoff" {
127+
status, reason = StatusError, notebook.Status.ContainerState.Waiting.Reason
130128
}
129+
} else {
130+
status, reason = StatusWaiting, "Scheduling the Pod"
131+
}
131132

132-
// Process events
133-
for _, event := range events {
134-
if event.Type == corev1.EventTypeWarning {
135-
return StatusWarning, event.Message
136-
}
133+
// Process events
134+
for _, event := range events {
135+
if event.Type == corev1.EventTypeWarning {
136+
return StatusWarning, event.Message
137137
}
138-
139-
return status, reason
140138
}
141139

142-
return "", ""
140+
return status, reason
141+
143142
}
144143

145144
func processGPU(notebook *kubeflowv1.Notebook) (resource.Quantity, GPUVendor) {
146145
if limit, ok := notebook.Spec.Template.Spec.Containers[0].Resources.Limits["nvidia.com/gpu"]; ok {
147146
return limit, GPUVendorNvidia
148-
} else if limit, ok := notebook.Spec.Template.Spec.Containers[0].Resources.Limits["amd.com/gpu"]; ok {
147+
}
148+
if limit, ok := notebook.Spec.Template.Spec.Containers[0].Resources.Limits["amd.com/gpu"]; ok {
149149
return limit, GPUVendorAMD
150150
}
151-
152151
return resource.Quantity{}, ""
153152
}
154153

@@ -316,7 +315,7 @@ func (s *server) NewNotebook(w http.ResponseWriter, r *http.Request) {
316315
Spec: corev1.PodSpec{
317316
ServiceAccountName: DefaultServiceAccountName,
318317
Containers: []corev1.Container{
319-
corev1.Container{
318+
{
320319
Name: req.Name,
321320
Image: image,
322321
Resources: corev1.ResourceRequirements{

0 commit comments

Comments
 (0)