Skip to content

Commit

Permalink
Remove the gather-traces and upload-traces commands.
Browse files Browse the repository at this point in the history
The ability to collect trace has been removed. The code was complex and
has not been well maintained since its inception in 2022. We have seen
no indication that it has ever been used.

Signed-off-by: Thomas Hallgren <[email protected]>
  • Loading branch information
thallgren committed Dec 8, 2024
1 parent 8af0b3b commit 1824b26
Show file tree
Hide file tree
Showing 66 changed files with 1,143 additions and 3,072 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ items:
for the local port is determined by the targeted container port rather than just defaulting to 8080.
A default can still be explicitly defined using the `config.intercept.defaultPort` setting.
- type: change
title: Tracing was removed.
body: >-
The ability to collect trace has been removed along with the `telepresence gather-traces` and
`telepresence upload-traces` commands. The underlying code was complex and has not been well maintained since
its inception in 2022. We have received no feedback on it and seen no indication that it has ever been used.
- type: bugfix
title: Cap timeouts.connectivityCheck at 5 seconds.
body: >-
Expand Down
369 changes: 181 additions & 188 deletions DEPENDENCIES.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ managerHost: traffic-manager.ambassador
managerPort: 8081
namespace: default
pullPolicy: IfNotPresent
tracingPort: 15766
workloadKind: Deployment
workloadName: hello

