Skip to content

Commit

Permalink
Bootstrap mode bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Maksimov committed Nov 5, 2020
1 parent bcab624 commit 224c4a4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
7 changes: 7 additions & 0 deletions services/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func Execute(ctx context.Context, flags *config.Flags, logger log.Logger) (govnr
os.Remove(flags.MetricsFilePath)
os.Remove(flags.StatusFilePath)

if flags.BootstrapResetTimeout.Nanoseconds() <= flags.PollingInterval.Nanoseconds() {
return nil, fmt.Errorf("invalid configuration: bootstrap reset timeout is less or equal to config polling interval")
}

if flags.StatusFilePath == "" && flags.MetricsFilePath == "" {
logger.Info("status file path and metrics file path are empty, periodical report disabled")
} else {
Expand Down Expand Up @@ -60,6 +64,9 @@ func Execute(ctx context.Context, flags *config.Flags, logger log.Logger) (govnr

return
}

configUpdateTimestamp = time.Now()

// random delay when provisioning change (that is, not bootstrap flow or repairing broken system)
if coreBoyar.healthy {
maybeDelayConfigUpdate(ctxWithCancel, cfg, flags.MaxReloadTimeDelay, coreBoyar.logger)
Expand Down
16 changes: 16 additions & 0 deletions services/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ import (
"time"
)

func TestExecuteWithInvalidFlags(t *testing.T) {
helpers.WithContext(func(ctx context.Context) {
logger := log.GetLogger()

resetTimeout := 1 * time.Second
pollingInterval := 2 * time.Second
_, err := Execute(ctx, &config.Flags{
ConfigUrl: "http://localhost/fake-url",
KeyPairConfigPath: "../boyar/config/test/fake-key-pair.json",
PollingInterval: pollingInterval,
BootstrapResetTimeout: resetTimeout,
}, logger)
require.EqualError(t, err, "invalid configuration: bootstrap reset timeout is less or equal to config polling interval")
})
}

func TestExecuteWithInvalidConfig(t *testing.T) {
helpers.WithContext(func(ctx context.Context) {
logger := log.GetLogger()
Expand Down
4 changes: 2 additions & 2 deletions strelets/adapter/swarm_get_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func (d *dockerSwarmOrchestrator) GetStatus(ctx context.Context, since time.Dura
return nil, fmt.Errorf("failed to retrieve task list: %s", err)
} else {
for _, task := range tasks {
name, _ := d.getServiceName(ctx, task.ServiceID)
logs, _ := d.getLogs(ctx, task.ServiceID, since)
name, _ := d.getServiceName(ctx, task.ServiceID) // FIXME handle error for non existing service
logs, _ := d.getLogs(ctx, task.ServiceID, since) // FIXME handle more errors

status := &ContainerStatus{
Name: name,
Expand Down

0 comments on commit 224c4a4

Please sign in to comment.