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

chore: server should skip sample load if path DNE #10833

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions backend/src/apiserver/client/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/pkg/errors"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"os"
)

func getKubernetesClientset(clientParams util.ClientParameters) (*kubernetes.Clientset, error) {
Expand All @@ -35,3 +36,15 @@ func getKubernetesClientset(clientParams util.ClientParameters) (*kubernetes.Cli
}
return clientSet, nil
}

// PathExists exists returns whether the given file or directory exists
func PathExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
12 changes: 12 additions & 0 deletions backend/src/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"encoding/json"
"flag"
"fmt"
"github.com/kubeflow/pipelines/backend/src/apiserver/client"
"io"
"io/ioutil"
"math"
Expand Down Expand Up @@ -252,6 +253,17 @@ func loadSamples(resourceManager *resource.ResourceManager) error {
glog.Infof("Samples already loaded in the past. Skip loading.")
return nil
}

pathExists, err := client.PathExists(*sampleConfigPath)
if err != nil {
return err
}

if !pathExists {
glog.Infof("No samples path provided, skipping loading samples..")
return nil
}

configBytes, err := ioutil.ReadFile(*sampleConfigPath)
if err != nil {
return fmt.Errorf("failed to read sample configurations file. Err: %v", err)
Expand Down
Loading