-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ws): update JSON payload for listing workspaces #134
fix(ws): update JSON payload for listing workspaces #134
Conversation
@mohamedch7 thank you so much for the contribution! I'll look it before end of the week. |
@mohamedch7 once we merge #137 (hopefully tomorrow) please rebase this PR so you get the new linting (and make sure your PR passes a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mohamedch7 thank you so much for the PR. I left some required changes for your PR.
Could you review all the fields according to:
https://github.com/thesuperzapper/kubeflow-notebooks-v2-design/blob/main/crds/workspace-kind.yaml
and https://github.com/thesuperzapper/kubeflow-notebooks-v2-design/blob/main/crds/workspace.yaml
Namespace: item.Namespace, | ||
WorkspaceKind: WorkspaceKind{ | ||
Name: item.Spec.Kind, | ||
Type: item.Spec.PodTemplate.Options.ImageConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be POD_TEMPLATE.
https://github.com/thesuperzapper/kubeflow-notebooks-v2-design/blob/main/crds/workspace-kind.yaml#L51
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
PodTemplate: PodTemplate{ | ||
PodMetadata: &PodMetadata{ | ||
Labels: item.Spec.PodTemplate.PodMetadata.Labels, | ||
Annotations: item.Spec.PodTemplate.PodMetadata.Annotations, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"labels": null,
"annotations": null
}, | ||
Volumes: &Volumes{ | ||
Home: &DataVolumeModel{ | ||
PvcName: item.Spec.PodTemplate.Volumes.Data[0].PVCName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Home is not Volumes.Data[0], but instead defined by kind:
the mount path is defined in the WorkspaceKind under
## spec.podTemplate.volumeMounts.home
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should fetch WorkspaceKind then use it, right ?
57d4485
MountPath: item.Spec.PodTemplate.Volumes.Data[0].MountPath, | ||
ReadOnly: *item.Spec.PodTemplate.Volumes.Data[0].ReadOnly, | ||
}, | ||
Data: dataVolumes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to don't list 'home' here.
}, | ||
PodConfig: &PodConfig{ | ||
Current: item.Spec.PodTemplate.Options.PodConfig, | ||
Desired: item.Spec.PodTemplate.Options.PodConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be:
Pod Template Options:
Image Config:
Desired: jupyterlab_scipy_190
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(on status)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
Also, make sure to rebase it to include the new linting etc. |
@mohamedch7 you should be able to rebase it to head of |
4a4c56f
to
fd1fb92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mohamedch7 I'm sorry for the delay on this PR. I was in a long PTO but I'm back.
I just asked here a small changes. I'll review as soon as you send the PR. And please, don't forget to sign the commits.
models.NewWorkspaceModelFromWorkspace(workspace1), | ||
models.NewWorkspaceModelFromWorkspace(workspace2), | ||
models.NewWorkspaceModelFromWorkspace(workspace3), | ||
models.NewWorkspaceModelFromWorkspace(ctx, k8sClient, workspace1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our model should only be responsible for translate k8s object for our DTOs/pojos. We should not add any extra logic there. Could you please pass the kind as a parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
models.NewWorkspaceModelFromWorkspace(workspace2), | ||
models.NewWorkspaceModelFromWorkspace(workspace3), | ||
models.NewWorkspaceModelFromWorkspace(ctx, k8sClient, workspace1), | ||
models.NewWorkspaceModelFromWorkspace(ctx, k8sClient, workspace2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
models.NewWorkspaceModelFromWorkspace(workspace3), | ||
models.NewWorkspaceModelFromWorkspace(ctx, k8sClient, workspace1), | ||
models.NewWorkspaceModelFromWorkspace(ctx, k8sClient, workspace2), | ||
models.NewWorkspaceModelFromWorkspace(ctx, k8sClient, workspace3), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
@@ -256,8 +256,8 @@ var _ = Describe("Workspaces Handler", func() { | |||
Expect(k8sClient.Get(ctx, workspaceKey2, workspace2)).To(Succeed()) | |||
|
|||
expectedWorkspaces := []models.WorkspaceModel{ | |||
models.NewWorkspaceModelFromWorkspace(workspace1), | |||
models.NewWorkspaceModelFromWorkspace(workspace2), | |||
models.NewWorkspaceModelFromWorkspace(ctx, k8sClient, workspace1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.
models.NewWorkspaceModelFromWorkspace(workspace1), | ||
models.NewWorkspaceModelFromWorkspace(workspace2), | ||
models.NewWorkspaceModelFromWorkspace(ctx, k8sClient, workspace1), | ||
models.NewWorkspaceModelFromWorkspace(ctx, k8sClient, workspace2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.
t := time.Unix(item.Status.Activity.LastActivity, 0) | ||
formattedLastActivity := t.Format("2006-01-02 15:04:05 MST") | ||
func NewWorkspaceModelFromWorkspace(ctx context.Context, cl client.Client, item *kubefloworgv1beta1.Workspace) WorkspaceModel { | ||
wsk := &kubefloworgv1beta1.WorkspaceKind{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this lines to repository.
@@ -69,7 +69,7 @@ func (r *WorkspaceRepository) GetWorkspaces(ctx context.Context, namespace strin | |||
|
|||
workspacesModels := make([]models.WorkspaceModel, len(workspaceList.Items)) | |||
for i, item := range workspaceList.Items { | |||
workspaceModel := models.NewWorkspaceModelFromWorkspace(&item) | |||
workspaceModel := models.NewWorkspaceModelFromWorkspace(ctx, r.client, &item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as others.
@@ -53,7 +53,7 @@ func (r *WorkspaceRepository) GetWorkspace(ctx context.Context, namespace string | |||
return models.WorkspaceModel{}, err | |||
} | |||
|
|||
workspaceModel := models.NewWorkspaceModelFromWorkspace(workspace) | |||
workspaceModel := models.NewWorkspaceModelFromWorkspace(ctx, r.client, workspace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as others.
@@ -100,34 +100,34 @@ func (r *WorkspaceRepository) CreateWorkspace(ctx context.Context, workspaceMode | |||
Name: workspaceModel.Name, | |||
Namespace: workspaceModel.Namespace, | |||
// TODO: the pod and workspace labels should be separated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove my old TODO here?
Hi @mohamedch7, please, don't forget to sign the commits, you have unsigned commits. |
@mohamedch7, can you please sign the commit? |
Signed-off-by: mohamedch7 <[email protected]>
Signed-off-by: mohamedch7 <[email protected]>
Signed-off-by: mohamedch7 <[email protected]>
Signed-off-by: mohamedch7 <[email protected]>
Signed-off-by: mohamedch7 <[email protected]>
Signed-off-by: mohamedch7 <[email protected]>
Signed-off-by: mohamedch7 <[email protected]>
Signed-off-by: mohamedch7 <[email protected]>
Signed-off-by: mohamedch7 <[email protected]>
fbc34d7
to
5bc2a17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the interest of moving this forward, I will approve.
There is one big issue I found (see comments) but other than that I expect we will be rewriting a lot of this anyway, so its good to have a base to work from.
workspaceModel := models.NewWorkspaceModelFromWorkspace(&item) | ||
workspacesModels[i] = workspaceModel | ||
kind := &kubefloworgv1beta1.WorkspaceKind{} | ||
if err := r.client.Get(ctx, client.ObjectKey{Name: item.Spec.Kind}, kind); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not guaranteed that a WorkspaceKind will actually exist, even if it has been referenced by a Workspace (things can happen which bypass the validation webhook).
So in a follow-up PR, we need to gracefully handle Workspaces with missing WorkspaceKinds (e.g. still list them but indicate that we can't fully process them).
workspaceModel := models.NewWorkspaceModelFromWorkspace(&item) | ||
workspacesModels[i] = workspaceModel | ||
kind := &kubefloworgv1beta1.WorkspaceKind{} | ||
if err := r.client.Get(ctx, client.ObjectKey{Name: item.Spec.Kind}, kind); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same idea here, WSK might be missing.
workspaceModel := models.NewWorkspaceModelFromWorkspace(workspace) | ||
return workspaceModel, nil | ||
kind := &kubefloworgv1beta1.WorkspaceKind{} | ||
if err := r.client.Get(ctx, client.ObjectKey{Name: workspace.Spec.Kind}, kind); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same idea here, WSK might be missing.
@@ -140,7 +144,12 @@ func (r *WorkspaceRepository) CreateWorkspace(ctx context.Context, workspaceMode | |||
return models.WorkspaceModel{}, err | |||
} | |||
|
|||
return models.NewWorkspaceModelFromWorkspace(workspace), nil | |||
kind := &kubefloworgv1beta1.WorkspaceKind{} | |||
if err := r.client.Get(ctx, client.ObjectKey{Name: workspace.Spec.Kind}, kind); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same idea here, WSK might be missing.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ederign, thesuperzapper The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Fix: Update Workspace Model and JSON Payload Structure
This PR addresses issue #127 by refactoring the workspace model and adjusting the JSON payload structure to align with the updated API requirements.
Changes Made
Workspace Model Updates:
WorkspaceKind
,PodTemplate
,Activity
, andVolumes
.PodMetadata
,ImageConfig
,PodConfig
) for improved modularity.Handler Updates:
workspaces_handler_test.go
to validate the new model and payload structure.Repository Adjustments:
CreateWorkspace
method inworkspaces.go
to reflect the new model structure.Payload Adjustments:
Impact
Testing
workspaces_handler_test.go
updated to include new cases.