Skip to content

Commit

Permalink
Fix integration tests/Fix MULTIUSER= false usecase
Browse files Browse the repository at this point in the history
Cover MULTIUSER=false usecase/Standalone pipeline installation.
In this case the namespace doesn't have `user` annotation and
there is no need to provide `kubeflow-userid` Header when making
a request against kfp-api-server

Signed-off-by: Diana Atanasova <[email protected]>
  • Loading branch information
difince committed Jun 29, 2022
1 parent 9c3fb15 commit 0b2d418
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 20 deletions.
6 changes: 5 additions & 1 deletion backend/src/agent/persistence/client/kubernetes_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"context"
"fmt"
"os"
"time"

"github.com/cenkalti/backoff"
Expand Down Expand Up @@ -30,9 +31,12 @@ func (c *KubernetesCore) NamespaceClient() v1.NamespaceInterface {
}

func (c *KubernetesCore) GetNamespaceOwner(namespace string) (string, error) {
if os.Getenv("MULTIUSER") == "" || os.Getenv("MULTIUSER") == "false" {
return "", nil
}
ns, err := c.NamespaceClient().Get(context.Background(), namespace, metav1.GetOptions{})
if err != nil {
return "", err
return "", errors.Wrapf(err, fmt.Sprintf("failed to get namespace '%v'", namespace))
}
owner, ok := ns.Annotations["owner"]
if !ok {
Expand Down
14 changes: 10 additions & 4 deletions backend/src/agent/persistence/client/pipeline_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ func (p *PipelineClient) ReportScheduledWorkflow(swf *util.ScheduledWorkflow) er
// ReadArtifact reads artifact content from run service. If the artifact is not present, returns
// nil response.
func (p *PipelineClient) ReadArtifact(request *api.ReadArtifactRequest, user string) (*api.ReadArtifactResponse, error) {
pctx := metadata.AppendToOutgoingContext(context.Background(), getKubeflowUserIDHeader(),
getKubeflowUserIDPrefix()+user)
pctx := context.Background()
if user != "" {
pctx = metadata.AppendToOutgoingContext(pctx, getKubeflowUserIDHeader(),
getKubeflowUserIDPrefix()+user)
}
ctx, cancel := context.WithTimeout(pctx, time.Minute)
defer cancel()

Expand All @@ -159,8 +162,11 @@ func (p *PipelineClient) ReadArtifact(request *api.ReadArtifactRequest, user str

// ReportRunMetrics reports run metrics to run service.
func (p *PipelineClient) ReportRunMetrics(request *api.ReportRunMetricsRequest, user string) (*api.ReportRunMetricsResponse, error) {
pctx := metadata.AppendToOutgoingContext(context.Background(), getKubeflowUserIDHeader(),
getKubeflowUserIDPrefix()+user)
pctx := context.Background()
if user != "" {
pctx = metadata.AppendToOutgoingContext(pctx, getKubeflowUserIDHeader(),
getKubeflowUserIDPrefix()+user)
}
ctx, cancel := context.WithTimeout(pctx, time.Minute)
defer cancel()

Expand Down
11 changes: 5 additions & 6 deletions backend/third_party_licenses/persistence_agent.csv
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ github.com/gorilla/websocket,https://github.com/gorilla/websocket/blob/v1.4.2/LI
github.com/grpc-ecosystem/grpc-gateway,https://github.com/grpc-ecosystem/grpc-gateway/blob/v1.16.0/LICENSE.txt,BSD-3-Clause
github.com/hashicorp/golang-lru,https://github.com/hashicorp/golang-lru/blob/v0.5.4/LICENSE,MPL-2.0
github.com/hashicorp/hcl,https://github.com/hashicorp/hcl/blob/v1.0.0/LICENSE,MPL-2.0
github.com/huandu/xstrings,https://github.com/huandu/xstrings/blob/v1.3.2/LICENSE,MIT
github.com/imdario/mergo,https://github.com/imdario/mergo/blob/v0.3.12/LICENSE,BSD-3-Clause
github.com/josharian/intern,https://github.com/josharian/intern/blob/v1.0.0/license.md,MIT
github.com/json-iterator/go,https://github.com/json-iterator/go/blob/v1.1.11/LICENSE,MIT
Expand All @@ -47,21 +48,19 @@ github.com/mitchellh/reflectwalk,https://github.com/mitchellh/reflectwalk/blob/v
github.com/moby/spdystream,https://github.com/moby/spdystream/blob/v0.2.0/LICENSE,Apache-2.0
github.com/modern-go/concurrent,https://github.com/modern-go/concurrent/blob/bacd9c7ef1dd/LICENSE,Apache-2.0
github.com/modern-go/reflect2,https://github.com/modern-go/reflect2/blob/v1.0.1/LICENSE,Apache-2.0
github.com/pelletier/go-toml,https://github.com/pelletier/go-toml/blob/v1.9.3/LICENSE,Apache-2.0
github.com/oliveagle/jsonpath,https://github.com/oliveagle/jsonpath/blob/2e52cf6e6852/LICENSE,MIT
github.com/pelletier/go-toml,https://github.com/pelletier/go-toml/blob/v1.9.3/LICENSE,Apache-2.0
github.com/pkg/errors,https://github.com/pkg/errors/blob/v0.9.1/LICENSE,BSD-2-Clause
github.com/shopspring/decimal,https://github.com/shopspring/decimal/blob/v1.2.0/LICENSE,MIT
github.com/sirupsen/logrus,https://github.com/sirupsen/logrus/blob/v1.7.0/LICENSE,MIT
github.com/spf13/cast,https://github.com/spf13/cast/blob/v1.3.1/LICENSE,MIT
github.com/spf13/pflag,https://github.com/spf13/pflag/blob/v1.0.5/LICENSE,BSD-3-Clause
github.com/valyala/bytebufferpool,https://github.com/valyala/bytebufferpool/blob/v1.0.0/LICENSE,MIT
github.com/valyala/fasttemplate,https://github.com/valyala/fasttemplate/blob/v1.1.0/LICENSE,MIT
github.com/spf13/afero,https://github.com/spf13/afero/blob/v1.6.0/LICENSE.txt,Apache-2.0
github.com/spf13/cast,https://github.com/spf13/cast/blob/v1.3.1/LICENSE,MIT
github.com/spf13/jwalterweatherman,https://github.com/spf13/jwalterweatherman/blob/v1.1.0/LICENSE,MIT
github.com/spf13/pflag,https://github.com/spf13/pflag/blob/v1.0.5/LICENSE,BSD-3-Clause
github.com/spf13/viper,https://github.com/spf13/viper/blob/v1.8.1/LICENSE,MIT
github.com/subosito/gotenv,https://github.com/subosito/gotenv/blob/v1.2.0/LICENSE,MIT
github.com/valyala/bytebufferpool,https://github.com/valyala/bytebufferpool/blob/v1.0.0/LICENSE,MIT
github.com/valyala/fasttemplate,https://github.com/valyala/fasttemplate/blob/v1.1.0/LICENSE,MIT
go.mongodb.org/mongo-driver,https://github.com/mongodb/mongo-go-driver/blob/v1.4.4/LICENSE,Apache-2.0
golang.org/x/crypto,https://cs.opensource.google/go/x/crypto/+/a769d52b:LICENSE,BSD-3-Clause
golang.org/x/net,https://cs.opensource.google/go/x/net/+/fe4d6282:LICENSE,BSD-3-Clause
Expand All @@ -79,7 +78,7 @@ gopkg.in/yaml.v2,https://github.com/go-yaml/yaml/blob/v2.4.0/LICENSE,Apache-2.0
gopkg.in/yaml.v3,https://github.com/go-yaml/yaml/blob/496545a6307b/LICENSE,MIT
k8s.io/api,https://github.com/kubernetes/api/blob/v0.21.5/LICENSE,Apache-2.0
k8s.io/apimachinery/pkg,https://github.com/kubernetes/apimachinery/blob/v0.21.5/LICENSE,Apache-2.0
k8s.io/apimachinery/third_party/forked/golang/reflect,https://github.com/kubernetes/apimachinery/blob/v0.21.5/third_party/forked/golang/LICENSE,BSD-3-Clause
k8s.io/apimachinery/third_party/forked/golang,https://github.com/kubernetes/apimachinery/blob/v0.21.5/third_party/forked/golang/LICENSE,BSD-3-Clause
k8s.io/client-go,https://github.com/kubernetes/client-go/blob/v0.21.5/LICENSE,Apache-2.0
k8s.io/client-go/third_party/forked/golang/template,https://github.com/kubernetes/client-go/blob/v0.21.5/third_party/forked/golang/LICENSE,BSD-3-Clause
k8s.io/klog/v2,https://github.com/kubernetes/klog/blob/v2.8.0/LICENSE,Apache-2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ rules:
- get
- list
- watch
- patch
- apiGroups:
- ''
resources:
- namespaces
verbs:
- get
- apiGroups:
- kubeflow.org
resources:
Expand All @@ -26,3 +19,9 @@ rules:
- get
- list
- watch
- apiGroups:
- ''
resources:
- namespaces
verbs:
- get
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ spec:
spec:
containers:
- name: ml-pipeline-persistenceagent
envFrom:
- configMapRef:
name: persistenceagent-config
env:
- name: NAMESPACE
value: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ kind: Kustomization
resources:
- cluster-role.yaml
- cluster-role-binding.yaml
configMapGenerator:
- name: persistenceagent-config
envs:
- params.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MULTIUSER=true
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,18 @@ rules:
- pipelines
- pipelines/versions
- experiments
- runs
- jobs
verbs:
- get
- list
- apiGroups:
- pipelines.kubeflow.org
resources:
- runs
verbs:
- get
- list
- readArtifact
- apiGroups:
- kubeflow.org
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ rules:
- apiGroups:
- ''
resources:
- namespace
- namespaces
verbs:
- get

0 comments on commit 0b2d418

Please sign in to comment.