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

Fix issue where plugin start timeout was getting limited to 60s. Closes #4477 #4493

Open
wants to merge 4 commits into
base: v1.0.x
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion pkg/cmdconfig/viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmdconfig

import (
"fmt"
pfilepaths "github.com/turbot/pipe-fittings/filepaths"
"log"
"os"

Expand All @@ -11,6 +10,7 @@ import (
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/go-kit/types"
pconstants "github.com/turbot/pipe-fittings/constants"
pfilepaths "github.com/turbot/pipe-fittings/filepaths"
"github.com/turbot/pipe-fittings/parse"
"github.com/turbot/pipe-fittings/workspace_profile"
"github.com/turbot/steampipe/pkg/constants"
Expand Down Expand Up @@ -110,6 +110,9 @@ func setBaseDefaults() error {
// memory
pconstants.ArgMemoryMaxMbPlugin: 1024,
pconstants.ArgMemoryMaxMb: 1024,

// plugin start timeout
pconstants.ArgPluginStartTimeout: constants.PluginStartTimeout.Seconds(),
}

for k, v := range defaults {
Expand Down
2 changes: 1 addition & 1 deletion pkg/constants/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ var (
DBRecoveryTimeout = 24 * time.Hour
DBRecoveryRetryBackoff = 200 * time.Millisecond
ServicePingInterval = 50 * time.Millisecond
PluginStartTimeout = 30 * time.Second
PluginStartTimeout = 3 * time.Minute
)
2 changes: 0 additions & 2 deletions pkg/options/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ func (t *Plugin) ConfigMap() map[string]interface{} {
}
if t.StartTimeout != nil {
res[constants.ArgPluginStartTimeout] = t.StartTimeout
} else {
res[constants.ArgPluginStartTimeout] = constants.PluginStartTimeout.Seconds()
}

return res
Expand Down
4 changes: 4 additions & 0 deletions pkg/pluginmanager/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import (
"log"
"os/exec"
"syscall"
"time"

"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"github.com/spf13/viper"
"github.com/turbot/pipe-fittings/app_specific"
"github.com/turbot/pipe-fittings/constants"
pconstants "github.com/turbot/pipe-fittings/constants"
"github.com/turbot/steampipe-plugin-sdk/v5/logging"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/pluginmanager_service/grpc"
Expand Down Expand Up @@ -64,6 +67,7 @@ func start(steampipeExecutablePath string) (*State, error) {
Cmd: pluginManagerCmd,
AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},
Logger: logger,
StartTimeout: time.Duration(viper.GetInt(pconstants.ArgPluginStartTimeout)) * time.Second,
})

if _, err := client.Start(); err != nil {
Expand Down
11 changes: 6 additions & 5 deletions pkg/pluginmanager_service/plugin_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,16 @@ func (m *PluginManager) startPluginProcess(pluginInstance string, connectionConf

cmd := exec.Command(pluginPath)
m.setPluginMaxMemory(pluginConfig, cmd)

pluginStartTimeoutDuration := time.Duration(viper.GetInt64(pconstants.ArgPluginStartTimeout)) * time.Second
log.Printf("[TRACE] %s pluginStartTimeoutDuration: %s", pluginPath, pluginStartTimeoutDuration)

client := goplugin.NewClient(&goplugin.ClientConfig{
HandshakeConfig: sdkshared.Handshake,
Plugins: pluginMap,
Cmd: cmd,
AllowedProtocols: []goplugin.Protocol{goplugin.ProtocolGRPC},
StartTimeout: pluginStartTimeoutDuration,

// pass our logger to the plugin client to ensure plugin logs end up in logfile
Logger: m.logger,
Expand Down Expand Up @@ -678,14 +683,10 @@ func (m *PluginManager) waitForPluginLoad(p *runningPlugin, req *pb.GetRequest)
}
pluginStartTimeoutSecs := pluginConfig.GetStartTimeout()
if pluginStartTimeoutSecs == 0 {
if viper.IsSet(pconstants.ArgMemoryMaxMbPlugin) {
if viper.IsSet(pconstants.ArgPluginStartTimeout) {
pluginStartTimeoutSecs = viper.GetInt64(pconstants.ArgPluginStartTimeout)
}
}
if pluginStartTimeoutSecs == 0 {
// if we don't have any timeout set use 30 seconds
pluginStartTimeoutSecs = int64(30)
}

log.Printf("[TRACE] waitForPluginLoad: waiting %d seconds (%p)", pluginStartTimeoutSecs, req)

Expand Down
4 changes: 2 additions & 2 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ Also https://www.digitalocean.com/community/tutorials/using-ldflags-to-set-versi
**/

// The main version number that is being run at the moment.
var steampipeVersion = "1.0.3"
var steampipeVersion = "1.0.4"

// A pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release
// such as "dev" (in development), "beta", "rc1", etc.
var prerelease = ""
var prerelease = "rc.0"

// SteampipeVersion is an instance of semver.Version. This has the secondary
// benefit of verifying during tests and init time that our version is a
Expand Down
Loading