Skip to content

Commit

Permalink
Merge pull request #121 from StatCan/try-image-pp
Browse files Browse the repository at this point in the history
feat(imagePullPolicy): Add and set it
  • Loading branch information
Jose-Matsuda authored Jun 6, 2022
2 parents f2caa7a + 0cd46e5 commit d105c5a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches:
- main

env:
REGISTRY_NAME: k8scc01covidacr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class FormImageComponent implements OnInit, OnDestroy {
@Input() imagesGroupOne: string[];
@Input() imagesGroupTwo: string[];
@Input() allowCustomImage: boolean;
selected = 'Always';
@Input() hideRegistry: boolean;
@Input() hideTag: boolean;

Expand Down
37 changes: 21 additions & 16 deletions notebooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type newnotebookrequest struct {
EnableSharedMemory bool `json:"shm"`
Configurations []string `json:"configurations"`
Language string `json:"language"`
ImagePullPolicy string `json:"imagePullPolicy"`
ServerType string `json:"serverType"`
AffinityConfig string `json:"affinityConfig"`
TolerationGroup string `json:"tolerationGroup"`
Expand Down Expand Up @@ -121,15 +122,16 @@ type notebookPhase string

// KeyType is the type of key
type KeyType struct {
Key string
Params []string
Key string
Params []string
}

// status represents the status of a notebook.
type status struct {
Message string `json:"message"`
Phase notebookPhase `json:"phase"`
State string `json:"state"`
Key KeyType `json:"key"`
Key KeyType `json:"key"`
}

const (
Expand Down Expand Up @@ -165,11 +167,10 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
return status{
Message: "Deleting this Notebook Server.",
Phase: NotebookPhaseTerminating,
Key:
KeyType{
Key: "jupyter.backend.status.notebookDeleting",
Params: []string{},
},
Key: KeyType{
Key: "jupyter.backend.status.notebookDeleting",
Params: []string{},
},
}
}

Expand All @@ -179,8 +180,8 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
return status{
Message: "No pods are currently running for this Notebook Server.",
Phase: NotebookPhaseStopped,
Key: KeyType{
Key: "jupyter.backend.status.noPodsRunning",
Key: KeyType{
Key: "jupyter.backend.status.noPodsRunning",
Params: []string{},
},
}
Expand All @@ -189,8 +190,8 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
return status{
Message: "Notebook Server is stopping.",
Phase: NotebookPhaseTerminating,
Key: KeyType{
Key: "jupyter.backend.status.notebookStopping",
Key: KeyType{
Key: "jupyter.backend.status.notebookStopping",
Params: []string{},
},
}
Expand All @@ -204,7 +205,7 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
Message: "Running",
Phase: NotebookPhaseReady,
Key: KeyType{
Key: "jupyter.backend.status.running",
Key: "jupyter.backend.status.running",
Params: []string{},
},
}
Expand All @@ -215,7 +216,7 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
Message: state.Waiting.Reason,
Phase: NotebookPhaseWaiting,
Key: KeyType{
Key: "jupyter.backend.status.waitingStatus",
Key: "jupyter.backend.status.waitingStatus",
Params: []string{},
},
}
Expand All @@ -228,7 +229,7 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
Message: event.Reason,
Phase: NotebookPhaseWarning,
Key: KeyType{
Key: "jupyter.backend.status.errorEvent",
Key: "jupyter.backend.status.errorEvent",
Params: []string{},
},
}
Expand All @@ -239,7 +240,7 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
Message: "Scheduling the Pod",
Phase: NotebookPhaseWaiting,
Key: KeyType{
Key: "jupyter.backend.status.schedulingPod",
Key: "jupyter.backend.status.schedulingPod",
Params: []string{},
},
}
Expand Down Expand Up @@ -640,6 +641,10 @@ func (s *server) NewNotebook(w http.ResponseWriter, r *http.Request) {
})
}

// Add imagePullPolicy
if req.ImagePullPolicy == "Always" || req.ImagePullPolicy == "Never" || req.ImagePullPolicy == "IfNotPresent" {
notebook.Spec.Template.Spec.Containers[0].ImagePullPolicy = corev1.PullPolicy(req.ImagePullPolicy)
}
log.Printf("creating notebook %q for %q", notebook.ObjectMeta.Name, namespace)

// Submit the notebook to the API server
Expand Down

0 comments on commit d105c5a

Please sign in to comment.