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

Add the --publish-not-ready-addresses param for the svc plugin #535

Merged
merged 1 commit into from
Nov 18, 2019
Merged
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
18 changes: 18 additions & 0 deletions pkg/controllers/job/plugins/svc/svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package svc

import (
"flag"
"fmt"
"strings"

Expand All @@ -38,19 +39,35 @@ type servicePlugin struct {
pluginArguments []string

Clientset pluginsinterface.PluginClientset

// flag parse args
publishNotReadyAddresses bool
}

// New creates service plugin
func New(client pluginsinterface.PluginClientset, arguments []string) pluginsinterface.PluginInterface {
servicePlugin := servicePlugin{pluginArguments: arguments, Clientset: client}

servicePlugin.addFlags()

return &servicePlugin
}

func (sp *servicePlugin) Name() string {
return "svc"
}

func (sp *servicePlugin) addFlags() {
flagSet := flag.NewFlagSet(sp.Name(), flag.ContinueOnError)
flagSet.BoolVar(&sp.publishNotReadyAddresses, "publish-not-ready-addresses", sp.publishNotReadyAddresses,
Copy link
Member

Choose a reason for hiding this comment

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

maybe set default value to true :)

"set publishNotReadyAddresses of svc to true")

if err := flagSet.Parse(sp.pluginArguments); err != nil {
glog.Errorf("plugin %s flagset parse failed, err: %v", sp.Name(), err)
}
return
}

func (sp *servicePlugin) OnPodCreate(pod *v1.Pod, job *batch.Job) error {
// use podName.serviceName as default pod DNS domain
if len(pod.Spec.Hostname) == 0 {
Expand Down Expand Up @@ -148,6 +165,7 @@ func (sp *servicePlugin) createServiceIfNotExist(job *batch.Job) error {
batch.JobNameKey: job.Name,
batch.JobNamespaceKey: job.Namespace,
},
PublishNotReadyAddresses: sp.publishNotReadyAddresses,
Ports: []v1.ServicePort{
{
Name: "placeholder-volcano",
Expand Down