Skip to content

Commit

Permalink
wip fix plugin logger init
Browse files Browse the repository at this point in the history
  • Loading branch information
Janelle Law committed Oct 23, 2023
1 parent ca68c11 commit 7079f5d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/plugins/apis/apiextensions/stream/plugin_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/hashicorp/go-plugin"
"github.com/jhump/protoreflect/grpcreflect"
"github.com/kralicky/totem"
controlv1 "github.com/rancher/opni/pkg/apis/control/v1"
streamv1 "github.com/rancher/opni/pkg/apis/stream/v1"
"github.com/rancher/opni/pkg/logger"
"github.com/rancher/opni/pkg/plugins/apis/apiextensions"
Expand Down Expand Up @@ -154,6 +155,10 @@ func (e *agentStreamExtensionServerImpl) Connect(stream streamv1.Stream_ConnectS
e.logger.Debug("stream client is now available")
if e.clientHandler != nil {
e.clientHandler.UseStreamClient(cc)
err := initRemotePluginLoggers(stream.Context(), cc)
if err != nil {
e.logger.Warn("could not initialize remote log streaming", logger.Err(err))
}
}
case err := <-errC:
if err != nil {
Expand Down Expand Up @@ -208,3 +213,13 @@ func (e *agentStreamExtensionServerImpl) Notify(_ context.Context, event *stream
}
return &emptypb.Empty{}, nil
}

func initRemotePluginLoggers(ctx context.Context, cc grpc.ClientConnInterface) error {
identityClient := controlv1.NewIdentityClient(cc)
id, err := identityClient.Whoami(ctx, &emptypb.Empty{})
if err != nil {
return err
}
logger.InitPluginWriter(id.GetId())
return nil
}

0 comments on commit 7079f5d

Please sign in to comment.