Skip to content

Commit

Permalink
Merge pull request #2769 from andrewballantyne/cert-fix-patch
Browse files Browse the repository at this point in the history
Jupyter tile, merge cert info from old notebook to avoid loss
  • Loading branch information
openshift-merge-bot[bot] authored May 1, 2024
2 parents 7255776 + 5142b4d commit b2de1f6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/src/routes/api/notebooks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export const enableNotebook = async (
const url = request.headers.origin;

try {
await getNotebook(fastify, notebookNamespace, name);
return await updateNotebook(fastify, username, url, notebookData);
const notebook = await getNotebook(fastify, notebookNamespace, name);
return await updateNotebook(fastify, username, url, notebookData, notebook);
} catch (e) {
if (e.response?.statusCode === 404) {
return await createNotebook(fastify, username, url, notebookData);
Expand Down
26 changes: 25 additions & 1 deletion backend/src/utils/notebookUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getDashboardConfig } from './resourceUtils';
import { merge } from 'lodash';
import {
ContainerResourceAttributes,
EnvironmentVariable,
Expand Down Expand Up @@ -510,6 +511,7 @@ export const updateNotebook = async (
username: string,
url: string,
notebookData: NotebookData,
oldNotebook: Notebook,
): Promise<Notebook> => {
if (!notebookData) {
const error = createCustomError(
Expand All @@ -521,7 +523,29 @@ export const updateNotebook = async (
throw error;
}
try {
const notebookAssembled = await generateNotebookResources(fastify, username, url, notebookData);
const serverNotebook = await generateNotebookResources(fastify, username, url, notebookData);

// Fix for Workbench Certs that get overridden
// We are intentionally applying on some details as to avoid implementing logic to properly
// manage the notebook the same way as workbench
const importantOldNotebookDetails: RecursivePartial<Notebook> = {
spec: {
template: {
spec: {
containers: [
{
env: oldNotebook.spec.template.spec.containers[0].env,
volumeMounts: oldNotebook.spec.template.spec.containers[0].volumeMounts,
},
],
volumes: oldNotebook.spec.template.spec.volumes,
},
},
},
};

const notebookAssembled = merge({}, importantOldNotebookDetails, serverNotebook);

const response = await fastify.kube.customObjectsApi.patchNamespacedCustomObject(
'kubeflow.org',
'v1',
Expand Down

0 comments on commit b2de1f6

Please sign in to comment.