From d677b3f260e868db38c2ed6b20c8811206f05e64 Mon Sep 17 00:00:00 2001 From: uvorbs Date: Mon, 9 May 2022 16:20:48 +0300 Subject: [PATCH 1/4] test name --- recovery/recovery_test.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/recovery/recovery_test.go b/recovery/recovery_test.go index 0531a2e..90df8d8 100644 --- a/recovery/recovery_test.go +++ b/recovery/recovery_test.go @@ -116,7 +116,7 @@ func Test_RecoveryJsonInvalid(t *testing.T) { } } -func Test_ExecutionTimeout(t *testing.T) { +func Test_RecoveryTimeout(t *testing.T) { // init recovery config config := Config{ IntervalMinute: 5, @@ -136,6 +136,27 @@ func Test_ExecutionTimeout(t *testing.T) { } } +func Test_RecoveryStderr(t *testing.T) { + url := "https://raw.githubusercontent.com/amihaz/staging-deployment/main/boyar_recovery/node/0xTEST/stderr.json" + + // init recovery config + config := Config{ + IntervalMinute: 1, + Url: url, + } + + logger = log.GetLogger() + Init(config, logger) + + r := GetInstance() + r.tick() + + e := "invalid character" + if r.lastError[:len(e)] != e { + t.Errorf("expect:\n%s got:\n%s", e, r.lastError) + } +} + // this part doesnt work in minutes // { // // timeout exceeded From 92285fd8f564abc2d04bb05fbd77718f69f0e789 Mon Sep 17 00:00:00 2001 From: uvorbs Date: Mon, 9 May 2022 16:22:25 +0300 Subject: [PATCH 2/4] yuval sh --- yuval.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 yuval.sh diff --git a/yuval.sh b/yuval.sh new file mode 100644 index 0000000..2cbb9de --- /dev/null +++ b/yuval.sh @@ -0,0 +1,67 @@ +go build -ldflags '-w -extldflags -static -X github.com/orbs-network/boyarin/version.SemanticVersion=v1.11.2 -X github.com/orbs-network/boyarin/version.CommitVersion=4e5b04d55b26df368ee4d02aabe0bfc1e2a22219' -tags ' usergo netgo' -o _bin/boyar-v1.11.2.bin -a ./boyar/main/main.gogot + +# run existing +./main --keys /opt/orbs/keys.json --max-reload-time-delay 0m --bootstrap-reset-timeout 30m --status /var/efs/boyar-status/status.json --management-config ~/boyar/opt/orbs/management-config.json --auto-update --shutdown-after-update + +# _bin +./boyar-v1.12.1.bin --keys /opt/orbs/keys.json --max-reload-time-delay 0m --bootstrap-reset-timeout 30m --status /var/efs/boyar-status/status.json --management-config ~/boyar/opt/orbs/management-config.json --auto-update --shutdown-after-update + +# run boyar on validator +/usr/bin/boyar --keys /opt/orbs/keys.json --max-reload-time-delay 0m --bootstrap-reset-timeout 30m --status /var/efs/boyar-status/status.json --management-config /opt/orbs/management-config.json --auto-update --shutdown-after-update & + + scp -i ../.ssh/id_rsa_guardians -o StrictHostKeyChecking=no ../../boyarin/_bin/boyar-v1.12.1.bin ubuntu@0xDEV:/usr/bin + + +https://github.com/orbs-network/mainnet-deployment/tree/main/boyar_agent/node/0x9f0988Cd37f14dfe95d44cf21f9987526d6147Ba/main.sh +https://deployment.orbs.network/boyar_agent/node/0x9f0988Cd37f14dfe95d44cf21f9987526d6147Ba/main.sh + + +### cioy local boyar to 0xdev +scp -i ../.ssh/id_rsa_guardians -o StrictHostKeyChecking=no ../../boyarin/_bin/boyar-v1.12.1.bin ubuntu@0xDEV:"~" +cd /usr/bin + +cp /home/ubuntu/boyar-v1.12.1.bin . +supervisorctl stop boyar +rm boyar +mv boyar-v1.12.1.bin boyar + +sudo mv current current.bak2 + +supervisorctl start boyar + + + + + + #okex +iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT + +iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT + +iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 8080 -j REDIRECT --to-port 80 +iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080 + +#list +iptables -t nat -v -L -n --line-number +iptables -t nat -v -L PREROUTING -n --line-number + +#darko +iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 5000 -j DNAT --to-destination 127.0.0.1:80 +iptables -A FORWARD -p tcp -d 127.0.0.1 --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT + +#delete +iptables -t nat -D PREROUTING + +# 2 +socat TCP-LISTEN:8080,fork TCP:127.0.0.1:80 + + +# Add entries in ip table +iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT +iptables -A INPUT -i eth0 -p tcp --dport 18888 -j ACCEPT +# pre rout +iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 18888 -j REDIRECT --to-port 80 +# if not installed +apt-get socat +# for listen on new port +socat TCP-LISTEN:18888,fork TCP:127.0.0.1:80 \ No newline at end of file From c57e6e3649b7d2d5fa60d0e4ad214d38562c9b91 Mon Sep 17 00:00:00 2001 From: uvorbs Date: Tue, 10 May 2022 13:14:16 +0300 Subject: [PATCH 3/4] implement default address if fails --- boyar/main/main.go | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/boyar/main/main.go b/boyar/main/main.go index bd7b798..718efb8 100644 --- a/boyar/main/main.go +++ b/boyar/main/main.go @@ -5,6 +5,7 @@ import ( "encoding/json" "flag" "fmt" + "math/rand" "os" "path/filepath" "time" @@ -126,25 +127,30 @@ func main() { // start recovery ////////////////////////////// logger.Info("============================================") keys, err := config.NewKeysConfig(flags.KeyPairConfigPath) - if err != nil { - logger.Error("failed to get recovery node address, " + err.Error()) + nodeAddress := "" + if err == nil { + nodeAddress = keys.Address() } else { - logger.Info("node address is: " + keys.Address()) - url := fmt.Sprintf("https://deployment.orbs.network/boyar_recovery/node/0x%s/main.json", keys.Address()) - // for testing - //url := fmt.Sprintf("https://raw.githubusercontent.com/amihaz/staging-deployment/main/boyar_recovery/node/0x%s/main.json", keys.Address()) - config := recovery.Config{ - IntervalMinute: 60 * 6, - TimeoutMinute: 30, - Url: url, - } - logger.Info(fmt.Sprintf("Init recovery %+v", &config)) - recovery.Init(config, logger) - - // start - recovery.GetInstance().Start(true) - logger.Info("recovery started") + logger.Error("failed to get recovery node address, " + err.Error()) + } + // generate random address if failed + if nodeAddress == "" { + nodeAddress = fmt.Sprintf("RAND_%d", rand.Intn(0xFFFFFFFF)) } + // go on to init recovery anyways + logger.Info("recovery node address is: " + nodeAddress) + url := fmt.Sprintf("https://deployment.orbs.network/boyar_recovery/node/0x%s/main.json", nodeAddress) + // for testing + //url := fmt.Sprintf("https://raw.githubusercontent.com/amihaz/staging-deployment/main/boyar_recovery/node/0x%s/main.json", keys.Address()) + recovConfig := recovery.Config{ + IntervalMinute: 60 * 6, + TimeoutMinute: 30, + Url: url, + } + recovery.Init(recovConfig, logger) + + // start + recovery.GetInstance().Start(true) logger.Info("============================================") // start services From ddd79ef2b7a44c8aa1bd0cacbfb76d414f4e3157 Mon Sep 17 00:00:00 2001 From: uvorbs Date: Tue, 10 May 2022 13:34:14 +0300 Subject: [PATCH 4/4] fix stderr to pass --- recovery/recovery_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recovery/recovery_test.go b/recovery/recovery_test.go index 90df8d8..07c41de 100644 --- a/recovery/recovery_test.go +++ b/recovery/recovery_test.go @@ -151,9 +151,9 @@ func Test_RecoveryStderr(t *testing.T) { r := GetInstance() r.tick() - e := "invalid character" - if r.lastError[:len(e)] != e { - t.Errorf("expect:\n%s got:\n%s", e, r.lastError) + e := "write_stderr" + if r.lastOutput[:len(e)] != e { + t.Errorf("expect:\n%s got:\n%s", e, r.lastOutput) } }