diff --git a/agent/pkg/api/proxy_logs.go b/agent/pkg/api/proxy_logs.go index 5e810ad..8221387 100644 --- a/agent/pkg/api/proxy_logs.go +++ b/agent/pkg/api/proxy_logs.go @@ -13,15 +13,13 @@ import ( func (c *Client) ProxyLogs( podName string, namespace string, - logs []byte, - level string) error { + logs []byte) error { now := time.Now() logMessage := &pb.ProxyLog{ Auth: c.auth, PodName: podName, PodNamespace: namespace, Lines: logs, - Level: level, Timestamp: ×tamppb.Timestamp{ Seconds: now.Unix(), Nanos: int32(now.Nanosecond()), diff --git a/agent/pkg/api/proxy_logs_test.go b/agent/pkg/api/proxy_logs_test.go index 939cf27..c20ebf7 100644 --- a/agent/pkg/api/proxy_logs_test.go +++ b/agent/pkg/api/proxy_logs_test.go @@ -12,7 +12,6 @@ func TestProxyLogs(t *testing.T) { podNamespace string podName string logs []byte - level string err error }{ { @@ -20,7 +19,6 @@ func TestProxyLogs(t *testing.T) { "ns", "pod", []byte("logs"), - "info", errors.New("bad response"), }, { @@ -28,7 +26,6 @@ func TestProxyLogs(t *testing.T) { "ns", "pod", []byte("logs"), - "info", nil, }, } @@ -39,7 +36,7 @@ func TestProxyLogs(t *testing.T) { m := &MockBcloudClient{err: tc.err} c := NewClient("", "", m) - err := c.ProxyLogs(tc.podName, tc.podNamespace, tc.logs, tc.level) + err := c.ProxyLogs(tc.podName, tc.podNamespace, tc.logs) if tc.err != err { t.Errorf("Expected %s, got %s", tc.err, err) } @@ -55,7 +52,7 @@ func TestProxyLogs(t *testing.T) { m := &MockBcloudClient{} c := NewClient(fakeID, fakeKey, m) - err := c.ProxyLogs("pod", "ns", nil, "info") + err := c.ProxyLogs("pod", "ns", nil) if err != nil { t.Error(err) } diff --git a/agent/pkg/handler/manage_agent.go b/agent/pkg/handler/manage_agent.go index 80e8926..16cbc32 100644 --- a/agent/pkg/handler/manage_agent.go +++ b/agent/pkg/handler/manage_agent.go @@ -105,13 +105,13 @@ func (h *ManageAgent) handleProxyDiagnostics(ctx context.Context, podName, names } func (h *ManageAgent) handleGetProxyLogs(ctx context.Context, podName, namespace string, lines int64) { - logs, level, err := h.k8s.GetProxyLogsAndLevel(ctx, podName, namespace, lines) + logs, err := h.k8s.GetProxyLogs(ctx, podName, namespace, true, &lines) if err != nil { - h.log.Errorf("cannot obtain logs and level for proxy %s/%s", namespace, podName) + h.log.Errorf("cannot obtain logs for proxy %s/%s", namespace, podName) return } - err = h.api.ProxyLogs(podName, namespace, logs, level) + err = h.api.ProxyLogs(podName, namespace, logs) if err != nil { h.log.Errorf("error sending ProxyLog message: %s", err) } diff --git a/agent/pkg/k8s/proxy_logs.go b/agent/pkg/k8s/proxy_logs.go deleted file mode 100644 index f789949..0000000 --- a/agent/pkg/k8s/proxy_logs.go +++ /dev/null @@ -1,58 +0,0 @@ -package k8s - -import ( - "context" - "fmt" - "io/ioutil" - "net/http" - - l5dk8s "github.com/linkerd/linkerd2/pkg/k8s" - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// GetProxyLogsAndLevel retrieves the the proxy logs and level of a pod -func (c *Client) GetProxyLogsAndLevel(ctx context.Context, podName, namespace string, lines int64) ([]byte, string, error) { - logs, err := c.GetProxyLogs(ctx, podName, namespace, true, &lines) - if err != nil { - return nil, "", err - } - - pod, err := c.k8sClient.CoreV1().Pods(namespace).Get(ctx, podName, metav1.GetOptions{}) - if err != nil { - return nil, "", err - } - - if pod.Status.Phase != v1.PodRunning { - return nil, "", fmt.Errorf("pod not running: %s/%s", namespace, podName) - } - - if pod.Status.PodIP == "" { - return nil, "", fmt.Errorf("pod IP not allocated: %s/%s", namespace, podName) - } - - proxyContainer, err := getProxyContainer(pod) - if err != nil { - return nil, "", err - } - - proxyConnection, err := c.getContainerConnection(pod, proxyContainer, l5dk8s.ProxyAdminPortName) - if err != nil { - return nil, "", err - } - defer proxyConnection.cleanup() - - metricsUrl := fmt.Sprintf("http://%s/proxy-log-level", proxyConnection.host) - resp, err := http.Get(metricsUrl) - if err != nil { - return nil, "", err - } - - level, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, "", err - } - resp.Body.Close() - - return logs, string(level), nil -} diff --git a/gen/bcloud/buoyant-cloud-api.pb.go b/gen/bcloud/buoyant-cloud-api.pb.go index 572173c..456b1f9 100644 --- a/gen/bcloud/buoyant-cloud-api.pb.go +++ b/gen/bcloud/buoyant-cloud-api.pb.go @@ -1572,8 +1572,7 @@ type ProxyLog struct { PodName string `protobuf:"bytes,2,opt,name=pod_name,json=podName,proto3" json:"pod_name,omitempty"` PodNamespace string `protobuf:"bytes,3,opt,name=pod_namespace,json=podNamespace,proto3" json:"pod_namespace,omitempty"` Lines []byte `protobuf:"bytes,4,opt,name=lines,proto3" json:"lines,omitempty"` - Level string `protobuf:"bytes,5,opt,name=level,proto3" json:"level,omitempty"` - Timestamp *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } func (x *ProxyLog) Reset() { @@ -1636,13 +1635,6 @@ func (x *ProxyLog) GetLines() []byte { return nil } -func (x *ProxyLog) GetLevel() string { - if x != nil { - return x.Level - } - return "" -} - func (x *ProxyLog) GetTimestamp() *timestamppb.Timestamp { if x != nil { return x.Timestamp @@ -1833,7 +1825,7 @@ var file_buoyant_cloud_api_proto_rawDesc = []byte{ 0x66, 0x65, 0x73, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x12, 0x6b, 0x38, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x61, - 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x22, 0xd9, 0x01, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x78, 0x79, + 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x22, 0xc3, 0x01, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4c, 0x6f, 0x67, 0x12, 0x27, 0x0a, 0x04, 0x61, 0x75, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x04, 0x61, 0x75, 0x74, 0x68, 0x12, 0x19, 0x0a, 0x08, @@ -1842,41 +1834,40 @@ var file_buoyant_cloud_api_proto_rawDesc = []byte{ 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x6c, 0x69, 0x6e, - 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x32, 0xa0, 0x03, 0x0a, 0x03, 0x41, 0x70, 0x69, 0x12, 0x4a, 0x0a, 0x0e, 0x57, 0x6f, - 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1e, 0x2e, 0x62, - 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x57, 0x6f, 0x72, - 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x14, 0x2e, 0x62, - 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x22, 0x00, 0x28, 0x01, 0x12, 0x38, 0x0a, 0x08, 0x41, 0x64, 0x64, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x12, 0x14, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, - 0x75, 0x64, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x1a, 0x14, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, + 0x65, 0x73, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x32, 0xa0, 0x03, 0x0a, + 0x03, 0x41, 0x70, 0x69, 0x12, 0x4a, 0x0a, 0x0e, 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, + 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1e, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, + 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x14, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, + 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x28, 0x01, + 0x12, 0x38, 0x0a, 0x08, 0x41, 0x64, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x2e, 0x62, + 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x1a, 0x14, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, + 0x75, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0b, 0x4c, 0x69, + 0x6e, 0x6b, 0x65, 0x72, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1d, 0x2e, 0x62, 0x75, 0x6f, 0x79, + 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x4c, 0x69, 0x6e, 0x6b, 0x65, 0x72, + 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x14, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, - 0x12, 0x44, 0x0a, 0x0b, 0x4c, 0x69, 0x6e, 0x6b, 0x65, 0x72, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, - 0x1d, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, - 0x4c, 0x69, 0x6e, 0x6b, 0x65, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x14, - 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0b, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x41, 0x67, 0x65, 0x6e, 0x74, 0x12, 0x13, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, - 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x1a, 0x1b, 0x2e, 0x62, 0x75, 0x6f, - 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x41, 0x67, 0x65, 0x6e, 0x74, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0x00, 0x30, 0x01, 0x12, 0x4a, 0x0a, 0x10, 0x50, - 0x72, 0x6f, 0x78, 0x79, 0x44, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x73, 0x12, - 0x1e, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, - 0x50, 0x72, 0x6f, 0x78, 0x79, 0x44, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x1a, - 0x14, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, - 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x78, 0x79, - 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x17, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, - 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4c, 0x6f, 0x67, 0x1a, 0x14, 0x2e, - 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x69, 0x6f, 0x2f, 0x6c, 0x69, - 0x6e, 0x6b, 0x65, 0x72, 0x64, 0x2d, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2f, 0x67, 0x65, - 0x6e, 0x2f, 0x62, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x43, 0x0a, 0x0b, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x12, + 0x13, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, + 0x41, 0x75, 0x74, 0x68, 0x1a, 0x1b, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, + 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x22, 0x00, 0x30, 0x01, 0x12, 0x4a, 0x0a, 0x10, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x44, 0x69, + 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x73, 0x12, 0x1e, 0x2e, 0x62, 0x75, 0x6f, 0x79, + 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x44, + 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x1a, 0x14, 0x2e, 0x62, 0x75, 0x6f, 0x79, + 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, + 0x00, 0x12, 0x3c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x17, + 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x50, + 0x72, 0x6f, 0x78, 0x79, 0x4c, 0x6f, 0x67, 0x1a, 0x14, 0x2e, 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, + 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, + 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, + 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x69, 0x6f, 0x2f, 0x6c, 0x69, 0x6e, 0x6b, 0x65, 0x72, 0x64, 0x2d, + 0x62, 0x75, 0x6f, 0x79, 0x61, 0x6e, 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x62, 0x63, 0x6c, 0x6f, + 0x75, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/buoyant-cloud-api.proto b/proto/buoyant-cloud-api.proto index b69ac47..486b524 100644 --- a/proto/buoyant-cloud-api.proto +++ b/proto/buoyant-cloud-api.proto @@ -185,8 +185,7 @@ message ProxyLog { string pod_name = 2; string pod_namespace = 3; bytes lines = 4; - string level = 5; - google.protobuf.Timestamp timestamp = 6; + google.protobuf.Timestamp timestamp = 5; } //