Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove host-keeper service #1063

Merged
merged 3 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- added `-d,--dmsghttp` flag to `skywire-cli config gen`
- added `dmsgdirect` client to connect to services over dmsg
- added `-f` flag to skywire-visor to configure a visor to expose hypervisor UI with default values at runtime
- added `host-keeper` update routine on starting visor process.
## 0.5.0

### Changed
Expand Down
2 changes: 0 additions & 2 deletions cmd/skywire-visor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ func runVisor(args []string) {
}
vis.SetLogstore(store)

go vis.HostKeeper(os.Getenv("SKYBIAN_BUILD_VERSION"))

if launchBrowser {
runBrowser(conf, log)
}
Expand Down
10 changes: 1 addition & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ require (
nhooyr.io/websocket v1.8.2
)

require (
github.com/james-barrow/golang-ipc v0.0.0-20210227130457-95e7cc81f5e2
github.com/jaypipes/ghw v0.8.0
)
require github.com/james-barrow/golang-ipc v0.0.0-20210227130457-95e7cc81f5e2

require (
github.com/ActiveState/termtest/conpty v0.5.0 // indirect
Expand All @@ -68,21 +65,18 @@ require (
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect
github.com/getlantern/errors v1.0.1 // indirect
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jaypipes/pcidb v0.6.0 // indirect
github.com/klauspost/compress v1.11.0 // indirect
github.com/klauspost/cpuid v1.2.4 // indirect
github.com/klauspost/pgzip v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nwaples/rardecode v1.0.0 // indirect
Expand All @@ -102,9 +96,7 @@ require (
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect
)

// Uncomment for tests with alternate branches of 'dmsg'
Expand Down
13 changes: 0 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ github.com/getlantern/ops v0.0.0-20200403153110-8476b16edcd6 h1:QthAQCekS1YOeYWS
github.com/getlantern/ops v0.0.0-20200403153110-8476b16edcd6/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA=
github.com/getlantern/systray v1.1.0 h1:U0wCEqseLi2ok1fE6b88gJklzriavPJixZysZPkZd/Y=
github.com/getlantern/systray v1.1.0/go.mod h1:AecygODWIsBquJCJFop8MEQcJbWFfw/1yWbVabNgpCM=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec=
Expand Down Expand Up @@ -271,12 +270,7 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/james-barrow/golang-ipc v0.0.0-20210227130457-95e7cc81f5e2 h1:lnIIG509NeyPk/15ZHqP3DwTTQXqp2PoQoxGdYDC2h4=
github.com/james-barrow/golang-ipc v0.0.0-20210227130457-95e7cc81f5e2/go.mod h1:M3eGiVVY7bdtqyWT+gtbIqji7CqHi3PKJHSPl2pP40c=
github.com/jaypipes/ghw v0.8.0 h1:02q1pTm9CD83vuhBsEZZhOCS128pq87uyaQeJZkp3sQ=
github.com/jaypipes/ghw v0.8.0/go.mod h1:+gR9bjm3W/HnFi90liF+Fj9GpCe/Dsibl9Im8KmC7c4=
github.com/jaypipes/pcidb v0.6.0 h1:VIM7GKVaW4qba30cvB67xSCgJPTzkG8Kzw/cbs5PHWU=
github.com/jaypipes/pcidb v0.6.0/go.mod h1:L2RGk04sfRhp5wvHO0gfRAMoLY/F3PKv/nwJeVoho0o=
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
Expand Down Expand Up @@ -342,7 +336,6 @@ github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceT
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
Expand Down Expand Up @@ -383,7 +376,6 @@ github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pires/go-proxyproto v0.3.3/go.mod h1:Odh9VFOZJCf9G8cLW5o435Xf1J95Jw9Gw5rnCjcwzAY=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -454,13 +446,11 @@ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw=
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
Expand Down Expand Up @@ -933,7 +923,6 @@ gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
Expand All @@ -947,8 +936,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M=
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
nhooyr.io/websocket v1.8.2 h1:LwdzfyyOZKtVFoXay6A39Acu03KmidSZ3YUUvPa13PA=
nhooyr.io/websocket v1.8.2/go.mod h1:LiqdCg1Cu7TPWxEvPjPa0TGYxCsy4pHNTN9gGluwBpQ=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
2 changes: 0 additions & 2 deletions pkg/skyenv/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const (
DefaultRouteFinderAddr = "http://rf.skywire.skycoin.com"
DefaultUptimeTrackerAddr = "http://ut.skywire.skycoin.com"
DefaultAddressResolverAddr = "http://ar.skywire.skycoin.com"
DefaultHostKeeperAddr = "http://hk.skywire.skycoin.com"
DefaultSetupPK = "0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
)

Expand All @@ -43,7 +42,6 @@ const (
TestRouteFinderAddr = "http://rf.skywire.dev"
TestUptimeTrackerAddr = "http://ut.skywire.dev"
TestAddressResolverAddr = "http://ar.skywire.dev"
TestHostKeeperAddr = "http://hk.skywire.dev"
TestSetupPK = "026c2a3e92d6253c5abd71a42628db6fca9dd9aa037ab6f4e3a31108558dfd87cf"
)

Expand Down
84 changes: 0 additions & 84 deletions pkg/visor/visor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,18 @@
package visor

import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"os/exec"
"sync"
"time"

"github.com/jaypipes/ghw"
"github.com/jaypipes/ghw/pkg/baseboard"
"github.com/jaypipes/ghw/pkg/product"
"github.com/skycoin/dmsg"
"github.com/skycoin/dmsg/cipher"
dmsgdisc "github.com/skycoin/dmsg/disc"
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/internal/httpauth"
"github.com/skycoin/skywire/internal/utclient"
"github.com/skycoin/skywire/pkg/app/appdisc"
"github.com/skycoin/skywire/pkg/app/appevent"
Expand Down Expand Up @@ -240,80 +233,3 @@ func (v *Visor) SetLogstore(store logstore.Store) {
func (v *Visor) tpDiscClient() transport.DiscoveryClient {
return v.tpM.Conf.DiscoveryClient
}

// HostKeeper save host info of running visor.
func (v *Visor) HostKeeper(skybianBuildVersion string) {
var model, serialNumber string
logger := v.MasterLogger().PackageLogger("host-keeper")

if skybianBuildVersion != "" {
modelByte, err := exec.Command("cat", "/proc/device-tree/model").Output()
if err != nil {
logger.Errorf("Error during get model of board due to %v", err)
return
}
model = string(modelByte)

serialNumberByte, err := exec.Command("cat", "/proc/device-tree/serial-number").Output()
if err != nil {
logger.Errorf("Error during get serial number of board due to %v", err)
return
}
serialNumber = string(serialNumberByte)
} else {
baseboardInfo, err := baseboard.New(ghw.WithDisableWarnings())
if err != nil {
logger.Errorf("Error during get information of host due to %v", err)
return
}
model = baseboardInfo.Vendor
serialNumber = baseboardInfo.SerialNumber
if model == "unknown" || serialNumber == "unknown" {
productInfo, err := product.New(ghw.WithDisableWarnings())
if err != nil {
logger.Errorf("Error during get information of host due to %v", err)
return
}
model = productInfo.Vendor
serialNumber = productInfo.UUID
}
}

var keeperInfo HostKeeperData
keeperInfo.Model = model
keeperInfo.SerialNumber = serialNumber

logger.WithField("Info", keeperInfo).Info("Host information achieved.")

client, err := httpauth.NewClient(context.Background(), v.conf.HostKeeper, v.conf.PK, v.conf.SK, &http.Client{}, "", v.MasterLogger())
if err != nil {
logger.Errorf("Host Keeper httpauth: %v", err)
return
}

keeperInfoByte, err := json.Marshal(keeperInfo)
if err != nil {
logger.Errorf("Error during marshal host info due to %v", err)
return
}

req, err := http.NewRequest(http.MethodPost, v.conf.HostKeeper+"/update", bytes.NewReader(keeperInfoByte))
if err != nil {
logger.Errorf("Error during make request of host info due to %v", err)
return
}

_, err = client.Do(req)
if err != nil {
logger.Errorf("Error during send host info to host-keeper service due to %v", err)
return
}

logger.Info("Host info successfully updated.")
}

// HostKeeperData the struct of host keeper data
type HostKeeperData struct {
Model string
SerialNumber string
}
3 changes: 0 additions & 3 deletions pkg/visor/visorconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func MakeBaseConfig(common *Common) *V1 {
conf.StunServers = skyenv.GetStunServers()
conf.ShutdownTimeout = DefaultTimeout
conf.RestartCheckDelay = Duration(restart.DefaultCheckDelay)
conf.HostKeeper = skyenv.DefaultHostKeeperAddr
return conf
}

Expand Down Expand Up @@ -181,7 +180,6 @@ func SetDefaultTestingValues(conf *V1) {
conf.Routing.SetupNodes = []cipher.PubKey{skyenv.MustPK(skyenv.TestSetupPK)}
conf.UptimeTracker.Addr = skyenv.TestUptimeTrackerAddr
conf.Launcher.ServiceDisc = skyenv.TestServiceDiscAddr
conf.HostKeeper = skyenv.TestHostKeeperAddr
}

// SetDefaultProductionValues mutates configuration to use production values
Expand All @@ -195,7 +193,6 @@ func SetDefaultProductionValues(conf *V1) {
Addr: skyenv.DefaultUptimeTrackerAddr,
}
conf.Launcher.ServiceDisc = skyenv.DefaultServiceDiscAddr
conf.HostKeeper = skyenv.DefaultHostKeeperAddr
}

// makeDefaultLauncherAppsConfig creates default launcher config for apps,
Expand Down
1 change: 0 additions & 1 deletion pkg/visor/visorconfig/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,5 @@ func updateUrls(conf *V1) *V1 {
if conf.Launcher.ServiceDisc == skyenv.OldDefaultServiceDiscAddr {
conf.Launcher.ServiceDisc = skyenv.DefaultServiceDiscAddr
}
conf.HostKeeper = skyenv.DefaultHostKeeperAddr
return conf
}
1 change: 0 additions & 1 deletion pkg/visor/visorconfig/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ type V1 struct {
ShutdownTimeout Duration `json:"shutdown_timeout,omitempty"` // time value, examples: 10s, 1m, etc
RestartCheckDelay Duration `json:"restart_check_delay,omitempty"` // time value, examples: 10s, 1m, etc
IsPublic bool `json:"is_public"`
HostKeeper string `json:"host_keeper"`

PersistentTransports []transport.PersistentTransports `json:"persistent_transports"`

Expand Down
20 changes: 0 additions & 20 deletions vendor/github.com/ghodss/yaml/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions vendor/github.com/ghodss/yaml/.travis.yml

This file was deleted.

50 changes: 0 additions & 50 deletions vendor/github.com/ghodss/yaml/LICENSE

This file was deleted.

Loading