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: Allow startup duration/interval to be overridden via env vars #2649

Merged
merged 2 commits into from
Jul 31, 2020
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
3 changes: 0 additions & 3 deletions cmd/core-command/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,3 @@ RetryWaitPeriod = "1s"
[SecretStore.Authentication]
AuthType = 'X-Vault-Token'

[Startup]
Duration = 30
Interval = 1
4 changes: 0 additions & 4 deletions cmd/core-data/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,3 @@ AdditionalRetryAttempts = 10
RetryWaitPeriod = "1s"
[SecretStore.Authentication]
AuthType = 'X-Vault-Token'

[Startup]
Duration = 30
Interval = 1
3 changes: 0 additions & 3 deletions cmd/core-metadata/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,3 @@ RetryWaitPeriod = "1s"
[SecretStore.Authentication]
AuthType = 'X-Vault-Token'

[Startup]
Duration = 30
Interval = 1
4 changes: 0 additions & 4 deletions cmd/security-proxy-setup/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,3 @@ SNIS = ["localhost"]
Protocol = "http"
Host = "localhost"
Port = 49990

[Startup]
Duration = 30
Interval = 1
4 changes: 0 additions & 4 deletions cmd/security-secrets-setup/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ WorkDir = "/tmp/edgex/secrets-setup"
DeployDir = "/tmp/edgex/secrets"
CacheDir = "/etc/edgex/pki"
CertConfigDir = "./res"

[Startup]
Duration = 30
Interval = 1
4 changes: 0 additions & 4 deletions cmd/security-secretstore-setup/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ TokenProviderType = "oneshot"
TokenProviderAdminTokenPath = "/run/edgex/secrets/tokenprovider/secrets-token.json"
RevokeRootTokens = true

[Startup]
Duration = 30
Interval = 1

[Databases]
[Databases.admin]
Username = "admin"
Expand Down
3 changes: 0 additions & 3 deletions cmd/support-logging/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,3 @@ RetryWaitPeriod = "1s"
[SecretStore.Authentication]
AuthType = 'X-Vault-Token'

[Startup]
Duration = 30
Interval = 1
3 changes: 0 additions & 3 deletions cmd/support-notifications/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,3 @@ RetryWaitPeriod = "1s"
[SecretStore.Authentication]
AuthType = 'X-Vault-Token'

[Startup]
Duration = 30
Interval = 1
3 changes: 0 additions & 3 deletions cmd/support-scheduler/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,3 @@ RetryWaitPeriod = "1s"
[SecretStore.Authentication]
AuthType = 'X-Vault-Token'

[Startup]
Duration = 30
Interval = 1
4 changes: 0 additions & 4 deletions cmd/sys-mgmt-agent/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,3 @@ File = ''
Protocol = 'http'
Host = 'localhost'
Port = 48085

[Startup]
Duration = 30
Interval = 1
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/OneOfOne/xxhash v1.2.5
github.com/cloudflare/gokey v0.1.0
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/edgexfoundry/go-mod-bootstrap v0.0.36
github.com/edgexfoundry/go-mod-bootstrap v0.0.37
github.com/edgexfoundry/go-mod-configuration v0.0.3
github.com/edgexfoundry/go-mod-core-contracts v0.1.58
github.com/edgexfoundry/go-mod-messaging v0.1.19
Expand Down
9 changes: 3 additions & 6 deletions internal/core/command/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package config

import (
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/interfaces"
bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/config"
)

Expand All @@ -28,7 +27,6 @@ type ConfigurationStruct struct {
Registry bootstrapConfig.RegistryInfo
Service bootstrapConfig.ServiceInfo
SecretStore bootstrapConfig.SecretStoreInfo
Startup bootstrapConfig.StartupInfo
}

