Skip to content

Commit

Permalink
feat: add ARGO_DATAFLOW_UNIX_DOMAIN_SOCKET config (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec authored Sep 16, 2021
1 parent 4cb372e commit 84bf124
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 266 deletions.
5 changes: 3 additions & 2 deletions api/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ const (
CtrSidecar = "sidecar"
// env vars
EnvCluster = "ARGO_DATAFLOW_CLUSTER"
EnvDebug = "ARGO_DATAFLOW_DEBUG" // enable default mode, default "false"
EnvImagePrefix = "ARGO_DATAFLOW_IMAGE_PREFIX" // default "quay.io/argoproj"
EnvDebug = "ARGO_DATAFLOW_DEBUG" // enable default mode, default "false"
EnvUnixDomainSocket = "ARGO_DATAFLOW_UNIX_DOMAIN_SOCKET" // use Unix Domain Socket, default "true"
EnvImagePrefix = "ARGO_DATAFLOW_IMAGE_PREFIX" // default "quay.io/argoproj"
EnvNamespace = "ARGO_DATAFLOW_NAMESPACE"
EnvPipelineName = "ARGO_DATAFLOW_PIPELINE_NAME"
EnvPod = "ARGO_DATAFLOW_POD"
Expand Down
479 changes: 224 additions & 255 deletions api/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions api/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion api/v1alpha1/get_pod_req.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

type GetPodSpecReq struct {
Cluster string `protobuf:"bytes,1,opt,name=cluster"`
Debug bool `protobuf:"varint,2,opt,name=debug"`
PipelineName string `protobuf:"bytes,3,opt,name=pipelineName"`
Replica int32 `protobuf:"varint,4,opt,name=replica"`
ImageFormat string `protobuf:"bytes,5,opt,name=imageFormat"`
Expand Down
7 changes: 6 additions & 1 deletion api/v1alpha1/step_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func (in Step) GetPodSpec(req GetPodSpecReq) corev1.PodSpec {
step, _ := json.Marshal(in.withoutManagedFields())
envVars := []corev1.EnvVar{
{Name: EnvCluster, Value: req.Cluster},
{Name: EnvDebug, Value: strconv.FormatBool(req.Debug)},
{Name: EnvNamespace, ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{FieldPath: "metadata.namespace"}}},
{Name: EnvPod, ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{FieldPath: "metadata.name"}}},
{Name: EnvPipelineName, Value: req.PipelineName},
Expand All @@ -110,6 +109,12 @@ func (in Step) GetPodSpec(req GetPodSpecReq) corev1.PodSpec {
{Name: "GODEBUG", Value: os.Getenv("GODEBUG")},
}

for _, n := range []string{EnvDebug, EnvUnixDomainSocket} {
if value, ok := os.LookupEnv(EnvDebug); ok {
envVars = append(envVars, corev1.EnvVar{Name: n, Value: value})
}
}

// add all Jaeger envvar
for _, kv := range os.Environ() {
if strings.HasPrefix(kv, "JAEGER_") {
Expand Down
1 change: 0 additions & 1 deletion api/v1alpha1/step_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func TestStep_GetPodSpec(t *testing.T) {
t.Run(fmt.Sprintf("Replica%d", replica), func(t *testing.T) {
env := []corev1.EnvVar{
{Name: "ARGO_DATAFLOW_CLUSTER", Value: "my-cluster"},
{Name: "ARGO_DATAFLOW_DEBUG", Value: "false"},
{Name: "ARGO_DATAFLOW_NAMESPACE", ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{FieldPath: "metadata.namespace"}}},
{Name: "ARGO_DATAFLOW_POD", ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{FieldPath: "metadata.name"}}},
{Name: "ARGO_DATAFLOW_PIPELINE_NAME", Value: "my-pl"},
Expand Down
2 changes: 0 additions & 2 deletions manager/controllers/step_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ type StepReconciler struct {
ContainerKiller containerkiller.Interface
DynamicInterface dynamic.Interface
Cluster string
Debug bool
}

type hash struct {
Expand Down Expand Up @@ -173,7 +172,6 @@ func (r *StepReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
Spec: step.GetPodSpec(
dfv1.GetPodSpecReq{
Cluster: r.Cluster,
Debug: r.Debug,
PipelineName: pipelineName,
Replica: int32(replica),
ImageFormat: imageFormat,
Expand Down
1 change: 0 additions & 1 deletion manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func main() {
ContainerKiller: containerKiller,
DynamicInterface: dynamicInterface,
Cluster: os.Getenv(dfv1.EnvCluster),
Debug: os.Getenv(dfv1.EnvDebug) == "true",
}).SetupWithManager(mgr); err != nil {
panic(fmt.Errorf("unable to create controller manager: %w", err))
}
Expand Down
2 changes: 1 addition & 1 deletion runner/sidecar/in.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func waitReady(ctx context.Context) error {
case <-ctx.Done():
return fmt.Errorf("failed to wait for ready: %w", ctx.Err())
default:
if _, err := os.Stat(ipcSockPath); err == nil {
if _, err := os.Stat(ipcSockPath); os.Getenv(dfv1.EnvDebug) != "false" && err == nil {
logger.Info("switching to Unix socket", "path", ipcSockPath)
httpTransport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
return (&net.Dialer{}).DialContext(ctx, "unix", ipcSockPath)
Expand Down

0 comments on commit 84bf124

Please sign in to comment.