Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw committed Oct 17, 2023
1 parent 5bcd1bf commit 8bbcd21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions flytepropeller/pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import (
"github.com/flyteorg/flyte/flytestdlib/logger"
"github.com/flyteorg/flyte/flytestdlib/promutils"
"github.com/flyteorg/flyte/flytestdlib/promutils/labeled"
resolver2 "github.com/flyteorg/flyte/flytestdlib/resolver"
k8sResolver "github.com/flyteorg/flyte/flytestdlib/resolver"
"github.com/flyteorg/flyte/flytestdlib/storage"
)

Expand Down Expand Up @@ -554,7 +554,7 @@ func StartController(ctx context.Context, cfg *config.Config, defaultNamespace s
return errors.Wrapf(err, "error building Kubernetes Clientset")
}

resolver.Register(resolver2.NewBuilder(kubeClient, resolver2.K8sSchema))
resolver.Register(k8sResolver.NewBuilder(ctx, kubeClient, k8sResolver.K8sSchema))

Check warning on line 558 in flytepropeller/pkg/controller/controller.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/controller.go#L557-L558

Added lines #L557 - L558 were not covered by tests
flyteworkflowClient, err := clientset.NewForConfig(kubecfg)
if err != nil {
Expand Down
14 changes: 8 additions & 6 deletions flytestdlib/resolver/k8s_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ type targetInfo struct {
}

func (t targetInfo) String() string {
return fmt.Sprintf("kubernetes:///%s.%s:%s", t.serviceNamespace, t.serviceName, t.port)
return fmt.Sprintf("%s:///%s.%s:%s", K8sSchema, t.serviceNamespace, t.serviceName, t.port)
}

// NewBuilder creates a kubeBuilder which is used by grpc resolver.
func NewBuilder(client kubernetes.Interface, schema string) resolver.Builder {
func NewBuilder(ctx context.Context, client kubernetes.Interface, schema string) resolver.Builder {
return &kubeBuilder{
ctx: ctx,
k8sClient: client,
schema: schema,
}
}

type kubeBuilder struct {
ctx context.Context
k8sClient kubernetes.Interface
schema string
}
Expand All @@ -63,14 +65,14 @@ func splitServicePortNamespace(hpn string) (service, port, namespace string) {
func parseResolverTarget(target resolver.Target) (targetInfo, error) {
var service, port, namespace string
if target.URL.Host == "" {
// kubernetes:///service.namespace:port
// k8s:///service.namespace:port
service, port, namespace = splitServicePortNamespace(target.Endpoint())
} else if target.URL.Port() == "" && target.Endpoint() != "" {
// kubernetes://namespace/service:port
// k8s://namespace/service:port
service, port, _ = splitServicePortNamespace(target.Endpoint())
namespace = target.URL.Hostname()
} else {
// kubernetes://service.namespace:port
// k8s://service.namespace:port
service, port, namespace = splitServicePortNamespace(target.URL.Host)
}

Expand All @@ -92,7 +94,7 @@ func (b *kubeBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts
return nil, err
}

ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(b.ctx)
r := &kResolver{
target: ti,
ctx: ctx,
Expand Down

0 comments on commit 8bbcd21

Please sign in to comment.