// WritableInfo contains configuration properties that can be updated and applied without restarting the service.
Expand Down Expand Up @@ -69,15 +67,14 @@ func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) boo
// GetBootstrap returns the configuration elements required by the bootstrap. Currently, a copy of the configuration
// data is returned. This is intended to be temporary -- since ConfigurationStruct drives the configuration.toml's
// structure -- until we can make backwards-breaking configuration.toml changes (which would consolidate these fields
// into an interfaces.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() interfaces.BootstrapConfiguration {
return interfaces.BootstrapConfiguration{
// into an bootstrapConfig.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() bootstrapConfig.BootstrapConfiguration {
return bootstrapConfig.BootstrapConfiguration{
Clients: c.Clients,
Service: c.Service,
Registry: c.Registry,
Logging: c.Logging,
SecretStore: c.SecretStore,
Startup: c.Startup,
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/core/command/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
)

func Main(ctx context.Context, cancel context.CancelFunc, router *mux.Router, readyStream chan<- bool) {
startupTimer := startup.NewStartUpTimer(internal.BootRetrySecondsDefault, internal.BootTimeoutSecondsDefault)
startupTimer := startup.NewStartUpTimer(clients.CoreCommandServiceKey)

// All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here,
// by inserting service specific flag prior to call to commonFlags.Parse().
Expand Down
9 changes: 3 additions & 6 deletions internal/core/data/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package config
import (
"fmt"

"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/interfaces"
bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/config"
)

Expand All @@ -29,7 +28,6 @@ type ConfigurationStruct struct {
Registry bootstrapConfig.RegistryInfo
Service bootstrapConfig.ServiceInfo
SecretStore bootstrapConfig.SecretStoreInfo
Startup bootstrapConfig.StartupInfo
}

type WritableInfo struct {
Expand Down Expand Up @@ -98,16 +96,15 @@ func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) boo
// GetBootstrap returns the configuration elements required by the bootstrap. Currently, a copy of the configuration
// data is returned. This is intended to be temporary -- since ConfigurationStruct drives the configuration.toml's
// structure -- until we can make backwards-breaking configuration.toml changes (which would consolidate these fields
// into an interfaces.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() interfaces.BootstrapConfiguration {
// into an bootstrapConfig.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() bootstrapConfig.BootstrapConfiguration {
// temporary until we can make backwards-breaking configuration.toml change
return interfaces.BootstrapConfiguration{
return bootstrapConfig.BootstrapConfiguration{
Clients: c.Clients,
Service: c.Service,
Registry: c.Registry,
Logging: c.Logging,
SecretStore: c.SecretStore,
Startup: c.Startup,
}
}

Expand Down
15 changes: 12 additions & 3 deletions internal/core/data/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewBootstrap(router *mux.Router) *Bootstrap {
}

// BootstrapHandler fulfills the BootstrapHandler contract and performs initialization needed by the data service.
func (b *Bootstrap) BootstrapHandler(ctx context.Context, wg *sync.WaitGroup, _ startup.Timer, dic *di.Container) bool {
func (b *Bootstrap) BootstrapHandler(ctx context.Context, wg *sync.WaitGroup, startupTimer startup.Timer, dic *di.Container) bool {
loadRestRoutes(b.router, dic)

configuration := dataContainer.ConfigurationFrom(dic.Get)
Expand All @@ -76,9 +76,18 @@ func (b *Bootstrap) BootstrapHandler(ctx context.Context, wg *sync.WaitGroup, _
return false
}

err = msgClient.Connect()
for startupTimer.HasNotElapsed() {
err = msgClient.Connect()
if err == nil {
break
}

lc.Warn(fmt.Sprintf("couldn't connect to message bus: %s", err.Error()))
startupTimer.SleepForInterval()
}

if err != nil {
lc.Error(fmt.Sprintf("failed to connect to message bus: %s", err.Error()))
lc.Error(fmt.Sprintf("failed to connect to message bus in allotted time"))
return false
}

Expand Down
2 changes: 1 addition & 1 deletion internal/core/data/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
)

func Main(ctx context.Context, cancel context.CancelFunc, router *mux.Router, readyStream chan<- bool) {
startupTimer := startup.NewStartUpTimer(internal.BootRetrySecondsDefault, internal.BootTimeoutSecondsDefault)
startupTimer := startup.NewStartUpTimer(clients.CoreDataServiceKey)

// All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here,
// by inserting service specific flag prior to call to commonFlags.Parse().
Expand Down
9 changes: 3 additions & 6 deletions internal/core/metadata/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package config

import (
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/interfaces"
bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/config"
)

Expand All @@ -29,7 +28,6 @@ type ConfigurationStruct struct {
Registry bootstrapConfig.RegistryInfo
Service bootstrapConfig.ServiceInfo
SecretStore bootstrapConfig.SecretStoreInfo
Startup bootstrapConfig.StartupInfo
}

type WritableInfo struct {
Expand Down Expand Up @@ -80,16 +78,15 @@ func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) boo
// GetBootstrap returns the configuration elements required by the bootstrap. Currently, a copy of the configuration
// data is returned. This is intended to be temporary -- since ConfigurationStruct drives the configuration.toml's
// structure -- until we can make backwards-breaking configuration.toml changes (which would consolidate these fields
// into an interfaces.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() interfaces.BootstrapConfiguration {
// into an bootstrapConfig.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() bootstrapConfig.BootstrapConfiguration {
// temporary until we can make backwards-breaking configuration.toml change
return interfaces.BootstrapConfiguration{
return bootstrapConfig.BootstrapConfiguration{
Clients: c.Clients,
Service: c.Service,
Registry: c.Registry,
Logging: c.Logging,
SecretStore: c.SecretStore,
Startup: c.Startup,
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/core/metadata/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
)

func Main(ctx context.Context, cancel context.CancelFunc, router *mux.Router, readyStream chan<- bool) {
startupTimer := startup.NewStartUpTimer(internal.BootRetrySecondsDefault, internal.BootTimeoutSecondsDefault)
startupTimer := startup.NewStartUpTimer(clients.CoreMetaDataServiceKey)

// All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here,
// by inserting service specific flag prior to call to commonFlags.Parse().
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/bootstrap/handlers/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (d Database) BootstrapHandler(
}

if dbClient == nil {
lc.Error(fmt.Sprintf("failed to create database client in allotted time"))
return false
}

Expand Down
7 changes: 3 additions & 4 deletions internal/security/fileprovider/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package config
import (
"github.com/edgexfoundry/edgex-go/internal/security/secretstoreclient"

"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/interfaces"
bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/config"
)

Expand Down Expand Up @@ -79,10 +78,10 @@ func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) boo
// GetBootstrap returns the configuration elements required by the bootstrap. Currently, a copy of the configuration
// data is returned. This is intended to be temporary -- since ConfigurationStruct drives the configuration.toml's
// structure -- until we can make backwards-breaking configuration.toml changes (which would consolidate these fields
// into an interfaces.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() interfaces.BootstrapConfiguration {
// into an bootstrapConfig.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() bootstrapConfig.BootstrapConfiguration {
// temporary until we can make backwards-breaking configuration.toml change
return interfaces.BootstrapConfiguration{
return bootstrapConfig.BootstrapConfiguration{
Logging: c.Logging,
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/security/fileprovider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
)

func Main(ctx context.Context, cancel context.CancelFunc, _ *mux.Router, _ chan<- bool) {
startupTimer := startup.NewStartUpTimer(internal.BootRetrySecondsDefault, internal.BootTimeoutSecondsDefault)
startupTimer := startup.NewStartUpTimer(clients.SecurityFileTokenProviderServiceKey)

// All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here,
// by inserting service specific flag prior to call to commonFlags.Parse().
Expand Down
7 changes: 3 additions & 4 deletions internal/security/proxy/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"net/url"

"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/interfaces"
bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/config"
"github.com/edgexfoundry/go-mod-secrets/pkg/providers/vault"
)
Expand Down Expand Up @@ -127,8 +126,8 @@ func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) boo
// GetBootstrap returns the configuration elements required by the bootstrap. Currently, a copy of the configuration
// data is returned. This is intended to be temporary -- since ConfigurationStruct drives the configuration.toml's
// structure -- until we can make backwards-breaking configuration.toml changes (which would consolidate these fields
// into an interfaces.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() interfaces.BootstrapConfiguration {
// into an bootstrapConfig.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() bootstrapConfig.BootstrapConfiguration {
//To keep config file for proxy unchanged in Geneva we need to create a temporary SecretStore struct so that bootstrapHandler can use it to create a secret client
//The config file may be changed in the future version and SecretStore can be used directly like other core services
ss := bootstrapConfig.SecretStoreInfo{
Expand All @@ -145,7 +144,7 @@ func (c *ConfigurationStruct) GetBootstrap() interfaces.BootstrapConfiguration {
}

// temporary until we can make backwards-breaking configuration.toml change
return interfaces.BootstrapConfiguration{
return bootstrapConfig.BootstrapConfiguration{
Clients: c.Clients,
Logging: c.Logging,
SecretStore: ss,
Expand Down
2 changes: 1 addition & 1 deletion internal/security/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
)

func Main(ctx context.Context, cancel context.CancelFunc, _ *mux.Router, _ chan<- bool) {
startupTimer := startup.NewStartUpTimer(internal.BootRetrySecondsDefault, internal.BootTimeoutSecondsDefault)
startupTimer := startup.NewStartUpTimer(clients.SecurityProxySetupServiceKey)

var initNeeded bool
var insecureSkipVerify bool
Expand Down
7 changes: 3 additions & 4 deletions internal/security/secrets/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package config

import (
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/interfaces"
bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/config"
)

Expand Down Expand Up @@ -69,10 +68,10 @@ func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) boo
// GetBootstrap returns the configuration elements required by the bootstrap. Currently, a copy of the configuration
// data is returned. This is intended to be temporary -- since ConfigurationStruct drives the configuration.toml's
// structure -- until we can make backwards-breaking configuration.toml changes (which would consolidate these fields
// into an interfaces.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() interfaces.BootstrapConfiguration {
// into an bootstrapConfig.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() bootstrapConfig.BootstrapConfiguration {
// temporary until we can make backwards-breaking configuration.toml change
return interfaces.BootstrapConfiguration{
return bootstrapConfig.BootstrapConfiguration{
Logging: c.Logging,
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/security/secrets/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

func Main(ctx context.Context, cancel context.CancelFunc) (*config.ConfigurationStruct, int) {
startupTimer := startup.NewStartUpTimer(internal.BootRetrySecondsDefault, internal.BootTimeoutSecondsDefault)
startupTimer := startup.NewStartUpTimer(clients.SecuritySecretsSetupServiceKey)

// Common Command-line flags have been moved to command.CommonFlags, but this service doesn't use all
// the common flags so we are using our own implementation of the CommonFlags interface
Expand Down
7 changes: 3 additions & 4 deletions internal/security/secretstore/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package config
import (
"github.com/edgexfoundry/edgex-go/internal/security/secretstoreclient"

"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/interfaces"
bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/config"
)

Expand Down Expand Up @@ -72,10 +71,10 @@ func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) boo
// GetBootstrap returns the configuration elements required by the bootstrap. Currently, a copy of the configuration
// data is returned. This is intended to be temporary -- since ConfigurationStruct drives the configuration.toml's
// structure -- until we can make backwards-breaking configuration.toml changes (which would consolidate these fields
// into an interfaces.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() interfaces.BootstrapConfiguration {
// into an bootstrapConfig.BootstrapConfiguration struct contained within ConfigurationStruct).
func (c *ConfigurationStruct) GetBootstrap() bootstrapConfig.BootstrapConfiguration {
// temporary until we can make backwards-breaking configuration.toml change
return interfaces.BootstrapConfiguration{
return bootstrapConfig.BootstrapConfiguration{
Logging: c.Logging,
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/security/secretstore/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
)

func Main(ctx context.Context, cancel context.CancelFunc, _ *mux.Router, _ chan<- bool) {
startupTimer := startup.NewStartUpTimer(internal.BootRetrySecondsDefault, internal.BootTimeoutSecondsDefault)
startupTimer := startup.NewStartUpTimer(clients.SecuritySecretStoreSetupServiceKey)

var insecureSkipVerify bool
var vaultInterval int
Expand Down
Loading