From 2c41f20d36a5467ded9d1e3df7ed421f72eb5fbc Mon Sep 17 00:00:00 2001 From: Kirill Maksimov Date: Thu, 29 Oct 2020 14:04:11 +0200 Subject: [PATCH 1/2] Refactor build system, add checksums --- .circleci/export.sh | 2 +- .gitignore | 1 + build-binaries.sh | 9 ++++++++- docker-build.sh | 5 ++++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.circleci/export.sh b/.circleci/export.sh index 0ecf3278..3ecff2b5 100755 --- a/.circleci/export.sh +++ b/.circleci/export.sh @@ -3,4 +3,4 @@ export VERSION=$(cat .version) export BOYAR_S3_PATH=s3://orbs-network-releases/infrastructure/boyar/boyar-$VERSION.bin -aws s3 cp --acl public-read ./boyar.bin $BOYAR_S3_PATH \ No newline at end of file +aws s3 cp --acl public-read --recursive ./_bin $BOYAR_S3_PATH diff --git a/.gitignore b/.gitignore index 6d79da3f..0f3e46e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea _tmp +_bin strelets.bin boyar.bin e2e.test \ No newline at end of file diff --git a/build-binaries.sh b/build-binaries.sh index 22d22615..ee41af84 100755 --- a/build-binaries.sh +++ b/build-binaries.sh @@ -5,4 +5,11 @@ export GIT_COMMIT=${GIT_COMMIT-$(./.circleci/hash.sh)} export CONFIG_PKG="github.com/orbs-network/boyarin/version" export CGO_ENABLED=0 -go build -ldflags "-w -extldflags '-static' -X $CONFIG_PKG.SemanticVersion=$SEMVER -X $CONFIG_PKG.CommitVersion=$GIT_COMMIT" -tags "$BUILD_FLAG usergo netgo" -o boyar.bin -a ./boyar/main/main.go +rm -rf _bin + +go build -ldflags "-w -extldflags '-static' -X $CONFIG_PKG.SemanticVersion=$SEMVER -X $CONFIG_PKG.CommitVersion=$GIT_COMMIT" -tags "$BUILD_FLAG usergo netgo" -o _bin/boyar-${SEMVER}.bin -a ./boyar/main/main.go + +cd _bin +shasum -a 256 boyar-${SEMVER}.bin > sha256checksums.txt +cd - + diff --git a/docker-build.sh b/docker-build.sh index fbd198f4..5520e9fd 100755 --- a/docker-build.sh +++ b/docker-build.sh @@ -7,5 +7,8 @@ docker build --build-arg git_commit=$(./.circleci/hash.sh) -f Dockerfile.build - docker run --name orbs_build orbs:build sleep 1 export SRC=/src +export SERMVER=$(cat ./version) + +rm -rf _bin +docker cp orbs_build:$SRC/_bin . -docker cp orbs_build:$SRC/boyar.bin . From e1ffaa52f4762d318a67242baf56d32185b3c05f Mon Sep 17 00:00:00 2001 From: Kirill Maksimov Date: Thu, 29 Oct 2020 14:04:32 +0200 Subject: [PATCH 2/2] Fix autoupdate context shutdown --- .version | 2 +- services/execute.go | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.version b/.version index 4e2cea3b..3f0882c5 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -v1.8.0 \ No newline at end of file +v1.8.1 \ No newline at end of file diff --git a/services/execute.go b/services/execute.go index cfbd14c3..4f569c48 100644 --- a/services/execute.go +++ b/services/execute.go @@ -19,6 +19,8 @@ func Execute(ctx context.Context, flags *config.Flags, logger log.Logger) (govnr return nil, fmt.Errorf("--keys is a required parameter for provisioning flow") } + // crucial for a proper shutdown + ctxWithCancel, cancelAndExit := context.WithCancel(ctx) supervisor := &govnr.TreeSupervisor{} // clean up old files @@ -29,14 +31,13 @@ func Execute(ctx context.Context, flags *config.Flags, logger log.Logger) (govnr if flags.StatusFilePath == "" && flags.MetricsFilePath == "" { logger.Info("status file path and metrics file path are empty, periodical report disabled") } else { - supervisor.Supervise(WatchAndReportStatusAndMetrics(ctx, logger, flags.StatusFilePath, flags.MetricsFilePath)) + supervisor.Supervise(WatchAndReportStatusAndMetrics(ctxWithCancel, logger, flags.StatusFilePath, flags.MetricsFilePath)) } cfgFetcher := NewConfigurationPollService(flags, logger) coreBoyar := NewCoreBoyarService(logger) // wire cfg and boyar - ctxWithCancel, cancelAndExit := context.WithCancel(ctx) supervisor.Supervise(govnr.Forever(ctxWithCancel, "apply config changes", utils.NewLogErrors("apply config changes", logger), func() { var cfg config.NodeConfiguration = nil select { @@ -49,7 +50,7 @@ func Execute(ctx context.Context, flags *config.Flags, logger log.Logger) (govnr } // random delay when provisioning change (that is, not bootstrap flow or repairing broken system) if coreBoyar.healthy { - maybeDelayConfigUpdate(ctx, cfg, flags.MaxReloadTimeDelay, coreBoyar.logger) + maybeDelayConfigUpdate(ctxWithCancel, cfg, flags.MaxReloadTimeDelay, coreBoyar.logger) } else { logger.Info("applying new configuration immediately") } @@ -60,22 +61,22 @@ func Execute(ctx context.Context, flags *config.Flags, logger log.Logger) (govnr return } - ctx, cancel := context.WithTimeout(ctx, flags.Timeout) + ctxWithTimeout, cancel := context.WithTimeout(ctxWithCancel, flags.Timeout) defer cancel() - err := coreBoyar.OnConfigChange(ctx, cfg) + err := coreBoyar.OnConfigChange(ctxWithTimeout, cfg) if err != nil { logger.Error("error executing configuration", log.Error(err)) cfgFetcher.Resend() } - if ctx.Err() != nil { - logger.Error("failed to apply new configuration", log.Error(ctx.Err())) + if ctxWithTimeout.Err() != nil { + logger.Error("failed to apply new configuration", log.Error(ctxWithTimeout.Err())) return } })) - supervisor.Supervise(cfgFetcher.Start(ctx)) + supervisor.Supervise(cfgFetcher.Start(ctxWithCancel)) return supervisor, nil }