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

Update service discovery references #872

Merged
merged 8 commits into from
Sep 8, 2021
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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.5.0

### Changed

- config updated to `v1.1.0`
- removed public_trusted_visor field from root section
- removed trusted_visors field from transport section
- removed authorization_file field from dmsgpty section
- changed default urls to newer shortned ones
- changed proxy_discovery_addr field to service_discovery
- updated UI
- removed `--public` flag from `skywire-cli visor add-tp` command

### Added

- added persistent_transports field to the config and UI
- added stun_servers field to the config
- added is_public field to root section
- added public_autoconnect field to transport section
- added transport_setup_nodes field to transport section
- added MinHops field to V1Routing section of config

## 0.2.1 - 2020.04.07

### Changed
Expand Down
Empty file removed Char
Empty file.
6 changes: 3 additions & 3 deletions cmd/skywire-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ $ skywire-cli visor gen-config
"launcher": {
"discovery": {
"update_interval": "30s",
"proxy_discovery_addr": "http://service.discovery.skycoin.com"
"service_discovery": "http://service.discovery.skycoin.com"
},
"apps": [
{
Expand Down Expand Up @@ -512,7 +512,7 @@ $ skywire-cli visor gen-config -ip
"launcher": {
"discovery": {
"update_interval": "30s",
"proxy_discovery_addr": "http://service.discovery.skycoin.com"
"service_discovery": "http://service.discovery.skycoin.com"
},
"apps": [
{
Expand Down Expand Up @@ -886,7 +886,7 @@ skywire-cli visor update-config
"launcher": {
"discovery": {
"update_interval": "30s",
"proxy_discovery_addr": "http://service.discovery.skycoin.com"
"service_discovery": "http://service.discovery.skycoin.com"
},
"apps": [
{
Expand Down
14 changes: 7 additions & 7 deletions pkg/app/appserver/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/pkg/app/appcommon"
"github.com/skycoin/skywire/pkg/app/appdisc"
"github.com/skycoin/skywire/pkg/app/appnet"
"github.com/skycoin/skywire/pkg/app/updatedisc"
)

var (
Expand All @@ -29,7 +29,7 @@ var (
// communication.
// TODO(evanlinjin): In the future, we will implement the ability to run multiple instances (procs) of a single app.
type Proc struct {
disc appdisc.Updater // app discovery client
disc updatedisc.Updater // app discovery client
conf appcommon.ProcConfig
log *logging.Logger

Expand Down Expand Up @@ -57,7 +57,7 @@ type Proc struct {
}

// NewProc constructs `Proc`.
func NewProc(mLog *logging.MasterLogger, conf appcommon.ProcConfig, disc appdisc.Updater, m ProcManager,
func NewProc(mLog *logging.MasterLogger, conf appcommon.ProcConfig, disc updatedisc.Updater, m ProcManager,
appName string) *Proc {
if mLog == nil {
mLog = logging.NewMasterLogger()
Expand Down Expand Up @@ -136,8 +136,8 @@ func (p *Proc) awaitConn() bool {
connDelta := p.rpcGW.cm.AddDeltaInformer()
go func() {
for n := range connDelta.Chan() {
if err := p.disc.ChangeValue(appdisc.ConnCountValue, []byte(strconv.Itoa(n))); err != nil {
p.log.WithError(err).WithField("value", appdisc.ConnCountValue).
if err := p.disc.ChangeValue(updatedisc.ConnCountValue, []byte(strconv.Itoa(n))); err != nil {
p.log.WithError(err).WithField("value", updatedisc.ConnCountValue).
Error("Failed to change app discovery value.")
}
}
Expand All @@ -146,8 +146,8 @@ func (p *Proc) awaitConn() bool {
lisDelta := p.rpcGW.lm.AddDeltaInformer()
go func() {
for n := range lisDelta.Chan() {
if err := p.disc.ChangeValue(appdisc.ListenerCountValue, []byte(strconv.Itoa(n))); err != nil {
p.log.WithError(err).WithField("value", appdisc.ListenerCountValue).
if err := p.disc.ChangeValue(updatedisc.ListenerCountValue, []byte(strconv.Itoa(n))); err != nil {
p.log.WithError(err).WithField("value", updatedisc.ListenerCountValue).
Error("Failed to change app discovery value.")
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/app/appserver/proc_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/pkg/app/appcommon"
"github.com/skycoin/skywire/pkg/app/appdisc"
"github.com/skycoin/skywire/pkg/app/appevent"
"github.com/skycoin/skywire/pkg/app/updatedisc"
)

//go:generate mockery -name ProcManager -case underscore -inpkg
Expand Down Expand Up @@ -57,7 +57,7 @@ type procManager struct {
conns map[string]net.Conn
connsWG sync.WaitGroup

discF *appdisc.Factory
discF *updatedisc.Factory
procs map[string]*Proc
procsByKey map[appcommon.ProcKey]*Proc

Expand All @@ -69,12 +69,12 @@ type procManager struct {
}

// NewProcManager constructs `ProcManager`.
func NewProcManager(mLog *logging.MasterLogger, discF *appdisc.Factory, eb *appevent.Broadcaster, addr string) (ProcManager, error) {
func NewProcManager(mLog *logging.MasterLogger, discF *updatedisc.Factory, eb *appevent.Broadcaster, addr string) (ProcManager, error) {
if mLog == nil {
mLog = logging.NewMasterLogger()
}
if discF == nil {
discF = new(appdisc.Factory)
discF = new(updatedisc.Factory)
}
if eb == nil {
eb = appevent.NewBroadcaster(mLog.PackageLogger("event_broadcaster"), time.Second)
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/appdisc/const.go → pkg/app/updatedisc/const.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package appdisc
package updatedisc

// ChangeValue keys. Each key changes a different value for proxyUpdater.ChangeValue
// ChangeValue keys. Each key changes a different value for serviceUpdater.ChangeValue
const (
// ConnCountValue represents the number of remote connections to a given proc.
ConnCountValue = "conn_count"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package appdisc
package updatedisc

import (
"context"
Expand Down
16 changes: 8 additions & 8 deletions pkg/app/appdisc/factory.go → pkg/app/updatedisc/factory.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package appdisc
package updatedisc

import (
"time"
Expand All @@ -18,18 +18,18 @@ type Factory struct {
PK cipher.PubKey
SK cipher.SecKey
UpdateInterval time.Duration
ProxyDisc string // Address of proxy-discovery
ServiceDisc string // Address of service-discovery
}

func (f *Factory) setDefaults() {
if f.Log == nil {
f.Log = logging.MustGetLogger("appdisc")
}
if f.UpdateInterval == 0 {
f.UpdateInterval = skyenv.AppDiscUpdateInterval
f.UpdateInterval = skyenv.ServiceDiscUpdateInterval
}
if f.ProxyDisc == "" {
f.ProxyDisc = skyenv.DefaultServiceDiscAddr
if f.ServiceDisc == "" {
f.ServiceDisc = skyenv.DefaultServiceDiscAddr
}
}

Expand All @@ -45,7 +45,7 @@ func (f *Factory) VisorUpdater(port uint16) Updater {
PK: f.PK,
SK: f.SK,
Port: port,
DiscAddr: f.ProxyDisc,
DiscAddr: f.ServiceDisc,
}

return &serviceUpdater{
Expand All @@ -63,7 +63,7 @@ func (f *Factory) AppUpdater(conf appcommon.ProcConfig) (Updater, bool) {

log := f.Log.WithField("appName", conf.AppName)

// Do not update in proxy discovery if passcode-protected.
// Do not update in service discovery if passcode-protected.
if conf.ContainsFlag("passcode") && conf.ArgVal("passcode") != "" {
return &emptyUpdater{}, false
}
Expand All @@ -74,7 +74,7 @@ func (f *Factory) AppUpdater(conf appcommon.ProcConfig) (Updater, bool) {
PK: f.PK,
SK: f.SK,
Port: uint16(conf.RoutingPort),
DiscAddr: f.ProxyDisc,
DiscAddr: f.ServiceDisc,
}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/skyenv/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ const (

// Default skywire app server and discovery constants
const (
DefaultAppSrvAddr = "localhost:5505"
AppDiscUpdateInterval = time.Minute
DefaultAppBinPath = DefaultSkywirePath + "/apps"
DefaultLogLevel = "info"
DefaultAppSrvAddr = "localhost:5505"
ServiceDiscUpdateInterval = time.Minute
DefaultAppBinPath = DefaultSkywirePath + "/apps"
DefaultLogLevel = "info"
)

// Package defaults
Expand Down
16 changes: 8 additions & 8 deletions pkg/visor/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (

"github.com/skycoin/skywire/internal/utclient"
"github.com/skycoin/skywire/internal/vpn"
"github.com/skycoin/skywire/pkg/app/appdisc"
"github.com/skycoin/skywire/pkg/app/appevent"
"github.com/skycoin/skywire/pkg/app/appserver"
"github.com/skycoin/skywire/pkg/app/launcher"
"github.com/skycoin/skywire/pkg/app/updatedisc"
"github.com/skycoin/skywire/pkg/dmsgc"
"github.com/skycoin/skywire/pkg/routefinder/rfclient"
"github.com/skycoin/skywire/pkg/router"
Expand Down Expand Up @@ -180,7 +180,7 @@ func initAddressResolver(ctx context.Context, v *Visor, log *logging.Logger) err

func initDiscovery(ctx context.Context, v *Visor, log *logging.Logger) error {
// Prepare app discovery factory.
factory := appdisc.Factory{
factory := updatedisc.Factory{
Log: v.MasterLogger().PackageLogger("app_discovery"),
}

Expand All @@ -190,7 +190,7 @@ func initDiscovery(ctx context.Context, v *Visor, log *logging.Logger) error {
factory.PK = v.conf.PK
factory.SK = v.conf.SK
factory.UpdateInterval = time.Duration(conf.Discovery.UpdateInterval)
factory.ProxyDisc = conf.Discovery.ServiceDisc
factory.ServiceDisc = conf.Discovery.ServiceDisc
}
v.initLock.Lock()
v.serviceDisc = factory
Expand Down Expand Up @@ -652,12 +652,12 @@ func initPublicVisors(ctx context.Context, v *Visor, log *logging.Logger) error
if !v.conf.Transport.AutoconnectPublic {
return nil
}
proxyDisc := v.conf.Launcher.Discovery.ServiceDisc
if proxyDisc == "" {
proxyDisc = skyenv.DefaultServiceDiscAddr
serviceDisc := v.conf.Launcher.Discovery.ServiceDisc
if serviceDisc == "" {
serviceDisc = skyenv.DefaultServiceDiscAddr
}

// todo: refactor appdisc: split connecting to services in appdisc and
// todo: refactor updatedisc: split connecting to services in updatedisc and
// advertising oneself as a service. Currently, config is tailored to
// advertising oneself and requires things like port that are not used
// in connecting to services
Expand All @@ -666,7 +666,7 @@ func initPublicVisors(ctx context.Context, v *Visor, log *logging.Logger) error
PK: v.conf.PK,
SK: v.conf.SK,
Port: uint16(0),
DiscAddr: proxyDisc,
DiscAddr: serviceDisc,
}
connector := servicedisc.MakeConnector(conf, 5, v.tpM, log)
go connector.Run(ctx) //nolint:errcheck
Expand Down
4 changes: 2 additions & 2 deletions pkg/visor/visor.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/internal/utclient"
"github.com/skycoin/skywire/pkg/app/appdisc"
"github.com/skycoin/skywire/pkg/app/appevent"
"github.com/skycoin/skywire/pkg/app/appserver"
"github.com/skycoin/skywire/pkg/app/launcher"
"github.com/skycoin/skywire/pkg/app/updatedisc"
"github.com/skycoin/skywire/pkg/restart"
"github.com/skycoin/skywire/pkg/routefinder/rfclient"
"github.com/skycoin/skywire/pkg/router"
Expand Down Expand Up @@ -66,7 +66,7 @@ type Visor struct {

procM appserver.ProcManager // proc manager
appL *launcher.Launcher // app launcher
serviceDisc appdisc.Factory
serviceDisc updatedisc.Factory
initLock *sync.Mutex
// when module is failed it pushes its error to this channel
// used by init and shutdown to show/check for any residual errors
Expand Down
2 changes: 1 addition & 1 deletion pkg/visor/visorconfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# V1AppDisc

- `update_interval` (Duration)
- `proxy_discovery_addr` (string)
- `service_discovery` (string)


# V1LogStore
Expand Down
10 changes: 5 additions & 5 deletions pkg/visor/visorconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func MakeBaseConfig(common *Common) *V1 {
RouteFinderTimeout: DefaultTimeout,
}
conf.Launcher = &V1Launcher{
Discovery: &V1AppDisc{
Discovery: &V1ServiceDisc{
ServiceDisc: skyenv.DefaultServiceDiscAddr,
},
Apps: nil,
Expand Down Expand Up @@ -89,8 +89,8 @@ func defaultConfigFromCommon(cc *Common, hypervisor bool) (*V1, error) {
Addr: skyenv.DefaultUptimeTrackerAddr,
}

conf.Launcher.Discovery = &V1AppDisc{
UpdateInterval: Duration(skyenv.AppDiscUpdateInterval),
conf.Launcher.Discovery = &V1ServiceDisc{
UpdateInterval: Duration(skyenv.ServiceDiscUpdateInterval),
ServiceDisc: skyenv.DefaultServiceDiscAddr,
}

Expand Down Expand Up @@ -218,8 +218,8 @@ func SetDefaultProductionValues(conf *V1) {
conf.UptimeTracker = &V1UptimeTracker{
Addr: skyenv.DefaultUptimeTrackerAddr,
}
conf.Launcher.Discovery = &V1AppDisc{
UpdateInterval: Duration(skyenv.AppDiscUpdateInterval),
conf.Launcher.Discovery = &V1ServiceDisc{
UpdateInterval: Duration(skyenv.ServiceDiscUpdateInterval),
ServiceDisc: skyenv.DefaultServiceDiscAddr,
}
}
2 changes: 1 addition & 1 deletion pkg/visor/visorconfig/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func parseV0(cc *Common, raw []byte) (*V1, error) {

func ensureAppDisc(conf *V1) *V1 {
if conf.Launcher.Discovery == nil {
conf.Launcher.Discovery = &V1AppDisc{
conf.Launcher.Discovery = &V1ServiceDisc{
ServiceDisc: skyenv.DefaultServiceDiscAddr,
}
}
Expand Down
11 changes: 7 additions & 4 deletions pkg/visor/visorconfig/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const V101Name = "v1.0.1"
// Removed authorization_file field from dmsgpty section
// Default urls are changed to newer shortned ones
// Added stun_servers field to the config
// Added persistent_transports field to the config
// Changed proxy_discovery_addr field to service_discovery
// Changed V1AppDisc struct to V1ServiceDisc
const V110Name = "v1.1.0"

// V1Name is the semantic version string for the most recent version of V1.
Expand Down Expand Up @@ -100,15 +103,15 @@ type V1UptimeTracker struct {
Addr string `json:"addr"`
}

// V1AppDisc configures Skywire App Discovery Clients.
type V1AppDisc struct {
// V1ServiceDisc configures Skywire App Discovery Clients.
type V1ServiceDisc struct {
UpdateInterval Duration `json:"update_interval,omitempty"`
ServiceDisc string `json:"proxy_discovery_addr"` // TODO: change JSON name
ServiceDisc string `json:"service_discovery"`
}

// V1Launcher configures the app launcher.
type V1Launcher struct {
Discovery *V1AppDisc `json:"discovery"`
Discovery *V1ServiceDisc `json:"discovery"`
Apps []launcher.AppConfig `json:"apps"`
ServerAddr string `json:"server_addr"`
BinPath string `json:"bin_path"`
Expand Down