Skip to content

Commit

Permalink
Monolithic Control Service POC (#3590)
Browse files Browse the repository at this point in the history
This commit introduces a monolithic control service server which
aggregates BS, CS, and PS services functionality.

The monolith removes the need for several intra-AS RPC calls (e.g., a BS
no longer needs to push crypto and segments to the CS and PS) and
removes the need for multiple database instances.

The current implementation is just a POC, and is inefficient. Some calls
from the monolithic process go via the SCION RPC mechanism to itself,
and the Certificate Service modules within the monolith still use the
local SCIOND for paths even though that SCIOND goes back to the Path
Service modules in the same monolith. These should be fixed in future
work.

The Go Dispatcher is patched to support applications binding to a
wildcard SVC. Traffic for BS, CS, and PS is delivered to the wildcard
SVC. This is not a valid wire SVC address, and is only locally relevant
on a host supporting the monolithic control service.

Also includes generator support for the monolithic control service and a
CI end2end test.
  • Loading branch information
scrye authored Jan 10, 2020
1 parent 715c1f1 commit 76bb67e
Show file tree
Hide file tree
Showing 174 changed files with 2,043 additions and 583 deletions.
22 changes: 19 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ steps:
- tar -kxf bazel-bin/scion.tar -C bin --overwrite
- tar -kxf bazel-bin/scion-ci.tar -C bin --overwrite
- ./scion.sh topology
- ./scion.sh run nobuild && sleep 10
- ./scion.sh run && sleep 10
- ./bin/end2end_integration -log.console warn
- ./integration/revocation_test.sh
key: revocation_tests
Expand All @@ -80,16 +80,32 @@ steps:
- tar -kxf bazel-bin/scion.tar -C bin --overwrite
- tar -kxf bazel-bin/scion-ci.tar -C bin --overwrite
- ./scion.sh topology
- ./scion.sh run nobuild && sleep 10
- ./scion.sh run && sleep 10
- ./bin/cert_req_integration -log.console warn
- ./bin/pp_integration -log.console warn
- ./bin/scmp_integration -log.console warn
- ./bin/end2end_integration -log.console warn
artifact_paths:
- "artifacts.out/**/*"
timeout_in_minutes: 5
timeout_in_minutes: 10
key: integration_tests
retry:
automatic:
- exit_status: -1 # Agent was lost
- exit_status: 255 # Forced agent shutdown
- label: "Integration: end2end_integration"
command:
- bazel --bazelrc=.bazelrc_ci build //:scion //:scion-ci >/dev/null 2>&1
- tar -kxf bazel-bin/scion.tar -C bin --overwrite
- tar -kxf bazel-bin/scion-ci.tar -C bin --overwrite
- ./scion.sh topology --monolith
- ./scion.sh run && sleep 10
- ./bin/end2end_integration -log.console warn
artifact_paths:
- "artifacts.out/**/*"
timeout_in_minutes: 10
key: integration_tests_monolith
retry:
automatic:
- exit_status: -1 # Agent was lost
- exit_status: 255 # Forced agent shutdown
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pkg_tar(
srcs = [
"//go/beacon_srv:beacon_srv",
"//go/border:border",
"//go/cs:cs",
"//go/cert_srv:cert_srv",
"//go/godispatcher:godispatcher",
"//go/tools/logdog:logdog",
Expand Down
15 changes: 8 additions & 7 deletions go/beacon_srv/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ go_library(
importpath = "github.com/scionproto/scion/go/beacon_srv",
visibility = ["//visibility:private"],
deps = [
"//go/beacon_srv/internal/beacon:go_default_library",
"//go/beacon_srv/internal/beaconing:go_default_library",
"//go/beacon_srv/internal/beaconstorage:go_default_library",
"//go/beacon_srv/internal/config:go_default_library",
"//go/beacon_srv/internal/ifstate:go_default_library",
"//go/beacon_srv/internal/keepalive:go_default_library",
"//go/beacon_srv/internal/onehop:go_default_library",
"//go/beacon_srv/internal/revocation:go_default_library",
"//go/cs/beacon:go_default_library",
"//go/cs/beaconing:go_default_library",
"//go/cs/beaconstorage:go_default_library",
"//go/cs/config:go_default_library",
"//go/cs/ifstate:go_default_library",
"//go/cs/keepalive:go_default_library",
"//go/cs/onehop:go_default_library",
"//go/cs/revocation:go_default_library",
"//go/lib/addr:go_default_library",
"//go/lib/common:go_default_library",
"//go/lib/discovery:go_default_library",
Expand Down
11 changes: 5 additions & 6 deletions go/beacon_srv/internal/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"config.go",
"sample.go",
],
srcs = ["config.go"],
importpath = "github.com/scionproto/scion/go/beacon_srv/internal/config",
visibility = ["//go/beacon_srv:__subpackages__"],
deps = [
"//go/beacon_srv/internal/beaconstorage:go_default_library",
"//go/cs/beaconstorage:go_default_library",
"//go/cs/config:go_default_library",
"//go/lib/common:go_default_library",
"//go/lib/config:go_default_library",
"//go/lib/ctrl/path_mgmt:go_default_library",
Expand All @@ -26,7 +24,8 @@ go_test(
srcs = ["config_test.go"],
embed = [":go_default_library"],
deps = [
"//go/beacon_srv/internal/beaconstorage/beaconstoragetest:go_default_library",
"//go/cs/beaconstorage/beaconstoragetest:go_default_library",
"//go/cs/config:go_default_library",
"//go/lib/ctrl/path_mgmt:go_default_library",
"//go/lib/env/envtest:go_default_library",
"//go/lib/infra/modules/idiscovery/idiscoverytest:go_default_library",
Expand Down
13 changes: 9 additions & 4 deletions go/beacon_srv/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
"io"
"time"

"github.com/scionproto/scion/go/beacon_srv/internal/beaconstorage"
"github.com/scionproto/scion/go/cs/beaconstorage"
controlconfig "github.com/scionproto/scion/go/cs/config"
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/config"
"github.com/scionproto/scion/go/lib/ctrl/path_mgmt"
Expand All @@ -30,6 +31,10 @@ import (
"github.com/scionproto/scion/go/lib/util"
)

const (
idSample = "bs-1"
)

const (
// DefaultKeepaliveInterval is the default interval between sending
// interface keepalives.
Expand Down Expand Up @@ -67,7 +72,7 @@ type Config struct {
TrustDB truststorage.TrustDBConf
BeaconDB beaconstorage.BeaconDBConf
Discovery idiscovery.Config
BS BSConfig
BS controlconfig.BSConfig
EnableQUICTest bool
}

Expand Down Expand Up @@ -198,7 +203,7 @@ func (cfg *BSConfig) Validate() error {

// Sample generates a sample for the beacon server specific configuration.
func (cfg *BSConfig) Sample(dst io.Writer, path config.Path, ctx config.CtxMap) {
config.WriteString(dst, bsconfigSample)
config.WriteString(dst, controlconfig.BSSample)
config.WriteSample(dst, path, ctx, &cfg.Policies)
}

Expand Down Expand Up @@ -242,7 +247,7 @@ type Policies struct {

// Sample generates a sample for the beacon server specific configuration.
func (cfg *Policies) Sample(dst io.Writer, _ config.Path, _ config.CtxMap) {
config.WriteString(dst, policiesSample)
config.WriteString(dst, controlconfig.PoliciesSample)
}

// ConfigName is the toml key for the beacon server specific configuration.
Expand Down
11 changes: 6 additions & 5 deletions go/beacon_srv/internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (
"github.com/BurntSushi/toml"
"github.com/stretchr/testify/assert"

"github.com/scionproto/scion/go/beacon_srv/internal/beaconstorage/beaconstoragetest"
"github.com/scionproto/scion/go/cs/beaconstorage/beaconstoragetest"
controlconfig "github.com/scionproto/scion/go/cs/config"
"github.com/scionproto/scion/go/lib/ctrl/path_mgmt"
"github.com/scionproto/scion/go/lib/env/envtest"
"github.com/scionproto/scion/go/lib/infra/modules/idiscovery/idiscoverytest"
Expand Down Expand Up @@ -64,11 +65,11 @@ func InitTestConfig(cfg *Config) {
InitTestBSConfig(&cfg.BS)
}

func InitTestBSConfig(cfg *BSConfig) {
func InitTestBSConfig(cfg *controlconfig.BSConfig) {
InitTestPolicies(&cfg.Policies)
}

func InitTestPolicies(cfg *Policies) {
func InitTestPolicies(cfg *controlconfig.Policies) {
cfg.Propagation = "test"
cfg.CoreRegistration = "test"
cfg.UpRegistration = "test"
Expand All @@ -83,7 +84,7 @@ func CheckTestConfig(t *testing.T, cfg *Config, id string) {
CheckTestBSConfig(t, &cfg.BS)
}

func CheckTestBSConfig(t *testing.T, cfg *BSConfig) {
func CheckTestBSConfig(t *testing.T, cfg *controlconfig.BSConfig) {
assert.Equal(t, DefaultKeepaliveTimeout, cfg.KeepaliveTimeout.Duration)
assert.Equal(t, DefaultKeepaliveInterval, cfg.KeepaliveInterval.Duration)
assert.Equal(t, DefaultOriginationInterval, cfg.OriginationInterval.Duration)
Expand All @@ -95,7 +96,7 @@ func CheckTestBSConfig(t *testing.T, cfg *BSConfig) {
CheckTestPolicies(t, &cfg.Policies)
}

func CheckTestPolicies(t *testing.T, cfg *Policies) {
func CheckTestPolicies(t *testing.T, cfg *controlconfig.Policies) {
assert.Empty(t, cfg.Propagation)
assert.Empty(t, cfg.CoreRegistration)
assert.Empty(t, cfg.UpRegistration)
Expand Down
30 changes: 0 additions & 30 deletions go/beacon_srv/internal/metrics/BUILD.bazel

This file was deleted.

19 changes: 10 additions & 9 deletions go/beacon_srv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ import (
"github.com/prometheus/client_golang/prometheus"
"gopkg.in/yaml.v2"

"github.com/scionproto/scion/go/beacon_srv/internal/beacon"
"github.com/scionproto/scion/go/beacon_srv/internal/beaconing"
"github.com/scionproto/scion/go/beacon_srv/internal/beaconstorage"
"github.com/scionproto/scion/go/beacon_srv/internal/config"
"github.com/scionproto/scion/go/beacon_srv/internal/ifstate"
"github.com/scionproto/scion/go/beacon_srv/internal/keepalive"
"github.com/scionproto/scion/go/beacon_srv/internal/onehop"
"github.com/scionproto/scion/go/beacon_srv/internal/revocation"
"github.com/scionproto/scion/go/cs/beacon"
"github.com/scionproto/scion/go/cs/beaconing"
"github.com/scionproto/scion/go/cs/beaconstorage"
controlconfig "github.com/scionproto/scion/go/cs/config"
"github.com/scionproto/scion/go/cs/ifstate"
"github.com/scionproto/scion/go/cs/keepalive"
"github.com/scionproto/scion/go/cs/onehop"
"github.com/scionproto/scion/go/cs/revocation"
"github.com/scionproto/scion/go/lib/addr"
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/discovery"
Expand Down Expand Up @@ -598,7 +599,7 @@ func loadStore(core bool, ia addr.IA, cfg config.Config) (beaconstorage.Store, e
return cfg.BeaconDB.NewStore(ia, policies)
}

func loadCorePolicies(cfg config.Policies) (beacon.CorePolicies, error) {
func loadCorePolicies(cfg controlconfig.Policies) (beacon.CorePolicies, error) {
var err error
var policies beacon.CorePolicies
if policies.Prop, err = loadPolicy(cfg.Propagation, beacon.PropPolicy); err != nil {
Expand All @@ -610,7 +611,7 @@ func loadCorePolicies(cfg config.Policies) (beacon.CorePolicies, error) {
return policies, nil
}

func loadPolicies(cfg config.Policies) (beacon.Policies, error) {
func loadPolicies(cfg controlconfig.Policies) (beacon.Policies, error) {
var err error
var policies beacon.Policies
if policies.Prop, err = loadPolicy(cfg.Propagation, beacon.PropPolicy); err != nil {
Expand Down
9 changes: 3 additions & 6 deletions go/cert_srv/internal/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"config.go",
"sample.go",
],
srcs = ["config.go"],
importpath = "github.com/scionproto/scion/go/cert_srv/internal/config",
visibility = ["//go/cert_srv:__subpackages__"],
deps = [
"//go/cs/config:go_default_library",
"//go/lib/common:go_default_library",
"//go/lib/config:go_default_library",
"//go/lib/env:go_default_library",
"//go/lib/infra/modules/idiscovery:go_default_library",
"//go/lib/serrors:go_default_library",
"//go/lib/truststorage:go_default_library",
"//go/lib/util:go_default_library",
],
)

Expand All @@ -25,6 +21,7 @@ go_test(
data = glob(["testdata/**"]),
embed = [":go_default_library"],
deps = [
"//go/cs/config:go_default_library",
"//go/lib/env/envtest:go_default_library",
"//go/lib/infra/modules/idiscovery/idiscoverytest:go_default_library",
"//go/lib/truststorage/truststoragetest:go_default_library",
Expand Down
67 changes: 6 additions & 61 deletions go/cert_srv/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ import (
"io"
"time"

controlconfig "github.com/scionproto/scion/go/cs/config"
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/config"
"github.com/scionproto/scion/go/lib/env"
"github.com/scionproto/scion/go/lib/infra/modules/idiscovery"
"github.com/scionproto/scion/go/lib/serrors"
"github.com/scionproto/scion/go/lib/truststorage"
"github.com/scionproto/scion/go/lib/util"
)

const (
idSample = "cs-1"
)

const (
Expand Down Expand Up @@ -58,7 +61,7 @@ type Config struct {
Sciond env.SciondClient `toml:"sd_client"`
TrustDB truststorage.TrustDBConf
Discovery idiscovery.Config
CS CSConfig
CS controlconfig.CSConfig
}

func (cfg *Config) InitDefaults() {
Expand Down Expand Up @@ -106,61 +109,3 @@ func (cfg *Config) Sample(dst io.Writer, path config.Path, _ config.CtxMap) {
func (cfg *Config) ConfigName() string {
return "cs_config"
}

var _ config.Config = (*CSConfig)(nil)

type CSConfig struct {
// LeafReissueLeadTime indicates how long in advance of leaf cert expiration
// the reissuance process starts.
LeafReissueLeadTime util.DurWrap
// IssuerReissueLeadTime indicates how long in advance core cert expiration
// the self reissuance process starts.
IssuerReissueLeadTime util.DurWrap
// ReissueRate is the interval between two consecutive reissue requests.
ReissueRate util.DurWrap
// ReissueTimeout is the timeout for resissue request.
ReissueTimeout util.DurWrap
// AutomaticRenewal whether automatic reissuing is enabled.
AutomaticRenewal bool
// DisableCorePush disables the core pusher task.
DisableCorePush bool
}

func (cfg *CSConfig) InitDefaults() {
if cfg.LeafReissueLeadTime.Duration == 0 {
cfg.LeafReissueLeadTime.Duration = LeafReissTime
}
if cfg.IssuerReissueLeadTime.Duration == 0 {
cfg.IssuerReissueLeadTime.Duration = IssuerReissTime
}
if cfg.ReissueRate.Duration == 0 {
cfg.ReissueRate.Duration = ReissReqRate
}
if cfg.ReissueTimeout.Duration == 0 {
cfg.ReissueTimeout.Duration = ReissueReqTimeout
}
}

func (cfg *CSConfig) Validate() error {
if cfg.LeafReissueLeadTime.Duration == 0 {
return serrors.New("LeafReissueLeadTime must not be zero")
}
if cfg.IssuerReissueLeadTime.Duration == 0 {
return serrors.New("IssuerReissueLeadTime must not be zero")
}
if cfg.ReissueRate.Duration == 0 {
return serrors.New("ReissueRate must not be zero")
}
if cfg.ReissueTimeout.Duration == 0 {
return serrors.New("ReissueTimeout must not be zero")
}
return nil
}

func (cfg *CSConfig) Sample(dst io.Writer, path config.Path, _ config.CtxMap) {
config.WriteString(dst, csconfigSample)
}

func (cfg *CSConfig) ConfigName() string {
return "cs"
}
Loading

0 comments on commit 76bb67e

Please sign in to comment.