From 5d0595a668851ff500991fdc04d2362803f4a142 Mon Sep 17 00:00:00 2001 From: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> Date: Tue, 10 Sep 2024 22:29:20 -0700 Subject: [PATCH 1/2] feat(ws): use controller-runtime with backend Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> --- workspaces/backend/api/app.go | 47 +++++------ workspaces/backend/api/errors.go | 32 ++++---- .../backend/api/healthcheck__handler_test.go | 10 ++- workspaces/backend/api/healthcheck_handler.go | 27 +++++-- workspaces/backend/api/helpers.go | 4 +- workspaces/backend/api/middleware.go | 6 +- workspaces/backend/cmd/main.go | 64 ++++++++++----- workspaces/backend/go.mod | 31 ++++++-- workspaces/backend/go.sum | 68 ++++++++++++---- .../{ => internal}/config/environment.go | 0 .../{ => internal}/data/health_check_model.go | 0 .../backend/{ => internal}/data/models.go | 0 .../{integrations => internal/helper}/k8s.go | 41 +++++----- workspaces/backend/internal/server/server.go | 79 +++++++++++++++++++ 14 files changed, 295 insertions(+), 114 deletions(-) rename workspaces/backend/{ => internal}/config/environment.go (100%) rename workspaces/backend/{ => internal}/data/health_check_model.go (100%) rename workspaces/backend/{ => internal}/data/models.go (100%) rename workspaces/backend/{integrations => internal/helper}/k8s.go (50%) create mode 100644 workspaces/backend/internal/server/server.go diff --git a/workspaces/backend/api/app.go b/workspaces/backend/api/app.go index 90f4bda0..e7f9444f 100644 --- a/workspaces/backend/api/app.go +++ b/workspaces/backend/api/app.go @@ -17,14 +17,15 @@ limitations under the License. package api import ( - "fmt" - "github.com/kubeflow/notebooks/workspaces/backend/config" - "github.com/kubeflow/notebooks/workspaces/backend/data" - "github.com/kubeflow/notebooks/workspaces/backend/integrations" "log/slog" "net/http" "github.com/julienschmidt/httprouter" + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/kubeflow/notebooks/workspaces/backend/internal/config" + "github.com/kubeflow/notebooks/workspaces/backend/internal/data" ) const ( @@ -33,33 +34,35 @@ const ( ) type App struct { - config config.EnvConfig - logger *slog.Logger - models data.Models - kubernetesClient *integrations.KubernetesClient -} + Config config.EnvConfig + logger *slog.Logger + models data.Models -func NewApp(cfg config.EnvConfig, logger *slog.Logger) (*App, error) { - k8sClient, err := integrations.NewKubernetesClient() - if err != nil { - return nil, fmt.Errorf("failed to create Kubernetes client: %w", err) - } + client.Client + Scheme *runtime.Scheme +} +// NewApp creates a new instance of the app +func NewApp(cfg config.EnvConfig, logger *slog.Logger, client client.Client, scheme *runtime.Scheme) (*App, error) { app := &App{ - config: cfg, - logger: logger, - kubernetesClient: k8sClient, + Config: cfg, + logger: logger, + models: data.NewModels(), + + Client: client, + Scheme: scheme, } return app, nil } -func (app *App) Routes() http.Handler { +// Routes returns the HTTP handler for the app +func (a *App) Routes() http.Handler { router := httprouter.New() - router.NotFound = http.HandlerFunc(app.notFoundResponse) - router.MethodNotAllowed = http.HandlerFunc(app.methodNotAllowedResponse) + router.NotFound = http.HandlerFunc(a.notFoundResponse) + router.MethodNotAllowed = http.HandlerFunc(a.methodNotAllowedResponse) - router.GET(HealthCheckPath, app.HealthcheckHandler) + router.GET(HealthCheckPath, a.HealthcheckHandler) - return app.RecoverPanic(app.enableCORS(router)) + return a.RecoverPanic(a.enableCORS(router)) } diff --git a/workspaces/backend/api/errors.go b/workspaces/backend/api/errors.go index 77520eee..51b9d216 100644 --- a/workspaces/backend/api/errors.go +++ b/workspaces/backend/api/errors.go @@ -33,16 +33,16 @@ type ErrorResponse struct { Message string `json:"message"` } -func (app *App) LogError(r *http.Request, err error) { +func (a *App) LogError(r *http.Request, err error) { var ( method = r.Method uri = r.URL.RequestURI() ) - app.logger.Error(err.Error(), "method", method, "uri", uri) + a.logger.Error(err.Error(), "method", method, "uri", uri) } -func (app *App) badRequestResponse(w http.ResponseWriter, r *http.Request, err error) { +func (a *App) badRequestResponse(w http.ResponseWriter, r *http.Request, err error) { httpError := &HTTPError{ StatusCode: http.StatusBadRequest, ErrorResponse: ErrorResponse{ @@ -50,23 +50,23 @@ func (app *App) badRequestResponse(w http.ResponseWriter, r *http.Request, err e Message: err.Error(), }, } - app.errorResponse(w, r, httpError) + a.errorResponse(w, r, httpError) } -func (app *App) errorResponse(w http.ResponseWriter, r *http.Request, error *HTTPError) { +func (a *App) errorResponse(w http.ResponseWriter, r *http.Request, error *HTTPError) { env := Envelope{"error": error} - err := app.WriteJSON(w, error.StatusCode, env, nil) + err := a.WriteJSON(w, error.StatusCode, env, nil) if err != nil { - app.LogError(r, err) + a.LogError(r, err) w.WriteHeader(error.StatusCode) } } -func (app *App) serverErrorResponse(w http.ResponseWriter, r *http.Request, err error) { - app.LogError(r, err) +func (a *App) serverErrorResponse(w http.ResponseWriter, r *http.Request, err error) { + a.LogError(r, err) httpError := &HTTPError{ StatusCode: http.StatusInternalServerError, @@ -75,10 +75,10 @@ func (app *App) serverErrorResponse(w http.ResponseWriter, r *http.Request, err Message: "the server encountered a problem and could not process your request", }, } - app.errorResponse(w, r, httpError) + a.errorResponse(w, r, httpError) } -func (app *App) notFoundResponse(w http.ResponseWriter, r *http.Request) { +func (a *App) notFoundResponse(w http.ResponseWriter, r *http.Request) { httpError := &HTTPError{ StatusCode: http.StatusNotFound, @@ -87,10 +87,10 @@ func (app *App) notFoundResponse(w http.ResponseWriter, r *http.Request) { Message: "the requested resource could not be found", }, } - app.errorResponse(w, r, httpError) + a.errorResponse(w, r, httpError) } -func (app *App) methodNotAllowedResponse(w http.ResponseWriter, r *http.Request) { +func (a *App) methodNotAllowedResponse(w http.ResponseWriter, r *http.Request) { httpError := &HTTPError{ StatusCode: http.StatusMethodNotAllowed, @@ -99,10 +99,10 @@ func (app *App) methodNotAllowedResponse(w http.ResponseWriter, r *http.Request) Message: fmt.Sprintf("the %s method is not supported for this resource", r.Method), }, } - app.errorResponse(w, r, httpError) + a.errorResponse(w, r, httpError) } -func (app *App) failedValidationResponse(w http.ResponseWriter, r *http.Request, errors map[string]string) { +func (a *App) failedValidationResponse(w http.ResponseWriter, r *http.Request, errors map[string]string) { message, err := json.Marshal(errors) if err != nil { @@ -115,5 +115,5 @@ func (app *App) failedValidationResponse(w http.ResponseWriter, r *http.Request, Message: string(message), }, } - app.errorResponse(w, r, httpError) + a.errorResponse(w, r, httpError) } diff --git a/workspaces/backend/api/healthcheck__handler_test.go b/workspaces/backend/api/healthcheck__handler_test.go index fd3939a1..c95ace93 100644 --- a/workspaces/backend/api/healthcheck__handler_test.go +++ b/workspaces/backend/api/healthcheck__handler_test.go @@ -18,18 +18,20 @@ package api import ( "encoding/json" - "github.com/kubeflow/notebooks/workspaces/backend/config" - "github.com/kubeflow/notebooks/workspaces/backend/data" - "github.com/stretchr/testify/assert" "io" "net/http" "net/http/httptest" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/kubeflow/notebooks/workspaces/backend/internal/config" + "github.com/kubeflow/notebooks/workspaces/backend/internal/data" ) func TestHealthCheckHandler(t *testing.T) { - app := App{config: config.EnvConfig{ + app := App{Config: config.EnvConfig{ Port: 4000, }} diff --git a/workspaces/backend/api/healthcheck_handler.go b/workspaces/backend/api/healthcheck_handler.go index 7c533357..98f9219a 100644 --- a/workspaces/backend/api/healthcheck_handler.go +++ b/workspaces/backend/api/healthcheck_handler.go @@ -19,20 +19,37 @@ package api import ( "github.com/julienschmidt/httprouter" "net/http" + + kubefloworgv1beta1 "github.com/kubeflow/notebooks/workspaces/controller/api/v1beta1" ) -func (app *App) HealthcheckHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { +func (a *App) HealthcheckHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { + + // list Workspaces + // + // TODO: remove after testing + // + workspaceList := &kubefloworgv1beta1.WorkspaceList{} + err := a.List(r.Context(), workspaceList) + if err != nil { + a.serverErrorResponse(w, r, err) + return + } + workspaceListString := "" + for _, workspace := range workspaceList.Items { + workspaceListString += workspace.Name + " " + } - healthCheck, err := app.models.HealthCheck.HealthCheck(Version) + healthCheck, err := a.models.HealthCheck.HealthCheck(workspaceListString) // TODO: revert to .HealthCheck(Version) if err != nil { - app.serverErrorResponse(w, r, err) + a.serverErrorResponse(w, r, err) return } - err = app.WriteJSON(w, http.StatusOK, healthCheck, nil) + err = a.WriteJSON(w, http.StatusOK, healthCheck, nil) if err != nil { - app.serverErrorResponse(w, r, err) + a.serverErrorResponse(w, r, err) } } diff --git a/workspaces/backend/api/helpers.go b/workspaces/backend/api/helpers.go index b57e016b..b8c0dd17 100644 --- a/workspaces/backend/api/helpers.go +++ b/workspaces/backend/api/helpers.go @@ -27,7 +27,7 @@ import ( type Envelope map[string]any -func (app *App) WriteJSON(w http.ResponseWriter, status int, data any, headers http.Header) error { +func (a *App) WriteJSON(w http.ResponseWriter, status int, data any, headers http.Header) error { js, err := json.MarshalIndent(data, "", "\t") @@ -48,7 +48,7 @@ func (app *App) WriteJSON(w http.ResponseWriter, status int, data any, headers h return nil } -func (app *App) ReadJSON(w http.ResponseWriter, r *http.Request, dst any) error { +func (a *App) ReadJSON(w http.ResponseWriter, r *http.Request, dst any) error { maxBytes := 1_048_576 r.Body = http.MaxBytesReader(w, r.Body, int64(maxBytes)) diff --git a/workspaces/backend/api/middleware.go b/workspaces/backend/api/middleware.go index 2da53927..c59a8e55 100644 --- a/workspaces/backend/api/middleware.go +++ b/workspaces/backend/api/middleware.go @@ -21,12 +21,12 @@ import ( "net/http" ) -func (app *App) RecoverPanic(next http.Handler) http.Handler { +func (a *App) RecoverPanic(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer func() { if err := recover(); err != nil { w.Header().Set("Connection", "close") - app.serverErrorResponse(w, r, fmt.Errorf("%s", err)) + a.serverErrorResponse(w, r, fmt.Errorf("%s", err)) } }() @@ -34,7 +34,7 @@ func (app *App) RecoverPanic(next http.Handler) http.Handler { }) } -func (app *App) enableCORS(next http.Handler) http.Handler { +func (a *App) enableCORS(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // TODO(ederign) restrict CORS to a much smaller set of trusted origins. // TODO(ederign) deal with preflight requests diff --git a/workspaces/backend/cmd/main.go b/workspaces/backend/cmd/main.go index 93e2e4f8..90d72a34 100644 --- a/workspaces/backend/cmd/main.go +++ b/workspaces/backend/cmd/main.go @@ -18,14 +18,17 @@ package main import ( "flag" - "fmt" - application "github.com/kubeflow/notebooks/workspaces/backend/api" - "github.com/kubeflow/notebooks/workspaces/backend/config" "log/slog" - "net/http" "os" "strconv" - "time" + + ctrl "sigs.k8s.io/controller-runtime" + metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" + + application "github.com/kubeflow/notebooks/workspaces/backend/api" + "github.com/kubeflow/notebooks/workspaces/backend/internal/config" + "github.com/kubeflow/notebooks/workspaces/backend/internal/helper" + "github.com/kubeflow/notebooks/workspaces/backend/internal/server" ) func main() { @@ -34,26 +37,49 @@ func main() { logger := slog.New(slog.NewTextHandler(os.Stdout, nil)) - app, err := application.NewApp(cfg, logger) + kubeconfig, err := helper.GetKubeconfig() if err != nil { - logger.Error(err.Error()) + logger.Error("failed to get kubeconfig", "error", err) os.Exit(1) } - - srv := &http.Server{ - Addr: fmt.Sprintf(":%d", cfg.Port), - Handler: app.Routes(), - IdleTimeout: time.Minute, - ReadTimeout: 30 * time.Second, - WriteTimeout: 30 * time.Second, - ErrorLog: slog.NewLogLogger(logger.Handler(), slog.LevelError), + scheme, err := helper.BuildScheme() + if err != nil { + logger.Error("failed to build Kubernetes scheme", "error", err) + os.Exit(1) + } + mgr, err := ctrl.NewManager(kubeconfig, ctrl.Options{ + Scheme: scheme, + Metrics: metricsserver.Options{ + BindAddress: "0", // disable metrics serving + }, + HealthProbeBindAddress: "0", // disable health probe serving + LeaderElection: false, + }) + if err != nil { + logger.Error("unable to create manager", "error", err) + os.Exit(1) } - logger.Info("starting server", "addr", srv.Addr) + app, err := application.NewApp(cfg, logger, mgr.GetClient(), mgr.GetScheme()) + if err != nil { + logger.Error("failed to create app", "error", err) + os.Exit(1) + } + svr, err := server.NewServer(app, logger) + if err != nil { + logger.Error("failed to create server", "error", err) + os.Exit(1) + } + if err := svr.SetupWithManager(mgr); err != nil { + logger.Error("failed to setup server with manager", "error", err) + os.Exit(1) + } - err = srv.ListenAndServe() - logger.Error(err.Error()) - os.Exit(1) + logger.Info("starting manager") + if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { + logger.Error("problem running manager", "error", err) + os.Exit(1) + } } func getEnv(key, defaultVal string) string { diff --git a/workspaces/backend/go.mod b/workspaces/backend/go.mod index 5a562bd7..d981eff8 100644 --- a/workspaces/backend/go.mod +++ b/workspaces/backend/go.mod @@ -1,51 +1,70 @@ module github.com/kubeflow/notebooks/workspaces/backend -go 1.22.2 +go 1.22.0 + +replace github.com/kubeflow/notebooks/workspaces/controller => ../controller require ( github.com/julienschmidt/httprouter v1.3.0 + github.com/kubeflow/notebooks/workspaces/controller v0.0.0 github.com/stretchr/testify v1.8.4 - k8s.io/apimachinery v0.30.1 - k8s.io/client-go v0.30.1 + k8s.io/apimachinery v0.30.4 + k8s.io/client-go v0.30.4 + sigs.k8s.io/controller-runtime v0.18.5 ) require ( + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/evanphx/json-patch/v5 v5.9.0 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/imdario/mergo v0.3.6 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect golang.org/x/net v0.23.0 // indirect - golang.org/x/oauth2 v0.10.0 // indirect + golang.org/x/oauth2 v0.12.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect + gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.30.1 // indirect + k8s.io/api v0.30.4 // indirect + k8s.io/apiextensions-apiserver v0.30.1 // indirect k8s.io/klog/v2 v2.120.1 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/workspaces/backend/go.sum b/workspaces/backend/go.sum index a1c9e0d9..21cde436 100644 --- a/workspaces/backend/go.sum +++ b/workspaces/backend/go.sum @@ -1,11 +1,23 @@ +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= +github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= +github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= +github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= @@ -16,6 +28,8 @@ github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEe github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= @@ -50,6 +64,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -57,12 +73,22 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= -github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= -github.com/onsi/gomega v1.31.0 h1:54UJxxj6cPInHS3a35wm6BK/F9nHYueZ1NVujHDrnXE= -github.com/onsi/gomega v1.31.0/go.mod h1:DW9aCi7U6Yi40wNVAvT6kzFnEVEI5n3DloYBiKiT6zk= +github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8= +github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= +github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk= +github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= +github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -78,9 +104,17 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= +golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -90,8 +124,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= -golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= +golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4= +golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -119,6 +153,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= +gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= @@ -134,21 +170,25 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.30.1 h1:kCm/6mADMdbAxmIh0LBjS54nQBE+U4KmbCfIkF5CpJY= -k8s.io/api v0.30.1/go.mod h1:ddbN2C0+0DIiPntan/bye3SW3PdwLa11/0yqwvuRrJM= -k8s.io/apimachinery v0.30.1 h1:ZQStsEfo4n65yAdlGTfP/uSHMQSoYzU/oeEbkmF7P2U= -k8s.io/apimachinery v0.30.1/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/client-go v0.30.1 h1:uC/Ir6A3R46wdkgCV3vbLyNOYyCJ8oZnjtJGKfytl/Q= -k8s.io/client-go v0.30.1/go.mod h1:wrAqLNs2trwiCH/wxxmT/x3hKVH9PuV0GGW0oDoHVqc= +k8s.io/api v0.30.4 h1:XASIELmW8w8q0i1Y4124LqPoWMycLjyQti/fdYHYjCs= +k8s.io/api v0.30.4/go.mod h1:ZqniWRKu7WIeLijbbzetF4U9qZ03cg5IRwl8YVs8mX0= +k8s.io/apiextensions-apiserver v0.30.1 h1:4fAJZ9985BmpJG6PkoxVRpXv9vmPUOVzl614xarePws= +k8s.io/apiextensions-apiserver v0.30.1/go.mod h1:R4GuSrlhgq43oRY9sF2IToFh7PVlF1JjfWdoG3pixk4= +k8s.io/apimachinery v0.30.4 h1:5QHQI2tInzr8LsT4kU/2+fSeibH1eIHswNx480cqIoY= +k8s.io/apimachinery v0.30.4/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/client-go v0.30.4 h1:eculUe+HPQoPbixfwmaSZGsKcOf7D288tH6hDAdd+wY= +k8s.io/client-go v0.30.4/go.mod h1:IBS0R/Mt0LHkNHF4E6n+SUDPG7+m2po6RZU7YHeOpzc= k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/controller-runtime v0.18.5 h1:nTHio/W+Q4aBlQMgbnC5hZb4IjIidyrizMai9P6n4Rk= +sigs.k8s.io/controller-runtime v0.18.5/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/workspaces/backend/config/environment.go b/workspaces/backend/internal/config/environment.go similarity index 100% rename from workspaces/backend/config/environment.go rename to workspaces/backend/internal/config/environment.go diff --git a/workspaces/backend/data/health_check_model.go b/workspaces/backend/internal/data/health_check_model.go similarity index 100% rename from workspaces/backend/data/health_check_model.go rename to workspaces/backend/internal/data/health_check_model.go diff --git a/workspaces/backend/data/models.go b/workspaces/backend/internal/data/models.go similarity index 100% rename from workspaces/backend/data/models.go rename to workspaces/backend/internal/data/models.go diff --git a/workspaces/backend/integrations/k8s.go b/workspaces/backend/internal/helper/k8s.go similarity index 50% rename from workspaces/backend/integrations/k8s.go rename to workspaces/backend/internal/helper/k8s.go index ddeb9b06..2b8661c1 100644 --- a/workspaces/backend/integrations/k8s.go +++ b/workspaces/backend/internal/helper/k8s.go @@ -14,40 +14,35 @@ See the License for the specific language governing permissions and limitations under the License. */ -package integrations +package helper import ( "fmt" - "k8s.io/client-go/kubernetes" - restclient "k8s.io/client-go/rest" - "k8s.io/client-go/tools/clientcmd" -) - -type KubernetesClient struct { - ClientSet *kubernetes.Clientset -} - -func NewKubernetesClient() (*KubernetesClient, error) { - clientSet, err := newClientSet() - if err != nil { - return nil, fmt.Errorf("failed to create Kubernetes clientset: %w", err) - } + "k8s.io/apimachinery/pkg/runtime" + clientRest "k8s.io/client-go/rest" + "k8s.io/client-go/tools/clientcmd" - return &KubernetesClient{ClientSet: clientSet}, nil -} + kubefloworgv1beta1 "github.com/kubeflow/notebooks/workspaces/controller/api/v1beta1" + clientgoscheme "k8s.io/client-go/kubernetes/scheme" +) -func getRestConfig() (*restclient.Config, error) { +// GetKubeconfig returns the current KUBECONFIG configuration based on the default loading rules. +func GetKubeconfig() (*clientRest.Config, error) { loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() configOverrides := &clientcmd.ConfigOverrides{} kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides) return kubeConfig.ClientConfig() } -func newClientSet() (*kubernetes.Clientset, error) { - restConfig, err := getRestConfig() - if err != nil { - return nil, err +// BuildScheme returns builds a new runtime scheme with all the necessary types registered. +func BuildScheme() (*runtime.Scheme, error) { + scheme := runtime.NewScheme() + if err := clientgoscheme.AddToScheme(scheme); err != nil { + return nil, fmt.Errorf("failed to add Kubernetes types to scheme: %w", err) + } + if err := kubefloworgv1beta1.AddToScheme(scheme); err != nil { + return nil, fmt.Errorf("failed to add Kubeflow types to scheme: %w", err) } - return kubernetes.NewForConfig(restConfig) + return scheme, nil } diff --git a/workspaces/backend/internal/server/server.go b/workspaces/backend/internal/server/server.go new file mode 100644 index 00000000..5f264f7e --- /dev/null +++ b/workspaces/backend/internal/server/server.go @@ -0,0 +1,79 @@ +package server + +import ( + "context" + "errors" + "fmt" + "github.com/kubeflow/notebooks/workspaces/backend/api" + "log/slog" + "net" + "net/http" + ctrl "sigs.k8s.io/controller-runtime" + "time" +) + +type Server struct { + logger *slog.Logger + listener net.Listener + server *http.Server +} + +func NewServer(app *api.App, logger *slog.Logger) (*Server, error) { + listener, err := net.Listen("tcp", fmt.Sprintf(":%d", app.Config.Port)) + if err != nil { + return nil, fmt.Errorf("failed to create listener: %w", err) + } + + svc := &http.Server{ + Addr: fmt.Sprintf(":%d", app.Config.Port), + Handler: app.Routes(), + IdleTimeout: 90 * time.Second, // matches http.DefaultTransport keep-alive timeout + ReadTimeout: 32 * time.Second, + ReadHeaderTimeout: 32 * time.Second, + WriteTimeout: 32 * time.Second, + ErrorLog: slog.NewLogLogger(logger.Handler(), slog.LevelError), + } + svr := &Server{ + logger: logger, + listener: listener, + server: svc, + } + + return svr, nil +} + +// SetupWithManager sets up the app with a controller-runtime manager +func (s *Server) SetupWithManager(mgr ctrl.Manager) error { + err := mgr.Add(s) + if err != nil { + return err + } + return nil +} + +// Start starts the server +// Blocks until the context is cancelled +func (s *Server) Start(ctx context.Context) error { + serverShutdown := make(chan struct{}) + go func() { + <-ctx.Done() + s.logger.Info("shutting down server") + if err := s.server.Shutdown(context.Background()); err != nil { + s.logger.Error("error shutting down server", "error", err) + } + close(serverShutdown) + }() + + s.logger.Info("starting server", "addr", s.server.Addr) + if err := s.server.Serve(s.listener); err != nil && !errors.Is(err, http.ErrServerClosed) { + return err + } + + <-serverShutdown + return nil +} + +// NeedLeaderElection returns false because this app does not need leader election from the manager +func (s *Server) NeedLeaderElection() bool { + return false +} From 9aa3297d3cf3c6920f49ea3ec581fdea4831073c Mon Sep 17 00:00:00 2001 From: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> Date: Sat, 14 Sep 2024 13:02:01 -0700 Subject: [PATCH 2/2] revert healthcheck to normal results Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> --- workspaces/backend/api/healthcheck_handler.go | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/workspaces/backend/api/healthcheck_handler.go b/workspaces/backend/api/healthcheck_handler.go index 98f9219a..57ad2d41 100644 --- a/workspaces/backend/api/healthcheck_handler.go +++ b/workspaces/backend/api/healthcheck_handler.go @@ -19,28 +19,11 @@ package api import ( "github.com/julienschmidt/httprouter" "net/http" - - kubefloworgv1beta1 "github.com/kubeflow/notebooks/workspaces/controller/api/v1beta1" ) func (a *App) HealthcheckHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { - // list Workspaces - // - // TODO: remove after testing - // - workspaceList := &kubefloworgv1beta1.WorkspaceList{} - err := a.List(r.Context(), workspaceList) - if err != nil { - a.serverErrorResponse(w, r, err) - return - } - workspaceListString := "" - for _, workspace := range workspaceList.Items { - workspaceListString += workspace.Name + " " - } - - healthCheck, err := a.models.HealthCheck.HealthCheck(workspaceListString) // TODO: revert to .HealthCheck(Version) + healthCheck, err := a.models.HealthCheck.HealthCheck(Version) if err != nil { a.serverErrorResponse(w, r, err) return