Skip to content

Commit

Permalink
refactor: Remove unneeded statements, unreachable code
Browse files Browse the repository at this point in the history
  • Loading branch information
brendangadd committed Aug 19, 2020
1 parent f3eb3cd commit 7d98d21
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions notebooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,40 +115,39 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) (Statu
// Return Container State if it's available
if notebook.Status.ContainerState.Running != nil {
return StatusRunning, "Running"
} else if notebook.Status.ContainerState.Terminated != nil {
}
if notebook.Status.ContainerState.Terminated != nil {
return StatusError, "The Pod has Terminated"
} else {
status, reason := StatusWarning, ""
}
status, reason := StatusWarning, ""

if notebook.Status.ContainerState.Waiting != nil {
status, reason = StatusWaiting, notebook.Status.ContainerState.Waiting.Reason
if notebook.Status.ContainerState.Waiting.Reason == "ImagePullBackoff" {
status, reason = StatusError, notebook.Status.ContainerState.Waiting.Reason
}
} else {
status, reason = StatusWaiting, "Scheduling the Pod"
if notebook.Status.ContainerState.Waiting != nil {
status, reason = StatusWaiting, notebook.Status.ContainerState.Waiting.Reason
if notebook.Status.ContainerState.Waiting.Reason == "ImagePullBackoff" {
status, reason = StatusError, notebook.Status.ContainerState.Waiting.Reason
}
} else {
status, reason = StatusWaiting, "Scheduling the Pod"
}

// Process events
for _, event := range events {
if event.Type == corev1.EventTypeWarning {
return StatusWarning, event.Message
}
// Process events
for _, event := range events {
if event.Type == corev1.EventTypeWarning {
return StatusWarning, event.Message
}

return status, reason
}

return "", ""
return status, reason

}

func processGPU(notebook *kubeflowv1.Notebook) (resource.Quantity, GPUVendor) {
if limit, ok := notebook.Spec.Template.Spec.Containers[0].Resources.Limits["nvidia.com/gpu"]; ok {
return limit, GPUVendorNvidia
} else if limit, ok := notebook.Spec.Template.Spec.Containers[0].Resources.Limits["amd.com/gpu"]; ok {
}
if limit, ok := notebook.Spec.Template.Spec.Containers[0].Resources.Limits["amd.com/gpu"]; ok {
return limit, GPUVendorAMD
}

return resource.Quantity{}, ""
}

Expand Down Expand Up @@ -316,7 +315,7 @@ func (s *server) NewNotebook(w http.ResponseWriter, r *http.Request) {
Spec: corev1.PodSpec{
ServiceAccountName: DefaultServiceAccountName,
Containers: []corev1.Container{
corev1.Container{
{
Name: req.Name,
Image: image,
Resources: corev1.ResourceRequirements{
Expand Down

0 comments on commit 7d98d21

Please sign in to comment.