Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cli): Migrate argo logs to use API client. See #2116 #2177

Merged
merged 33 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
cc26a3b
chore: Migrate `argo logs` to use API client. See #2116
alexec Feb 5, 2020
664e33a
changes
alexec Feb 5, 2020
b52d20a
fix: Correctly create code from changed protos.
alexec Feb 5, 2020
12eb78e
Merge branch 'codegen' into cli-logs
alexec Feb 5, 2020
587e36d
lint
alexec Feb 5, 2020
b4d49dc
Merge branch 'master' into cli-logs
alexec Feb 6, 2020
75504ed
codegen
alexec Feb 6, 2020
a4b92a0
make codegen
alexec Feb 6, 2020
e379903
logs
alexec Feb 6, 2020
2ab5dde
changes
alexec Feb 6, 2020
0d40d96
oddloading
alexec Feb 6, 2020
cab847e
correct diagnostic output
alexec Feb 6, 2020
271eb45
hopefully the final changes
alexec Feb 6, 2020
7ed136f
changes
alexec Feb 6, 2020
7168d34
Merge branch 'master' into cli-logs
alexec Feb 7, 2020
52e85da
Merge branch 'master' into cli-logs
alexec Feb 10, 2020
88fd4ad
feat(cli-logs): fix merge + make lint
alexec Feb 10, 2020
9420827
lint
alexec Feb 10, 2020
b589a73
Merge branch 'master' into cli-logs
alexec Feb 11, 2020
1f416ff
tidy up
alexec Feb 11, 2020
8078538
Merge branch 'master' into cli-logs
alexec Feb 20, 2020
67e4f53
codegen
alexec Feb 20, 2020
1c23aa4
test(cli): fix test
alexec Feb 20, 2020
50d67aa
Merge branch 'master' into cli-logs
alexec Feb 20, 2020
ecaf440
logs
alexec Feb 21, 2020
5fed826
reinstate vendor
alexec Feb 21, 2020
1ed093a
Merge branch 'master' into cli-logs
alexec Feb 22, 2020
78eeb15
changes
alexec Feb 22, 2020
802c290
Merge branch 'master' into cli-logs
alexec Feb 24, 2020
d868351
interm-2
alexec Feb 24, 2020
67c4ff9
copylocks lint
alexec Feb 24, 2020
0594ddd
Merge branch 'master' into cli-logs
alexec Feb 25, 2020
0ec7417
Merge branch 'master' into cli-logs
alexec Feb 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
555 changes: 85 additions & 470 deletions cmd/argo/commands/logs.go

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions pkg/apiclient/classic-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"

workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
Expand All @@ -14,6 +15,7 @@ import (

type classicClient struct {
versioned.Interface
kubeClient kubernetes.Interface
}

func newClassicClient(clientConfig clientcmd.ClientConfig) (context.Context, Client, error) {
Expand All @@ -25,11 +27,15 @@ func newClassicClient(clientConfig clientcmd.ClientConfig) (context.Context, Cli
if err != nil {
return nil, nil, err
}
return context.Background(), &classicClient{wfClient}, nil
kubeClient, err := kubernetes.NewForConfig(restConfig)
if err != nil {
return nil, nil, err
}
return context.Background(), &classicClient{wfClient, kubeClient}, nil
}

func (a *classicClient) NewWorkflowServiceClient() workflowpkg.WorkflowServiceClient {
return &classicWorkflowServiceClient{a.Interface}
return &classicWorkflowServiceClient{a.Interface, a.kubeClient}
}

func (a *classicClient) NewArchivedWorkflowServiceClient() (workflowarchivepkg.ArchivedWorkflowServiceClient, error) {
Expand Down
45 changes: 44 additions & 1 deletion pkg/apiclient/classic-workflow-service-client.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package apiclient

import (
"bufio"
"context"
"fmt"
"strconv"

log "github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"

workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
"github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
Expand All @@ -25,6 +28,7 @@ var (

type classicWorkflowServiceClient struct {
versioned.Interface
kubeClient kubernetes.Interface
}

func (k *classicWorkflowServiceClient) CreateWorkflow(_ context.Context, in *workflowpkg.WorkflowCreateRequest, _ ...grpc.CallOption) (*v1alpha1.Workflow, error) {
Expand Down Expand Up @@ -146,6 +150,45 @@ func (k *classicWorkflowServiceClient) LintWorkflow(_ context.Context, in *workf
return in.Workflow, nil
}

func (k *classicWorkflowServiceClient) PodLogs(_ context.Context, _ *workflowpkg.WorkflowLogRequest, _ ...grpc.CallOption) (workflowpkg.WorkflowService_PodLogsClient, error) {
type classicPodLogsClient struct {
*bufio.Scanner
}

func (c classicPodLogsClient) Recv() (*workflowpkg.LogEntry, error) {
if c.Scan() {
return &workflowpkg.LogEntry{Content: c.Text()}, nil
}
return nil, fmt.Errorf("no more data")
}

func (c classicPodLogsClient) Header() (metadata.MD, error) {
panic("implement me")
}

func (c classicPodLogsClient) Trailer() metadata.MD {
panic("implement me")
}

func (c classicPodLogsClient) CloseSend() error {
panic("implement me")
}

func (c classicPodLogsClient) Context() context.Context {
panic("implement me")
}

func (c classicPodLogsClient) SendMsg(m interface{}) error {
panic("implement me")
}

func (c classicPodLogsClient) RecvMsg(m interface{}) error {
panic("implement me")
}

func (k *classicWorkflowServiceClient) PodLogs(_ context.Context, in *workflowpkg.WorkflowLogRequest, _ ...grpc.CallOption) (workflowpkg.WorkflowService_PodLogsClient, error) {
stream, err := k.kubeClient.CoreV1().Pods(in.GetNamespace()).GetLogs(in.GetPodName(), in.LogOptions).Stream()
if err != nil {
return nil, err
}
return &classicPodLogsClient{bufio.NewScanner(stream)}, nil
}
239 changes: 171 additions & 68 deletions pkg/apiclient/workflow/workflow.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/apiclient/workflow/workflow.pb.gw.go

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

4 changes: 3 additions & 1 deletion pkg/apiclient/workflow/workflow.proto
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ message WorkflowWatchEvent {

message LogEntry {
string content = 1;
string podName = 2;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need this for printing

string containerName = 3;
}

message WorkflowLintRequest {
Expand Down Expand Up @@ -161,6 +163,6 @@ service WorkflowService {
}

rpc PodLogs (WorkflowLogRequest) returns (stream LogEntry) {
option (google.api.http).get = "/api/v1/workflows/{namespace}/{name}/{podName}/log";
option (google.api.http).get = "/api/v1/workflows/{namespace}/{name}/log/{podName}";
}
}
Loading