From 40310df61fdca357eb0b601f2351cc3b8baac2c3 Mon Sep 17 00:00:00 2001 From: John Lee Date: Wed, 20 Jan 2021 11:31:50 -0500 Subject: [PATCH 1/4] Update buildnumber.dat --- buildnumber.dat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildnumber.dat b/buildnumber.dat index 573541ac97..d00491fd7e 100644 --- a/buildnumber.dat +++ b/buildnumber.dat @@ -1 +1 @@ -0 +1 From 1d002c7f8050a1887977c8ad654ca0fdd5844a69 Mon Sep 17 00:00:00 2001 From: Tsachi Herman Date: Wed, 20 Jan 2021 08:55:50 -0500 Subject: [PATCH 2/4] Fix regression to loadTelemetryConfig introduced in 2.3.0 (#1845) As part of a refactoring effort in https://github.com/algorand/go-algorand/pull/1709, a small bug was introduced that changed the intended behavior of `loadTelemetryConfig`. This PR restores the previous behavior and adds a unit test for that. --- logging/telemetryConfig.go | 3 ++- logging/telemetryConfig_test.go | 12 ++++++++++++ test/testdata/configs/logging/logging.config.test1 | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/testdata/configs/logging/logging.config.test1 diff --git a/logging/telemetryConfig.go b/logging/telemetryConfig.go index 7fa2254261..0e3818c444 100644 --- a/logging/telemetryConfig.go +++ b/logging/telemetryConfig.go @@ -133,8 +133,9 @@ func loadTelemetryConfig(path string) (TelemetryConfig, error) { return createTelemetryConfig(), err } defer f.Close() - cfg := createTelemetryConfig() + var cfg TelemetryConfig var marshaledConfig MarshalingTelemetryConfig + marshaledConfig.TelemetryConfig = createTelemetryConfig() dec := json.NewDecoder(f) err = dec.Decode(&marshaledConfig) cfg = marshaledConfig.TelemetryConfig diff --git a/logging/telemetryConfig_test.go b/logging/telemetryConfig_test.go index 65ee74261b..362ecd6577 100644 --- a/logging/telemetryConfig_test.go +++ b/logging/telemetryConfig_test.go @@ -107,3 +107,15 @@ func Test_SanitizeTelemetryString(t *testing.T) { require.Equal(t, test.expected, SanitizeTelemetryString(test.input, test.parts)) } } + +func TestLoadTelemetryConfig(t *testing.T) { + testLoggingConfigFileName := "../test/testdata/configs/logging/logging.config.test1" + tc, err := loadTelemetryConfig(testLoggingConfigFileName) + require.NoError(t, err) + require.Equal(t, true, tc.Enable) + // make sure the user name was loaded from the specified file + require.Equal(t, "test-user-name", tc.UserName) + // ensure we know how to default correctly if some of the fields in the configuration field aren't specified. + require.Equal(t, createTelemetryConfig().Password, tc.Password) + +} diff --git a/test/testdata/configs/logging/logging.config.test1 b/test/testdata/configs/logging/logging.config.test1 new file mode 100644 index 0000000000..8e9e46fd35 --- /dev/null +++ b/test/testdata/configs/logging/logging.config.test1 @@ -0,0 +1,4 @@ +{ + "Enable": true, + "UserName": "test-user-name" +} From 6b62f796ff2b41f35d45bb965e47e28be857f473 Mon Sep 17 00:00:00 2001 From: btoll Date: Wed, 20 Jan 2021 10:06:42 -0500 Subject: [PATCH 3/4] Move check_golang_version check to fix travis builds (#1827) The call to check_golang_version.sh is causing the travis run to fail when deploying: https://travis-ci.com/github/algorand/go-algorand/jobs/470973034#L142 --- scripts/travis/deploy_packages.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/travis/deploy_packages.sh b/scripts/travis/deploy_packages.sh index d4dbccc48c..c98b957304 100755 --- a/scripts/travis/deploy_packages.sh +++ b/scripts/travis/deploy_packages.sh @@ -12,10 +12,6 @@ set -e SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" -if ! "${SCRIPTPATH}/../check_golang_version.sh" -then - exit 1 -fi # Get the go build version. GOLANG_VERSION=$("${SCRIPTPATH}/../get_golang_version.sh") @@ -23,6 +19,11 @@ curl -sL -o ~/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gim chmod +x ~/gimme eval "$(~/gimme "${GOLANG_VERSION}")" +if ! "${SCRIPTPATH}/../check_golang_version.sh" +then + exit 1 +fi + scripts/travis/build.sh export RELEASE_GENESIS_PROCESS=true From 3c07756cbaa9b1d2db98b5747759f977f5508420 Mon Sep 17 00:00:00 2001 From: bricerisingalgorand <60147418+bricerisingalgorand@users.noreply.github.com> Date: Wed, 20 Jan 2021 13:42:40 -0500 Subject: [PATCH 4/4] diagcfg : Read from global logging config if data dir not provided (#1844) When a datadir is not provided, this will have diagcfg read from the default logging config in the global config path. It will then generate a default config if that file does not exist --- cmd/diagcfg/telemetry.go | 4 ++-- logging/telemetry.go | 9 +++++---- logging/telemetry_test.go | 23 ++++++++++++++++++++++- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/cmd/diagcfg/telemetry.go b/cmd/diagcfg/telemetry.go index a54289e268..c7df1bc83c 100644 --- a/cmd/diagcfg/telemetry.go +++ b/cmd/diagcfg/telemetry.go @@ -55,7 +55,7 @@ func maybeUpdateDataDirFromEnv() { func readTelemetryConfigOrExit() logging.TelemetryConfig { maybeUpdateDataDirFromEnv() - cfg, err := logging.ReadTelemetryConfigOrDefault(&dataDir, "") + cfg, err := logging.ReadTelemetryConfigOrDefault(dataDir, "") if err != nil { fmt.Fprintf(os.Stderr, telemetryConfigReadError, err) os.Exit(1) @@ -112,7 +112,7 @@ var telemetryStatusCmd = &cobra.Command{ Long: `Print the node's telemetry status`, Run: func(cmd *cobra.Command, args []string) { maybeUpdateDataDirFromEnv() - cfg, err := logging.ReadTelemetryConfigOrDefault(&dataDir, "") + cfg, err := logging.ReadTelemetryConfigOrDefault(dataDir, "") // If error loading config, can't disable / no need to disable if err != nil { diff --git a/logging/telemetry.go b/logging/telemetry.go index 50be5a0ca8..7258b9ca61 100644 --- a/logging/telemetry.go +++ b/logging/telemetry.go @@ -90,13 +90,14 @@ func makeTelemetryState(cfg TelemetryConfig, hookFactory hookFactory) (*telemetr } // ReadTelemetryConfigOrDefault reads telemetry config from file or defaults if no config file found. -func ReadTelemetryConfigOrDefault(dataDir *string, genesisID string) (cfg TelemetryConfig, err error) { +func ReadTelemetryConfigOrDefault(dataDir string, genesisID string) (cfg TelemetryConfig, err error) { err = nil - if dataDir != nil && *dataDir != "" { - configPath := filepath.Join(*dataDir, TelemetryConfigFilename) + dataDirProvided := dataDir != "" + if dataDirProvided { + configPath := filepath.Join(dataDir, TelemetryConfigFilename) cfg, err = LoadTelemetryConfig(configPath) } - if err != nil && os.IsNotExist(err) { + if (err != nil && os.IsNotExist(err)) || !dataDirProvided { var configPath string configPath, err = config.GetConfigFilePath(TelemetryConfigFilename) if err != nil { diff --git a/logging/telemetry_test.go b/logging/telemetry_test.go index dbfa04c0fc..fce2e6d9e1 100644 --- a/logging/telemetry_test.go +++ b/logging/telemetry_test.go @@ -18,13 +18,16 @@ package logging import ( "fmt" + "os" "testing" "time" - "github.com/algorand/go-deadlock" "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" + "github.com/algorand/go-deadlock" + + "github.com/algorand/go-algorand/config" "github.com/algorand/go-algorand/logging/telemetryspec" ) @@ -315,3 +318,21 @@ func TestLogHistoryLevels(t *testing.T) { a.Nil(data[5]["log"]) // Panic - this is stack trace a.NotNil(data[6]["log"]) // Panic } + +func TestReadTelemetryConfigOrDefaultNoDataDir(t *testing.T) { + a := require.New(t) + tempDir := os.TempDir() + originalGlobalConfigFileRoot, _ := config.GetGlobalConfigFileRoot() + config.SetGlobalConfigFileRoot(tempDir) + + cfg, err := ReadTelemetryConfigOrDefault("", "") + defaultCfgSettings := createTelemetryConfig() + config.SetGlobalConfigFileRoot(originalGlobalConfigFileRoot) + + a.Nil(err) + a.NotNil(cfg) + a.NotEqual(TelemetryConfig{}, cfg) + a.Equal(defaultCfgSettings.UserName, cfg.UserName) + a.Equal(defaultCfgSettings.Password, cfg.Password) + a.Equal(len(defaultCfgSettings.GUID), len(cfg.GUID)) +}