Expand Down
1 change: 0 additions & 1 deletion charts/telepresence/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ RBAC rules required to create an intercept in a namespace; excludes any rules th
- apiGroups: [""]
resources: ["services"]
verbs: ["list", "watch", "get"]
# Needed for the gather-traces command
- apiGroups: [""]
resources: ["pods/portforward"]
verbs: ["create"]
Expand Down
10 changes: 0 additions & 10 deletions charts/telepresence/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ spec:
value: {{ .agentInjector.secret.name }}
{{- end }}
{{- end }}
{{- with .tracing }}
{{- if .grpcPort }}
- name: TRACING_GRPC_PORT
value: {{ .grpcPort | quote }}
{{- end }}
{{- end }}
{{- with .telepresenceAPI }}
{{- if .port }}
- name: AGENT_REST_API_PORT
Expand Down Expand Up @@ -277,10 +271,6 @@ spec:
- name: prometheus
containerPort: {{ .prometheus.port }}
{{- end }}
{{- with .tracing }}
- name: grpc-trace
containerPort: {{ .grpcPort }}
{{- end }}
{{- with .livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
Expand Down
8 changes: 0 additions & 8 deletions charts/telepresence/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ spec:
- name: api
port: {{ .Values.apiPort }}
targetPort: api
{{- with .Values.tracing }}
{{- if .grpcPort }}
- name: grpc-trace
port: {{ .grpcPort }}
targetPort: "grpc-trace"
{{- end }}
{{- end }}

selector:
{{- include "telepresence.selectorLabels" . | nindent 4 }}
{{- if .Values.agentInjector.enabled }}
Expand Down
11 changes: 0 additions & 11 deletions charts/telepresence/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,6 @@ telepresenceAPI:
# Default: 0
port: 0


################################################################################
## Tracing configuration
################################################################################
tracing: {}
# The port on which a grpc server will be exposed for traces
# To enable, set tracing to
#
# tracing:
# grpcPort: 15766

################################################################################
## Prometheus Server Configuration
################################################################################
Expand Down
20 changes: 0 additions & 20 deletions cmd/traffic/cmd/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/pkg/sftp"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"

"github.com/datawire/dlib/dgroup"
Expand All @@ -26,7 +25,6 @@ import (
"github.com/telepresenceio/telepresence/v2/pkg/forwarder"
"github.com/telepresenceio/telepresence/v2/pkg/iputil"
"github.com/telepresenceio/telepresence/v2/pkg/restapi"
"github.com/telepresenceio/telepresence/v2/pkg/tracing"
"github.com/telepresenceio/telepresence/v2/pkg/tunnel"
"github.com/telepresenceio/telepresence/v2/pkg/version"
)
Expand Down Expand Up @@ -224,24 +222,6 @@ func TalkToManagerLoop(ctx context.Context, s State, info *rpc.AgentInfo) {
func StartServices(ctx context.Context, g *dgroup.Group, config Config, srv State) (*rpc.AgentInfo, error) {
var grpcOpts []grpc.ServerOption
ac := config.AgentConfig()
if ac.TracingPort != 0 {
g.Go("tracer-grpc", func(c context.Context) error {
tracer, err := tracing.NewTraceServer(c, "traffic-agent", OtelResources(c, config)...)
if err != nil {
return err
}
defer func() {
c, cancel := context.WithTimeout(context.WithoutCancel(c), time.Second)
tracer.Shutdown(c)
cancel()
}()
return tracer.ServeGrpc(c, ac.TracingPort)
})

grpcOpts = []grpc.ServerOption{
grpc.StatsHandler(otelgrpc.NewServerHandler()),
}
}

grpcPortCh := make(chan uint16)
g.Go("tunneling", func(ctx context.Context) error {
Expand Down
5 changes: 1 addition & 4 deletions cmd/traffic/cmd/agent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/blang/semver/v4"
dns2 "github.com/miekg/dns"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
Expand Down Expand Up @@ -50,9 +49,7 @@ func TalkToManager(ctx context.Context, address string, info *rpc.AgentInfo, sta
ctx, cancel := context.WithCancel(ctx)
defer cancel()

conn, err := grpc.NewClient(address,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithStatsHandler(otelgrpc.NewClientHandler()))
conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return err
}
Expand Down
14 changes: 0 additions & 14 deletions cmd/traffic/cmd/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"strconv"
"strings"

"go.opentelemetry.io/otel/attribute"

"github.com/datawire/dlib/dlog"
"github.com/telepresenceio/telepresence/v2/pkg/agentconfig"
"github.com/telepresenceio/telepresence/v2/pkg/dos"
Expand Down Expand Up @@ -86,18 +84,6 @@ func (c *config) PodIP() string {
return c.podIP
}

func OtelResources(ctx context.Context, c Config) []attribute.KeyValue {
return []attribute.KeyValue{
attribute.Bool("tel2.has-mounts", c.HasMounts(ctx)),
attribute.String("tel2.workload-name", c.AgentConfig().WorkloadName),
attribute.String("tel2.workload-kind", c.AgentConfig().WorkloadKind),
attribute.String("tel2.manager-host", fmt.Sprintf("%s:%v", c.AgentConfig().ManagerHost, c.AgentConfig().ManagerPort)),
attribute.Bool("tel2.manual", c.AgentConfig().Manual),
attribute.String("k8s.namespace", c.AgentConfig().Namespace),
attribute.String("k8s.pod-ip", c.PodIP()),
}
}

// addAppMounts adds each of the mounts present under the containers MountPoint as a
// symlink under the agentconfig.ExportsMountPoint/<container mount>/.
func addAppMounts(ctx context.Context, ag *agentconfig.Container) error {
Expand Down
28 changes: 1 addition & 27 deletions cmd/traffic/cmd/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"go.opentelemetry.io/otel/attribute"
"google.golang.org/grpc"
"google.golang.org/grpc/health/grpc_health_v1"
"k8s.io/apimachinery/pkg/util/runtime"
Expand All @@ -31,7 +29,6 @@ import (
"github.com/telepresenceio/telepresence/v2/pkg/agentmap"
"github.com/telepresenceio/telepresence/v2/pkg/informer"
"github.com/telepresenceio/telepresence/v2/pkg/iputil"
"github.com/telepresenceio/telepresence/v2/pkg/tracing"
"github.com/telepresenceio/telepresence/v2/pkg/version"
)

Expand Down Expand Up @@ -69,26 +66,11 @@ func MainWithEnv(ctx context.Context) (err error) {
dlog.Infof(ctx, "%s %s [uid:%d,gid:%d]", DisplayName, version.Version, os.Getuid(), os.Getgid())

env := managerutil.GetEnv(ctx)
var tracer *tracing.TraceServer

if env.TracingGrpcPort != 0 {
tracer, err = tracing.NewTraceServer(ctx, "traffic-manager",
attribute.String("tel2.agent-image", env.QualifiedAgentImage()),
attribute.String("tel2.managed-namespaces", strings.Join(env.ManagedNamespaces, ",")),
attribute.String("k8s.namespace", env.ManagerNamespace),
attribute.String("k8s.pod-ip", env.PodIP.String()),
)
if err != nil {
return err
}
defer tracer.Shutdown(ctx)
}

cfg, err := rest.InClusterConfig()
if err != nil {
return fmt.Errorf("unable to get the Kubernetes InClusterConfig: %w", err)
}
cfg.WrapTransport = tracing.NewWrapperFunc()
ki, err := kubernetes.NewForConfig(cfg)
if err != nil {
return fmt.Errorf("unable to create the Kubernetes Interface from InClusterConfig: %w", err)
Expand Down Expand Up @@ -158,12 +140,6 @@ func MainWithEnv(ctx context.Context) (err error) {

g.Go("session-gc", mgr.runSessionGCLoop)

if tracer != nil {
g.Go("tracer-grpc", func(c context.Context) error {
return tracer.ServeGrpc(c, env.TracingGrpcPort)
})
}

// Wait for exit
return g.Wait()
}
Expand Down Expand Up @@ -276,9 +252,7 @@ func (s *service) serveHTTP(ctx context.Context) error {
env := managerutil.GetEnv(ctx)
host := env.ServerHost
port := env.ServerPort
opts := []grpc.ServerOption{
grpc.StatsHandler(otelgrpc.NewServerHandler()),
}
var opts []grpc.ServerOption
if mz, ok := env.MaxReceiveSize.AsInt64(); ok {
opts = append(opts, grpc.MaxRecvMsgSize(int(mz)))
}
Expand Down
4 changes: 1 addition & 3 deletions cmd/traffic/cmd/manager/managerutil/envconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ type Env struct {
APIPort uint16 `env:"AGENT_REST_API_PORT, parser=port-number, default=0"`
AgentArrivalTimeout time.Duration `env:"AGENT_ARRIVAL_TIMEOUT, parser=time.ParseDuration, default=0"`

TracingGrpcPort uint16 `env:"TRACING_GRPC_PORT, parser=port-number,default=0"`
MaxReceiveSize resource.Quantity `env:"GRPC_MAX_RECEIVE_SIZE, parser=quantity"`
MaxReceiveSize resource.Quantity `env:"GRPC_MAX_RECEIVE_SIZE, parser=quantity"`

PodCIDRStrategy string `env:"POD_CIDR_STRATEGY, parser=nonempty-string"`
PodCIDRs []netip.Prefix `env:"POD_CIDRS, parser=split-ipnet, default="`
Expand Down Expand Up @@ -82,7 +81,6 @@ func (e *Env) GeneratorConfig(qualifiedAgentImage string) (agentmap.GeneratorCon
return &agentmap.BasicGeneratorConfig{
AgentPort: e.AgentPort,
APIPort: e.APIPort,
TracingPort: e.TracingGrpcPort,
ManagerPort: e.ServerPort,
QualifiedAgentImage: qualifiedAgentImage,
ManagerNamespace: e.ManagerNamespace,
Expand Down
14 changes: 0 additions & 14 deletions cmd/traffic/cmd/manager/mutator/agent_injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
admission "k8s.io/api/admission/v1"
core "k8s.io/api/core/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -27,7 +25,6 @@ import (
"github.com/telepresenceio/telepresence/v2/pkg/agentconfig"
"github.com/telepresenceio/telepresence/v2/pkg/agentmap"
"github.com/telepresenceio/telepresence/v2/pkg/maps"
"github.com/telepresenceio/telepresence/v2/pkg/tracing"
"github.com/telepresenceio/telepresence/v2/pkg/workload"
)

Expand Down Expand Up @@ -98,8 +95,6 @@ func (a *agentInjector) Inject(ctx context.Context, req *admission.AdmissionRequ
dlog.Errorf(ctx, "%+v", err)
}
}()
ctx, span := otel.GetTracerProvider().Tracer("").Start(ctx, "mutator.inject")
defer tracing.EndAndRecord(span, err)

isDelete := req.Operation == admission.Delete
if atomic.LoadInt64(&a.terminating) > 0 {
Expand All @@ -120,12 +115,6 @@ func (a *agentInjector) Inject(ctx context.Context, req *admission.AdmissionRequ
env := managerutil.GetEnv(ctx)

ia := pod.Annotations[agentconfig.InjectAnnotation]
span.SetAttributes(
attribute.String("tel2.pod-name", pod.Name),
attribute.String("tel2.pod-namespace", pod.Namespace),
attribute.String("tel2.operation", string(req.Operation)),
attribute.String("tel2."+agentconfig.InjectAnnotation, ia),
)

var scx agentconfig.SidecarExt
switch ia {
Expand Down Expand Up @@ -190,8 +179,6 @@ func (a *agentInjector) Inject(ctx context.Context, req *admission.AdmissionRequ
dlog.Debugf(ctx, "Skipping webhook where agent is manually injected %s.%s", pod.Name, pod.Namespace)
return nil, nil
}

tracing.RecordWorkloadInfo(span, wl)
default:
return nil, fmt.Errorf("invalid value %q for annotation %s", ia, agentconfig.InjectAnnotation)
}
Expand All @@ -216,7 +203,6 @@ func (a *agentInjector) Inject(ctx context.Context, req *admission.AdmissionRequ
// Create patch operations to add the traffic-agent sidecar
if len(patches) > 0 {
dlog.Infof(ctx, "Injecting %d patches into pod %s.%s", len(patches), pod.Name, pod.Namespace)
span.SetAttributes(attribute.Stringer("tel2.patches", patches))
}
return patches, nil
}
Expand Down
6 changes: 1 addition & 5 deletions cmd/traffic/cmd/manager/mutator/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/go-json-experiment/json"
"github.com/go-json-experiment/json/jsontext"
jsonv1 "github.com/go-json-experiment/json/v1"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
admission "k8s.io/api/admission/v1"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -156,9 +155,6 @@ func ServeMutator(ctx context.Context, injectorCertGetter InjectorCertGetter) er
w.WriteHeader(http.StatusOK)
})

wrapped := otelhttp.NewHandler(mux, "agent-injector", otelhttp.WithSpanNameFormatter(func(operation string, r *http.Request) string {
return operation + r.URL.Path
}))
port := managerutil.GetEnv(ctx).MutatorWebhookPort
lg := dlog.StdLogger(ctx, dlog.MaxLogLevel(ctx))
lg.SetPrefix(fmt.Sprintf("%d/", port))
Expand All @@ -170,7 +166,7 @@ func ServeMutator(ctx context.Context, injectorCertGetter InjectorCertGetter) er
wr: lg.Writer(),
})
server := http.Server{
Handler: wrapped,
Handler: mux,
ErrorLog: lg,
BaseContext: func(n net.Listener) context.Context {
return ctx
Expand Down
Loading

0 comments on commit 1824b26

Please sign in to comment.