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

Allow more flexible way to config the api server addr in persistence agent #867

Merged
merged 2 commits into from
Apr 24, 2019
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
7 changes: 3 additions & 4 deletions backend/src/agent/persistence/client/pipeline_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

const (
addressTemp = "%s.%s.svc.cluster.local:%s"
addressTemp = "%s:%s"
)

type PipelineClientInterface interface {
Expand All @@ -48,15 +48,14 @@ type PipelineClient struct {
}

func NewPipelineClient(
namespace string,
initializeTimeout time.Duration,
timeout time.Duration,
basePath string,
mlPipelineServiceName string,
mlPipelineServiceHttpPort string,
mlPipelineServiceGRPCPort string) (*PipelineClient, error) {
httpAddress := fmt.Sprintf(addressTemp, mlPipelineServiceName, namespace, mlPipelineServiceHttpPort)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead, can you parameterize the domain name, and give default value "local"?
%s.%s.svc.cluster.%s:%s

It would be easier for customizations in future. we don't assume api and persistentagent in the same namespace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to put "cluster" together with "local", as this field represents , https://github.com/kubernetes/dns/blob/master/docs/specification.md#21---definitions. If we go that way, we'll have three configs to generate the full service name: ..svc.. Another way (just as the diff) would be, just using one config to config the full path, which includes the three configs aforementioned.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think these deserves flexible configurations so having a "zone" parameter with default value cluster.local make sense.
With that it's easy to change namespace without changing anything else.
WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, I'm ok with 1 config or 3 configs. Another thing is, we need to introduce another config "informerNamespace" in #901. I used to think about releasing "namespace" config here to replace "informerNamespace", to keep consistent with #851 swf.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good. do you want to do it as part of this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the diff to remove "namespace" which is not needed anymore.

grpcAddress := fmt.Sprintf(addressTemp, mlPipelineServiceName, namespace, mlPipelineServiceGRPCPort)
httpAddress := fmt.Sprintf(addressTemp, mlPipelineServiceName, mlPipelineServiceHttpPort)
grpcAddress := fmt.Sprintf(addressTemp, mlPipelineServiceName, mlPipelineServiceGRPCPort)
err := util.WaitForAPIAvailable(initializeTimeout, basePath, httpAddress)
if err != nil {
return nil, errors.Wrapf(err,
Expand Down
5 changes: 0 additions & 5 deletions backend/src/agent/persistence/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package main

import (
"flag"
"os"
"time"

workflowclientSet "github.com/argoproj/argo/pkg/client/clientset/versioned"
Expand All @@ -34,7 +33,6 @@ import (
var (
masterURL string
kubeconfig string
namespace string
initializeTimeout time.Duration
timeout time.Duration
mlPipelineAPIServerName string
Expand All @@ -47,7 +45,6 @@ var (
const (
kubeconfigFlagName = "kubeconfig"
masterFlagName = "master"
namespaceFlagName = "namespace"
initializationTimeoutFlagName = "initializeTimeout"
timeoutFlagName = "timeout"
mlPipelineAPIServerBasePathFlagName = "mlPipelineAPIServerBasePath"
Expand Down Expand Up @@ -81,7 +78,6 @@ func main() {
workflowInformerFactory := workflowinformers.NewSharedInformerFactory(workflowClient, time.Second*30)

pipelineClient, err := client.NewPipelineClient(
namespace,
initializeTimeout,
timeout,
mlPipelineAPIServerBasePath,
Expand Down Expand Up @@ -109,7 +105,6 @@ func main() {
func init() {
flag.StringVar(&kubeconfig, kubeconfigFlagName, "", "Path to a kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&masterURL, masterFlagName, "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&namespace, namespaceFlagName, os.Getenv("POD_NAMESPACE"), "The namespace the ML pipeline API server is deployed to")
flag.DurationVar(&initializeTimeout, initializationTimeoutFlagName, 2*time.Minute, "Duration to wait for initialization of the ML pipeline API server.")
flag.DurationVar(&timeout, timeoutFlagName, 1*time.Minute, "Duration to wait for calls to complete.")
flag.StringVar(&mlPipelineAPIServerName, mlPipelineAPIServerNameFlagName, "ml-pipeline", "Name of the ML pipeline API server.")
Expand Down