Skip to content

Commit 4060f0e

Browse files
committed
[core] Disable system proxy by default for Mesos, DCS, DDscheduler
1 parent 97b7e92 commit 4060f0e

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

core/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func setDefaults() error {
6767
viper.SetDefault("mesosAuthMode", env("AUTH_MODE", ""))
6868
viper.SetDefault("mesosCheckpoint", true)
6969
viper.SetDefault("mesosCompression", false)
70+
viper.SetDefault("mesosUseSystemProxy", false)
7071
viper.SetDefault("mesosCredentials.username", env("AUTH_USER", ""))
7172
viper.SetDefault("mesosCredentials.passwordFile", env("AUTH_PASSWORD_FILE", ""))
7273
viper.SetDefault("mesosExecutorImage", env("EXEC_IMAGE", ""))
@@ -95,7 +96,9 @@ func setDefaults() error {
9596
viper.SetDefault("dumpWorkflows", false)
9697
viper.SetDefault("configServiceUri", "apricot://127.0.0.1:47101")
9798
viper.SetDefault("dcsServiceEndpoint", "127.0.0.1:50051")
99+
viper.SetDefault("dcsServiceUseSystemProxy", false)
98100
viper.SetDefault("ddSchedulerEndpoint", "127.0.0.1:50052")
101+
viper.SetDefault("ddSchedulerUseSystemProxy", false)
99102
viper.SetDefault("integrationPlugins", []string{})
100103
viper.SetDefault("coreConfigEntry", "settings")
101104
viper.SetDefault("fmqPlugin", "OCClite")
@@ -115,6 +118,7 @@ func setFlags() error {
115118
pflag.String("mesosAuthMode", viper.GetString("mesosAuthMode"), "Method to use for Mesos authentication; specify '"+schedutil.AuthModeBasic+"' for simple HTTP authentication")
116119
pflag.Bool("mesosCheckpoint", viper.GetBool("mesosCheckpoint"), "Enable/disable agent checkpointing for framework tasks (recover from agent failure)")
117120
pflag.Bool("mesosCompression", viper.GetBool("mesosCompression"), "When true attempt to use compression for HTTP streams")
121+
pflag.Bool("mesosUseSystemProxy", viper.GetBool("mesosUseSystemProxy"), "When true the https_proxy, http_proxy and no_proxy environment variables are obeyed")
118122
pflag.String("mesosExecutorImage", viper.GetString("mesosExecutorImage"), "Name of the docker image to run the executor")
119123
pflag.Duration("mesosFailoverTimeout", viper.GetDuration("mesosFailoverTimeout"), "Framework failover timeout (recover from scheduler failure)")
120124
pflag.String("mesosFrameworkHostname", viper.GetString("mesosFrameworkHostname"), "Framework hostname that is advertised to the master")
@@ -140,7 +144,9 @@ func setFlags() error {
140144
pflag.Bool("dumpWorkflows", viper.GetBool("dumpWorkflows"), "Dump unprocessed and processed workflow files (`$PWD/wf-{,un}processed-<timestamp>.json`)")
141145
pflag.String("configServiceUri", viper.GetString("configServiceUri"), "URI of the Apricot instance (`apricot://host:port`), Consul server (`consul://`) or YAML configuration file, entry point for all configuration")
142146
pflag.String("dcsServiceEndpoint", viper.GetString("dcsServiceEndpoint"), "Endpoint of the DCS gRPC service (`host:port`)")
147+
pflag.Bool("dcsServiceUseSystemProxy", viper.GetBool("dcsServiceUseSystemProxy"), "When true the https_proxy, http_proxy and no_proxy environment variables are obeyed")
143148
pflag.String("ddSchedulerEndpoint", viper.GetString("ddSchedulerEndpoint"), "Endpoint of the DD scheduler gRPC service (`host:port`)")
149+
pflag.Bool("ddSchedulerUseSystemProxy", viper.GetBool("ddSchedulerUseSystemProxy"), "When true the https_proxy, http_proxy and no_proxy environment variables are obeyed")
144150
pflag.StringSlice("integrationPlugins", viper.GetStringSlice("integrationPlugins"), "List of integration plugins to load (default: empty)")
145151
pflag.String("coreConfigEntry", viper.GetString("coreConfigEntry"), "key for AliECS core configuration within the `aliecs` component [EXPERT SETTING]")
146152
pflag.String("fmqPlugin", viper.GetString("fmqPlugin"), "Name of the plugin for FairMQ tasks")

core/integration/dcs/client.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/AliceO2Group/Control/common/logger"
3131
dcspb "github.com/AliceO2Group/Control/core/integration/dcs/protos"
3232
"github.com/sirupsen/logrus"
33+
"github.com/spf13/viper"
3334
"google.golang.org/grpc"
3435
"google.golang.org/grpc/connectivity"
3536
)
@@ -46,7 +47,18 @@ func NewClient(cxt context.Context, cancel context.CancelFunc, endpoint string)
4647
log.WithFields(logrus.Fields{
4748
"endpoint": endpoint,
4849
}).Debug("dialing DCS client")
49-
conn, err := grpc.DialContext(cxt, endpoint, grpc.WithInsecure(), grpc.WithBlock())
50+
51+
dialOptions := []grpc.DialOption {
52+
grpc.WithInsecure(),
53+
grpc.WithBlock(),
54+
}
55+
if !viper.GetBool("dcsServiceUseSystemProxy") {
56+
dialOptions = append(dialOptions, grpc.WithNoProxy())
57+
}
58+
conn, err := grpc.DialContext(cxt,
59+
endpoint,
60+
dialOptions...,
61+
)
5062
if err != nil {
5163
log.WithField("error", err.Error()).
5264
WithField("endpoint", endpoint).

core/integration/ddsched/client.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/AliceO2Group/Control/common/logger"
3131
ddpb "github.com/AliceO2Group/Control/core/integration/ddsched/protos"
3232
"github.com/sirupsen/logrus"
33+
"github.com/spf13/viper"
3334
"google.golang.org/grpc"
3435
"google.golang.org/grpc/connectivity"
3536
)
@@ -46,7 +47,18 @@ func NewClient(cxt context.Context, cancel context.CancelFunc, endpoint string)
4647
log.WithFields(logrus.Fields{
4748
"endpoint": endpoint,
4849
}).Debug("dialing DD scheduler client")
49-
conn, err := grpc.DialContext(cxt, endpoint, grpc.WithInsecure(), grpc.WithBlock())
50+
51+
dialOptions := []grpc.DialOption {
52+
grpc.WithInsecure(),
53+
grpc.WithBlock(),
54+
}
55+
if !viper.GetBool("ddSchedulerUseSystemProxy") {
56+
dialOptions = append(dialOptions, grpc.WithNoProxy())
57+
}
58+
conn, err := grpc.DialContext(cxt,
59+
endpoint,
60+
dialOptions...,
61+
)
5062
if err != nil {
5163
log.WithField("error", err.Error()).
5264
WithField("endpoint", endpoint).

core/task/schedutil/mesosutil.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,21 @@ package schedutil
3030
import (
3131
"errors"
3232
"fmt"
33+
"net/http"
34+
"net/url"
3335
"path/filepath"
3436
"time"
3537

3638
"github.com/AliceO2Group/Control/common/logger"
37-
"github.com/mesos/mesos-go/api/v1/lib/encoding/codecs"
38-
"github.com/sirupsen/logrus"
39-
"github.com/spf13/viper"
40-
4139
"github.com/AliceO2Group/Control/common/product"
4240
"github.com/mesos/mesos-go/api/v1/lib"
41+
"github.com/mesos/mesos-go/api/v1/lib/encoding/codecs"
4342
"github.com/mesos/mesos-go/api/v1/lib/httpcli"
4443
"github.com/mesos/mesos-go/api/v1/lib/httpcli/httpsched"
4544
"github.com/mesos/mesos-go/api/v1/lib/resources"
4645
"github.com/mesos/mesos-go/api/v1/lib/scheduler/calls"
46+
"github.com/sirupsen/logrus"
47+
"github.com/spf13/viper"
4748
proto "google.golang.org/protobuf/proto"
4849
)
4950

@@ -133,6 +134,13 @@ func BuildHTTPSched(creds credentials) calls.Caller {
133134
httpcli.Do(httpcli.With(
134135
authConfigOpt,
135136
httpcli.Timeout(viper.GetDuration("mesosApiTimeout")),
137+
httpcli.Transport(func(transport *http.Transport) {
138+
if !viper.GetBool("mesosUseSystemProxy") {
139+
transport.Proxy = func(request *http.Request) (*url.URL, error) {
140+
return nil, nil
141+
}
142+
}
143+
}),
136144
)),
137145
)
138146
if viper.GetBool("mesosCompression") {

0 commit comments

Comments
 (0)