Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions managedplugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type Client struct {
useTCP bool
tcpAddr string
dockerExtraHosts []string
typ PluginType
}

// typ will be deprecated soon but now required for a transition period
Expand Down Expand Up @@ -151,6 +152,7 @@ func NewClient(ctx context.Context, typ PluginType, config Config, opts ...Optio
registry: config.Registry,
cqDockerHost: DefaultCloudQueryDockerHost,
dockerAuth: config.DockerAuth,
typ: typ,
}
for _, opt := range opts {
opt(c)
Expand Down Expand Up @@ -588,7 +590,7 @@ func (c *Client) connectUsingTCP(ctx context.Context, path string) error {
),
)
if err != nil {
return fmt.Errorf("failed to dial grpc source plugin at %s: %w", path, err)
return fmt.Errorf("failed to dial grpc %s plugin at %s: %w", c.typ.String(), path, err)
}

return retry.Do(
Expand Down Expand Up @@ -759,7 +761,7 @@ func (c *Client) Terminate() error {

if c.Conn != nil {
if err := c.Conn.Close(); err != nil {
c.logger.Error().Err(err).Msg("failed to close gRPC connection to source plugin")
c.logger.Error().Err(err).Msgf("failed to close gRPC connection to %s plugin", c.typ.String())
}
c.Conn = nil
}
Expand Down
12 changes: 6 additions & 6 deletions managedplugin/unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ func getSysProcAttr() *syscall.SysProcAttr {
}

func (c *Client) terminateProcess() error {
c.logger.Debug().Msg("sending interrupt signal to source plugin")
c.logger.Debug().Msgf("sending interrupt signal to %s plugin", c.typ.String())
if err := c.cmd.Process.Signal(os.Interrupt); err != nil {
c.logger.Error().Err(err).Msg("failed to send interrupt signal to source plugin")
c.logger.Error().Err(err).Msgf("failed to send interrupt signal to %s plugin", c.typ.String())
}
timer := time.AfterFunc(5*time.Second, func() {
c.logger.Info().Msg("sending kill signal to source plugin")
c.logger.Info().Msgf("sending kill signal to %s plugin", c.typ.String())
if err := c.cmd.Process.Kill(); err != nil {
c.logger.Error().Err(err).Msg("failed to kill source plugin")
c.logger.Error().Err(err).Msgf("failed to kill %s plugin", c.typ.String())
}
})
c.logger.Info().Msg("waiting for source plugin to terminate")
c.logger.Info().Msgf("waiting for %s plugin to terminate", c.typ.String())
st, err := c.cmd.Process.Wait()
timer.Stop()
if err != nil {
Expand All @@ -42,7 +42,7 @@ func (c *Client) terminateProcess() error {
if st.ExitCode() == 137 {
additionalInfo = " (Out of Memory)"
}
return fmt.Errorf("source plugin process failed with %s%s", st.String(), additionalInfo)
return fmt.Errorf("%s plugin process failed with %s%s", c.typ.String(), st.String(), additionalInfo)
}

return nil
Expand Down
8 changes: 4 additions & 4 deletions managedplugin/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ func getSysProcAttr() *syscall.SysProcAttr {
}

func (c *Client) terminateProcess() error {
c.logger.Debug().Msg("sending kill signal to destination plugin")
c.logger.Debug().Msgf("sending kill signal to %s plugin", c.typ.String())
if err := c.cmd.Process.Kill(); err != nil {
c.logger.Error().Err(err).Msg("failed to kill source plugin")
c.logger.Error().Err(err).Msgf("failed to kill %s plugin", c.typ.String())
}
c.logger.Info().Msg("waiting for source plugin to terminate")
c.logger.Info().Msgf("waiting for %s plugin to terminate", c.typ.String())
st, err := c.cmd.Process.Wait()
if err != nil {
return err
}
if !st.Success() {
// on windows there is no way to shutdown gracefully via signal. Maybe we can do it via grpc api?
// though it is a bit strange to expose api to shutdown a server :thinking?:
c.logger.Info().Msgf("source plugin process exited with %s", st.String())
c.logger.Info().Msgf("%s plugin process exited with %s", c.typ.String(), st.String())
}

return nil
Expand Down