-
Notifications
You must be signed in to change notification settings - Fork 33
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
feat(ws): add http service paths to WS get on backend #213
Open
yehudit1987
wants to merge
5
commits into
kubeflow:notebooks-v2
Choose a base branch
from
yehudit1987:add_missing_field
base: notebooks-v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+52
−0
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7c261e6
Add missing ports field to workspace model
8648291
Add missing ports field to workspace model
b1fac0d
Add services field to workspace model
d176b64
Add services field to workspace model
3f32965
Add services field to workspace model
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ package workspaces | |
|
||
import ( | ||
"fmt" | ||
"path" | ||
|
||
kubefloworgv1beta1 "github.com/kubeflow/notebooks/workspaces/controller/api/v1beta1" | ||
"k8s.io/utils/ptr" | ||
|
@@ -124,10 +125,46 @@ func NewWorkspaceModelFromWorkspace(ws *kubefloworgv1beta1.Workspace, wsk *kubef | |
// https://github.com/kubeflow/notebooks/issues/38 | ||
LastProbe: nil, | ||
}, | ||
Services: buildServicesList(ws, wsk), | ||
} | ||
return workspaceModel | ||
} | ||
|
||
func buildServicesList(ws *kubefloworgv1beta1.Workspace, wsk *kubefloworgv1beta1.WorkspaceKind) []Service { | ||
//nolint:prealloc | ||
var services []Service | ||
|
||
if !wskExists(wsk) { | ||
return services | ||
} | ||
|
||
// Get the image configuration from the WorkspaceKind's PodTemplate options. | ||
imageConfig := wsk.Spec.PodTemplate.Options.ImageConfig | ||
|
||
for _, val := range imageConfig.Values { | ||
if len(val.Spec.Ports) == 0 { | ||
continue | ||
} | ||
firstPort := val.Spec.Ports[0] | ||
portStr := fmt.Sprintf("%d", firstPort.Port) | ||
displayName := firstPort.DisplayName | ||
if displayName == "" { | ||
displayName = val.Id | ||
} | ||
basePath := "/workspace" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just out of my curiosity, where this /workspace path comes from? |
||
notebookPath := path.Join(basePath, ws.Namespace, ws.Name, portStr) | ||
service := Service{ | ||
HttpService: &HttpService{ | ||
DisplayName: displayName, | ||
HttpPath: notebookPath, | ||
}, | ||
} | ||
services = append(services, service) | ||
} | ||
|
||
return services | ||
} | ||
|
||
func wskExists(wsk *kubefloworgv1beta1.WorkspaceKind) bool { | ||
return wsk != nil && wsk.UID != "" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shall we support here multiple ports here?
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.
Or we deliberatelly are going to always use the first port here?
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.
@thesuperzapper maybe you can chime in on this one. ^
I'm good to support just one for now and do a FUP PR on it.
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.
@ederign I think it's a mistake (mine). Will fix it soon.
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.
No worries @yehudit1987 ! Thank you for the PR