Skip to content

Commit

Permalink
Merge pull request #535 from zrss/add-param-for-svc
Browse files Browse the repository at this point in the history
Add the --publish-not-ready-addresses param for the svc plugin
  • Loading branch information
volcano-sh-bot authored Nov 18, 2019
2 parents 7e94a94 + 649dad7 commit 7223b6b
Showing 1 changed file with 18 additions and 0 deletions.
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,
"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

0 comments on commit 7223b6b

Please sign in to comment.