Skip to content

Commit d105c5a

Browse files
authored
Merge pull request #121 from StatCan/try-image-pp
feat(imagePullPolicy): Add and set it
2 parents f2caa7a + 0cd46e5 commit d105c5a

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

.github/workflows/publish.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ on:
33
push:
44
branches:
55
- main
6-
76
env:
87
REGISTRY_NAME: k8scc01covidacr
98

frontend/jupyter/src/app/pages/form/form-default/form-image/form-image.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export class FormImageComponent implements OnInit, OnDestroy {
1616
@Input() imagesGroupOne: string[];
1717
@Input() imagesGroupTwo: string[];
1818
@Input() allowCustomImage: boolean;
19-
selected = 'Always';
2019
@Input() hideRegistry: boolean;
2120
@Input() hideTag: boolean;
2221

notebooks.go

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type newnotebookrequest struct {
8383
EnableSharedMemory bool `json:"shm"`
8484
Configurations []string `json:"configurations"`
8585
Language string `json:"language"`
86+
ImagePullPolicy string `json:"imagePullPolicy"`
8687
ServerType string `json:"serverType"`
8788
AffinityConfig string `json:"affinityConfig"`
8889
TolerationGroup string `json:"tolerationGroup"`
@@ -121,15 +122,16 @@ type notebookPhase string
121122

122123
// KeyType is the type of key
123124
type KeyType struct {
124-
Key string
125-
Params []string
125+
Key string
126+
Params []string
126127
}
128+
127129
// status represents the status of a notebook.
128130
type status struct {
129131
Message string `json:"message"`
130132
Phase notebookPhase `json:"phase"`
131133
State string `json:"state"`
132-
Key KeyType `json:"key"`
134+
Key KeyType `json:"key"`
133135
}
134136

135137
const (
@@ -165,11 +167,10 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
165167
return status{
166168
Message: "Deleting this Notebook Server.",
167169
Phase: NotebookPhaseTerminating,
168-
Key:
169-
KeyType{
170-
Key: "jupyter.backend.status.notebookDeleting",
171-
Params: []string{},
172-
},
170+
Key: KeyType{
171+
Key: "jupyter.backend.status.notebookDeleting",
172+
Params: []string{},
173+
},
173174
}
174175
}
175176

@@ -179,8 +180,8 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
179180
return status{
180181
Message: "No pods are currently running for this Notebook Server.",
181182
Phase: NotebookPhaseStopped,
182-
Key: KeyType{
183-
Key: "jupyter.backend.status.noPodsRunning",
183+
Key: KeyType{
184+
Key: "jupyter.backend.status.noPodsRunning",
184185
Params: []string{},
185186
},
186187
}
@@ -189,8 +190,8 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
189190
return status{
190191
Message: "Notebook Server is stopping.",
191192
Phase: NotebookPhaseTerminating,
192-
Key: KeyType{
193-
Key: "jupyter.backend.status.notebookStopping",
193+
Key: KeyType{
194+
Key: "jupyter.backend.status.notebookStopping",
194195
Params: []string{},
195196
},
196197
}
@@ -204,7 +205,7 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
204205
Message: "Running",
205206
Phase: NotebookPhaseReady,
206207
Key: KeyType{
207-
Key: "jupyter.backend.status.running",
208+
Key: "jupyter.backend.status.running",
208209
Params: []string{},
209210
},
210211
}
@@ -215,7 +216,7 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
215216
Message: state.Waiting.Reason,
216217
Phase: NotebookPhaseWaiting,
217218
Key: KeyType{
218-
Key: "jupyter.backend.status.waitingStatus",
219+
Key: "jupyter.backend.status.waitingStatus",
219220
Params: []string{},
220221
},
221222
}
@@ -228,7 +229,7 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
228229
Message: event.Reason,
229230
Phase: NotebookPhaseWarning,
230231
Key: KeyType{
231-
Key: "jupyter.backend.status.errorEvent",
232+
Key: "jupyter.backend.status.errorEvent",
232233
Params: []string{},
233234
},
234235
}
@@ -239,7 +240,7 @@ func processStatus(notebook *kubeflowv1.Notebook, events []*corev1.Event) status
239240
Message: "Scheduling the Pod",
240241
Phase: NotebookPhaseWaiting,
241242
Key: KeyType{
242-
Key: "jupyter.backend.status.schedulingPod",
243+
Key: "jupyter.backend.status.schedulingPod",
243244
Params: []string{},
244245
},
245246
}
@@ -640,6 +641,10 @@ func (s *server) NewNotebook(w http.ResponseWriter, r *http.Request) {
640641
})
641642
}
642643

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

645650
// Submit the notebook to the API server

0 commit comments

Comments
 (0)