Skip to content
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: select.nodepool validation #810

Merged
merged 9 commits into from
Dec 29, 2020
96 changes: 48 additions & 48 deletions api/api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,54 +141,6 @@
]
}
},
"/apis/v1beta1/labels/{namespace}/{resource}/labels": {
"get": {
"operationId": "GetAvailableLabels",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/GetLabelsResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/google.rpc.Status"
}
}
},
"parameters": [
{
"name": "namespace",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "resource",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "keyLike",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "skipKeys",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"LabelService"
]
}
},
"/apis/v1beta1/namespaces": {
"get": {
"operationId": "ListNamespaces",
Expand Down Expand Up @@ -2758,6 +2710,54 @@
]
}
},
"/apis/v1beta1/{namespace}/{resource}/labels": {
"get": {
"operationId": "GetAvailableLabels",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/GetLabelsResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/google.rpc.Status"
}
}
},
"parameters": [
{
"name": "namespace",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "resource",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "keyLike",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "skipKeys",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"LabelService"
]
}
},
"/apis/v1beta1/{namespace}/{resource}/{uid}/labels": {
"get": {
"operationId": "GetLabels",
Expand Down
76 changes: 38 additions & 38 deletions api/gen/label.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/label.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/proto/label.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "google/api/annotations.proto";
service LabelService {
rpc GetAvailableLabels (GetAvailableLabelsRequest) returns (GetLabelsResponse) {
option (google.api.http) = {
get: "/apis/v1beta1/labels/{namespace}/{resource}/labels"
get: "/apis/v1beta1/{namespace}/{resource}/labels"
};
}

Expand Down
30 changes: 30 additions & 0 deletions db/go/20201229205644_fix_jupyter_workspace_yaml.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package migration

import (
"database/sql"
"github.com/pressly/goose"
"path/filepath"
)

func initialize20201229205644() {
if _, ok := initializedMigrations[20201229205644]; !ok {
goose.AddMigration(Up20201229205644, Down20201229205644)
initializedMigrations[20201229205644] = true
}
}

// Up20201229205644 updates the jupyterlab workspace template
func Up20201229205644(tx *sql.Tx) error {
// This code is executed when the migration is applied.
return updateWorkspaceTemplateManifest(
filepath.Join("workspaces", "jupyterlab", "20201229205644.yaml"),
jupyterLabTemplateName)
}

// Down20201229205644 rolls back the jupyterab workspace template update
func Down20201229205644(tx *sql.Tx) error {
// This code is executed when the migration is rolled back.
return updateWorkspaceTemplateManifest(
filepath.Join("workspaces", "jupyterlab", "20201214133458.yaml"),
jupyterLabTemplateName)
}
1 change: 1 addition & 0 deletions db/go/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func Initialize() {
initialize20201221195937()
initialize20201223062947()
initialize20201223202929()
initialize20201229205644()

if err := client.DB.Close(); err != nil {
log.Printf("[error] closing db %v", err)
Expand Down
93 changes: 93 additions & 0 deletions db/yaml/workspaces/jupyterlab/20201229205644.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Docker containers that are part of the Workspace
containers:
- name: jupyterlab
image: onepanel/dl:0.17.0
command: ["/bin/bash", "-c", "pip install onepanel-sdk && start.sh LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64 jupyter lab --LabApp.token='' --LabApp.allow_remote_access=True --LabApp.allow_origin=\"*\" --LabApp.disable_check_xsrf=True --LabApp.trust_xheaders=True --LabApp.base_url=/ --LabApp.tornado_settings='{\"headers\":{\"Content-Security-Policy\":\"frame-ancestors * 'self'\"}}' --notebook-dir='/data' --allow-root"]
workingDir: /data
env:
- name: tornado
value: "'{'headers':{'Content-Security-Policy':\"frame-ancestors\ *\ 'self'\"}}'"
- name: TENSORBOARD_PROXY_URL
value: '//$(ONEPANEL_RESOURCE_UID)--$(ONEPANEL_RESOURCE_NAMESPACE).$(ONEPANEL_DOMAIN)/tensorboard'
ports:
- containerPort: 8888
name: jupyterlab
- containerPort: 6006
name: tensorboard
- containerPort: 8080
name: nni
volumeMounts:
- name: data
mountPath: /data
lifecycle:
postStart:
exec:
command:
- /bin/sh
- -c
- >
condayml="/data/.environment.yml";
jupytertxt="/data/.jupexported.txt";
if [ -f "$condayml" ]; then conda env update -f $condayml; fi;
if [ -f "$jupytertxt" ]; then cat $jupytertxt | xargs -n 1 jupyter labextension install --no-build && jupyter lab build --minimize=False; fi;
preStop:
exec:
command:
- /bin/sh
- -c
- >
conda env export > /data/.environment.yml -n base;
jupyter labextension list 1>/dev/null 2> /data/.jup.txt;
cat /data/.jup.txt | sed -n '2,$p' | awk 'sub(/v/,"@", $2){print $1$2}' > /data/.jupexported.txt;
ports:
- name: jupyterlab
port: 80
protocol: TCP
targetPort: 8888
- name: tensorboard
port: 6006
protocol: TCP
targetPort: 6006
- name: nni
port: 8080
protocol: TCP
targetPort: 8080
routes:
- match:
- uri:
prefix: /tensorboard
route:
- destination:
port:
number: 6006
- match:
- uri:
prefix: /nni
route:
- destination:
port:
number: 8080
- match:
- uri:
prefix: / #jupyter runs at the default route
route:
- destination:
port:
number: 80
# DAG Workflow to be executed once a Workspace action completes (optional)
#postExecutionWorkflow:
# entrypoint: main
# templates:
# - name: main
# dag:
# tasks:
# - name: slack-notify
# template: slack-notify
# - name: slack-notify
# container:
# image: technosophos/slack-notify
# args:
# - SLACK_USERNAME=onepanel SLACK_TITLE="Your workspace is ready" SLACK_ICON=https://www.gravatar.com/avatar/5c4478592fe00878f62f0027be59c1bd SLACK_MESSAGE="Your workspace is now running" ./slack-notify
# command:
# - sh
# - -c
5 changes: 5 additions & 0 deletions pkg/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ func ParseParametersFromManifest(manifest []byte) ([]Parameter, error) {
if parameter.Visibility == nil {
parameter.Visibility = ptr.String("public")
}

if parameter.Type == "select.nodepool" {
parameter.Options = make([]*ParameterOption, 0)
parameter.Value = ptr.String("default")
}
}

if err := IsValidParameters(manifestResult.Arguments.Parameters); err != nil {
Expand Down
18 changes: 18 additions & 0 deletions pkg/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ func (s SystemConfig) NodePoolOptions() (options []*NodePoolOption, err error) {
return
}

// NodePoolOptionsAsParameters returns the NodePool options as []*ParameterOption
func (s SystemConfig) NodePoolOptionsAsParameters() (result []*ParameterOption, err error) {
nodePoolOptions, err := s.NodePoolOptions()
if err != nil {
return nil, err
}

result = make([]*ParameterOption, 0)
for _, option := range nodePoolOptions {
result = append(result, &ParameterOption{
Name: option.Name,
Value: option.Value,
})
}

return
}

// NodePoolOptionByValue returns the nodePoolOption based on a given value
func (s SystemConfig) NodePoolOptionByValue(value string) (option *NodePoolOption, err error) {
options, err := s.NodePoolOptions()
Expand Down
Loading