Skip to content

Commit 4bdc28e

Browse files
authored
fix: Correct plugin type in log messages (#565)
#### Summary Noticed while working on an internal issue ---
1 parent e240c97 commit 4bdc28e

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

managedplugin/plugin.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ type Client struct {
104104
useTCP bool
105105
tcpAddr string
106106
dockerExtraHosts []string
107+
typ PluginType
107108
}
108109

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

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

760762
if c.Conn != nil {
761763
if err := c.Conn.Close(); err != nil {
762-
c.logger.Error().Err(err).Msg("failed to close gRPC connection to source plugin")
764+
c.logger.Error().Err(err).Msgf("failed to close gRPC connection to %s plugin", c.typ.String())
763765
}
764766
c.Conn = nil
765767
}

managedplugin/unix.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ func getSysProcAttr() *syscall.SysProcAttr {
1717
}
1818

1919
func (c *Client) terminateProcess() error {
20-
c.logger.Debug().Msg("sending interrupt signal to source plugin")
20+
c.logger.Debug().Msgf("sending interrupt signal to %s plugin", c.typ.String())
2121
if err := c.cmd.Process.Signal(os.Interrupt); err != nil {
22-
c.logger.Error().Err(err).Msg("failed to send interrupt signal to source plugin")
22+
c.logger.Error().Err(err).Msgf("failed to send interrupt signal to %s plugin", c.typ.String())
2323
}
2424
timer := time.AfterFunc(5*time.Second, func() {
25-
c.logger.Info().Msg("sending kill signal to source plugin")
25+
c.logger.Info().Msgf("sending kill signal to %s plugin", c.typ.String())
2626
if err := c.cmd.Process.Kill(); err != nil {
27-
c.logger.Error().Err(err).Msg("failed to kill source plugin")
27+
c.logger.Error().Err(err).Msgf("failed to kill %s plugin", c.typ.String())
2828
}
2929
})
30-
c.logger.Info().Msg("waiting for source plugin to terminate")
30+
c.logger.Info().Msgf("waiting for %s plugin to terminate", c.typ.String())
3131
st, err := c.cmd.Process.Wait()
3232
timer.Stop()
3333
if err != nil {
@@ -42,7 +42,7 @@ func (c *Client) terminateProcess() error {
4242
if st.ExitCode() == 137 {
4343
additionalInfo = " (Out of Memory)"
4444
}
45-
return fmt.Errorf("source plugin process failed with %s%s", st.String(), additionalInfo)
45+
return fmt.Errorf("%s plugin process failed with %s%s", c.typ.String(), st.String(), additionalInfo)
4646
}
4747

4848
return nil

managedplugin/windows.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ func getSysProcAttr() *syscall.SysProcAttr {
1414
}
1515

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

3232
return nil

0 commit comments

Comments
 (0)