From c32f17d14ef3e7e50b2d3d7f197a8e776f893bcb Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Tue, 6 Jul 2021 00:10:10 +0430 Subject: [PATCH 1/7] fix race condition on sudphConn for closing address_reslover --- pkg/snet/arclient/client.go | 3 +-- pkg/snet/network.go | 13 ++++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/pkg/snet/arclient/client.go b/pkg/snet/arclient/client.go index 360d4467d7..c51d02dd7c 100644 --- a/pkg/snet/arclient/client.go +++ b/pkg/snet/arclient/client.go @@ -432,10 +432,9 @@ func (c *httpClient) Close() error { if err := c.sudphConn.Close(); err != nil { c.log.WithError(err).Errorf("Failed to close SUDPH") } + close(c.closed) } - close(c.closed) - return nil } diff --git a/pkg/snet/network.go b/pkg/snet/network.go index 128e6b576f..e36b6018ba 100644 --- a/pkg/snet/network.go +++ b/pkg/snet/network.go @@ -274,16 +274,11 @@ func (n *Network) Close() error { if directClient == nil { continue } - wg.Add(1) - go func(client directtp.Client) { - err := client.Close() - if err != nil { - directErrors <- err - } - wg.Done() - }(directClient) + err := directClient.Close() + if err != nil { + directErrors <- err + } } - wg.Wait() close(directErrors) if dmsgErr != nil { From 04ba8495d93d4cc01a6103c25610d724d6fb01f2 Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Tue, 6 Jul 2021 00:21:16 +0430 Subject: [PATCH 2/7] add wg.Wait() that deleted in wrong --- pkg/snet/network.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/snet/network.go b/pkg/snet/network.go index e36b6018ba..24162bc88c 100644 --- a/pkg/snet/network.go +++ b/pkg/snet/network.go @@ -280,7 +280,7 @@ func (n *Network) Close() error { } } close(directErrors) - + wg.Wait() if dmsgErr != nil { return dmsgErr } From e817698aa80e42abb80d2ae85afb9b174da33fb4 Mon Sep 17 00:00:00 2001 From: Alexander Adhyatma Date: Wed, 7 Jul 2021 13:10:47 +0700 Subject: [PATCH 3/7] added git to prequisites --- docker/images/visor/install-preq.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docker/images/visor/install-preq.sh b/docker/images/visor/install-preq.sh index 8867903719..a3b678ad9d 100755 --- a/docker/images/visor/install-preq.sh +++ b/docker/images/visor/install-preq.sh @@ -1,13 +1,13 @@ #!/bin/sh -if type apt > /dev/null; then - apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ - && rm -rf /var/lib/apt/lists/* +if type apt >/dev/null; then + apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates && + rm -rf /var/lib/apt/lists/* fi -if type apk > /dev/null; then - apk update - apk add --no-cache ca-certificates openssl iproute2 bash - update-ca-certificates --fresh +if type apk >/dev/null; then + apk update + apk add --no-cache ca-certificates openssl iproute2 bash git + update-ca-certificates --fresh fi From 6cf3bbc708adc16d93f76b419b772ff5ef5e6619 Mon Sep 17 00:00:00 2001 From: Alexander Adhyatma Date: Wed, 7 Jul 2021 13:20:11 +0700 Subject: [PATCH 4/7] fixes version not showing --- .dockerignore | 1 - docker/images/visor/Dockerfile | 3 +-- docker/images/visor/install-preq.sh | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index e589eea63c..c085529283 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ -.git bin skywire ci_scripts diff --git a/docker/images/visor/Dockerfile b/docker/images/visor/Dockerfile index bf96f41c16..17c95287f2 100644 --- a/docker/images/visor/Dockerfile +++ b/docker/images/visor/Dockerfile @@ -6,14 +6,13 @@ ARG BUILDINFO_LDFLAGS ARG CGO_ENABLED=0 ENV CGO_ENABLED=${CGO_ENABLED} \ GOOS=linux \ - GOARCH=amd64 \ GO111MODULE=on COPY . /skywire WORKDIR /skywire -RUN apk add --no-cache make && \ +RUN apk add --no-cache make git && \ sh -c /skywire/docker/images/visor/install-preq.sh && \ make host-apps && \ make build-deploy && \ diff --git a/docker/images/visor/install-preq.sh b/docker/images/visor/install-preq.sh index a3b678ad9d..8c8293c825 100755 --- a/docker/images/visor/install-preq.sh +++ b/docker/images/visor/install-preq.sh @@ -8,6 +8,6 @@ fi if type apk >/dev/null; then apk update - apk add --no-cache ca-certificates openssl iproute2 bash git + apk add --no-cache ca-certificates openssl iproute2 bash update-ca-certificates --fresh fi From 38cb1838baddb1d2dfb8e512437963d33db88d6f Mon Sep 17 00:00:00 2001 From: Alexander Adhyatma Date: Wed, 7 Jul 2021 13:39:30 +0700 Subject: [PATCH 5/7] fixes panic if launcher discovery is null --- pkg/visor/visorconfig/parse.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/visor/visorconfig/parse.go b/pkg/visor/visorconfig/parse.go index ba449fefad..2a51c74e5a 100644 --- a/pkg/visor/visorconfig/parse.go +++ b/pkg/visor/visorconfig/parse.go @@ -58,6 +58,7 @@ func parseV1(cc *Common, raw []byte) (*V1, error) { if err := conf.ensureKeys(); err != nil { return nil, fmt.Errorf("%v: %w", ErrInvalidSK, err) } + conf = ensureAppDisc(conf) conf = updateUrls(conf) conf.Version = V1Name return conf, conf.flush(conf) @@ -158,6 +159,16 @@ func parseV0(cc *Common, raw []byte) (*V1, error) { return conf, conf.flush(conf) } + +func ensureAppDisc(conf *V1) *V1 { + if conf.Launcher.Discovery == nil { + conf.Launcher.Discovery = &V1AppDisc{ + ServiceDisc: skyenv.DefaultServiceDiscAddr, + } + } + return conf +} + func updateUrls(conf *V1) *V1 { if conf.Dmsg.Discovery == skyenv.OldDefaultDmsgDiscAddr { conf.Dmsg.Discovery = skyenv.DefaultDmsgDiscAddr From c537b8dc095b334021d63071faf7320748d41ac3 Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Tue, 6 Jul 2021 00:10:10 +0430 Subject: [PATCH 6/7] fix race condition on sudphConn for closing address_reslover --- pkg/snet/arclient/client.go | 3 +-- pkg/snet/network.go | 13 ++++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/pkg/snet/arclient/client.go b/pkg/snet/arclient/client.go index 360d4467d7..c51d02dd7c 100644 --- a/pkg/snet/arclient/client.go +++ b/pkg/snet/arclient/client.go @@ -432,10 +432,9 @@ func (c *httpClient) Close() error { if err := c.sudphConn.Close(); err != nil { c.log.WithError(err).Errorf("Failed to close SUDPH") } + close(c.closed) } - close(c.closed) - return nil } diff --git a/pkg/snet/network.go b/pkg/snet/network.go index 128e6b576f..e36b6018ba 100644 --- a/pkg/snet/network.go +++ b/pkg/snet/network.go @@ -274,16 +274,11 @@ func (n *Network) Close() error { if directClient == nil { continue } - wg.Add(1) - go func(client directtp.Client) { - err := client.Close() - if err != nil { - directErrors <- err - } - wg.Done() - }(directClient) + err := directClient.Close() + if err != nil { + directErrors <- err + } } - wg.Wait() close(directErrors) if dmsgErr != nil { From 83a904a1e267589162b5772c253eef952fcd7f69 Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Tue, 6 Jul 2021 00:21:16 +0430 Subject: [PATCH 7/7] add wg.Wait() that deleted in wrong --- pkg/snet/network.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/snet/network.go b/pkg/snet/network.go index e36b6018ba..24162bc88c 100644 --- a/pkg/snet/network.go +++ b/pkg/snet/network.go @@ -280,7 +280,7 @@ func (n *Network) Close() error { } } close(directErrors) - + wg.Wait() if dmsgErr != nil { return dmsgErr }