Skip to content

Commit

Permalink
Merge branch 'master' into fixIfId
Browse files Browse the repository at this point in the history
  • Loading branch information
jiceatscion authored Jul 17, 2024
2 parents 4c99c37 + cb634d7 commit e3ca243
Show file tree
Hide file tree
Showing 27 changed files with 539 additions and 476 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check the pull request title

on:
pull_request:
types: [opened, edited, reopened, synchronize]

jobs:
check:
runs-on: ubuntu-latest
steps:
- name : Check the PR title
env:
TITLE: ${{ github.event.pull_request.title }}
run: |
# Check that PR is of the form `<subsystem>: <lowercase message>`
url='https://docs.scion.org/en/latest/dev/git.html#good-commit-messages'
if [[ ! "$TITLE" =~ ^[a-z0-9,/]*:[[:space:]] ]]; then
echo '::error::The PR title should start with `<substystem>: `. See '"$url"
exit 1
fi
# Title should be lower case; initialisms and identifiers still occur occasionally and should be allowed.
# -> enforce only the first word
if [[ ! "$TITLE" =~ ^[a-z0-9,/]*:[[:space:]][a-z] ]]; then
echo '::error::The PR title should be lower case (enforced on first letter). See '"$url"
exit 1
fi
if [[ $TITLE =~ \.[[:space:]]*$ ]]; then
echo '::error::The PR title should not end with a ".". See '"$url"
exit 1
fi
10 changes: 0 additions & 10 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ config_setting(
},
)

# This is a dummy target so Make can "blaze build --announce_rc <something>
# Where something truly does nothing that we may care about.

config_setting(
name = "dummy_setting",
define_values = {
"whatever": "whatever",
},
)

gazelle(
name = "gazelle",
build_tags = select({
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ lint-go-bazel:
$(info ==> $@)
@tools/quiet bazel test --config lint //...

GO_BUILD_TAGS_ARG=$(shell bazel build --ui_event_filters=-stdout,-stderr --announce_rc --noshow_progress :dummy_setting 2>&1 | grep "'build' options" | sed -n "s/^.*--define gotags=\(\S*\).*/--build-tags \1/p" )
GO_BUILD_TAGS_ARG=$(shell bazel info --ui_event_filters=-stdout,-stderr --announce_rc --noshow_progress 2>&1 | grep "'build' options" | sed -n "s/^.*--define gotags=\(\S*\).*/--build-tags \1/p" )

lint-go-golangci:
$(info ==> $@)
Expand Down
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ require (
github.com/prometheus/procfs v0.14.0
github.com/quic-go/quic-go v0.43.1
github.com/sergi/go-diff v1.3.1
github.com/smartystreets/goconvey v1.8.1
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
Expand Down Expand Up @@ -75,14 +74,12 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20240509144519-723abb6459b7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/invopop/yaml v0.3.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
Expand All @@ -107,7 +104,6 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/smarty/assertions v1.16.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
Expand Down
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ github.com/google/pprof v0.0.0-20240509144519-723abb6459b7 h1:velgFPYr1X9TDwLIfk
github.com/google/pprof v0.0.0-20240509144519-723abb6459b7/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
Expand All @@ -131,8 +129,6 @@ github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFF
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand Down Expand Up @@ -239,10 +235,6 @@ github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWR
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/smarty/assertions v1.16.0 h1:EvHNkdRA4QHMrn75NZSoUQ/mAUXAYWfatfB01yTCzfY=
github.com/smarty/assertions v1.16.0/go.mod h1:duaaFdCS0K9dnoM50iyek/eYINOZ64gbh1Xlf6LG7AI=
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60=
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 h1:TG/diQgUe0pntT/2D9tmUCz4VNwm9MfrtPr0SU2qSX8=
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8/go.mod h1:P5HUIBuIWKbyjl083/loAegFkfbFNx5i2qEP4CNbm7E=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
Expand Down
54 changes: 0 additions & 54 deletions go_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,6 @@ def go_deps():
sum = "h1:zC34cGQu69FG7qzJ3WiKW244WfhDC3xxYMeNOX2gtUQ=",
version = "v0.0.0-20210719221736-1c9a4c676720",
)
go_repository(
name = "com_github_gopherjs_gopherjs",
importpath = "github.com/gopherjs/gopherjs",
sum = "h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=",
version = "v1.17.2",
)
go_repository(
name = "com_github_gorilla_css",
importpath = "github.com/gorilla/css",
Expand Down Expand Up @@ -721,12 +715,6 @@ def go_deps():
sum = "h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=",
version = "v1.1.12",
)
go_repository(
name = "com_github_jtolds_gls",
importpath = "github.com/jtolds/gls",
sum = "h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=",
version = "v4.20.0+incompatible",
)
go_repository(
name = "com_github_juju_gnuflag",
importpath = "github.com/juju/gnuflag",
Expand Down Expand Up @@ -1027,18 +1015,6 @@ def go_deps():
sum = "h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=",
version = "v0.1.9",
)
go_repository(
name = "com_github_neelance_astrewrite",
importpath = "github.com/neelance/astrewrite",
sum = "h1:D6paGObi5Wud7xg83MaEFyjxQB1W5bz5d0IFppr+ymk=",
version = "v0.0.0-20160511093645-99348263ae86",
)
go_repository(
name = "com_github_neelance_sourcemap",
importpath = "github.com/neelance/sourcemap",
sum = "h1:bY6ktFuJkt+ZXkX0RChQch2FtHpWQLVS8Qo1YasiIVk=",
version = "v0.0.0-20200213170602-2833bce08e4c",
)
go_repository(
name = "com_github_niemeyer_pretty",
importpath = "github.com/niemeyer/pretty",
Expand Down Expand Up @@ -1213,42 +1189,12 @@ def go_deps():
sum = "h1:KkH3I3sJuOLP3TjA/dfr4NAY8bghDwnXiU7cTKxQqo0=",
version = "v0.0.0-20220729165902-8cddb4f5de06",
)
go_repository(
name = "com_github_shurcool_go",
importpath = "github.com/shurcooL/go",
sum = "h1:aSISeOcal5irEhJd1M+IrApc0PdcN7e7Aj4yuEnOrfQ=",
version = "v0.0.0-20200502201357-93f07166e636",
)
go_repository(
name = "com_github_shurcool_httpfs",
importpath = "github.com/shurcooL/httpfs",
sum = "h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk=",
version = "v0.0.0-20190707220628-8d4bc4ba7749",
)
go_repository(
name = "com_github_shurcool_vfsgen",
importpath = "github.com/shurcooL/vfsgen",
sum = "h1:pXY9qYc/MP5zdvqWEUH6SjNiu7VhSjuVFTFiTcphaLU=",
version = "v0.0.0-20200824052919-0d455de96546",
)
go_repository(
name = "com_github_sirupsen_logrus",
importpath = "github.com/sirupsen/logrus",
sum = "h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=",
version = "v1.8.1",
)
go_repository(
name = "com_github_smarty_assertions",
importpath = "github.com/smarty/assertions",
sum = "h1:EvHNkdRA4QHMrn75NZSoUQ/mAUXAYWfatfB01yTCzfY=",
version = "v1.16.0",
)
go_repository(
name = "com_github_smartystreets_goconvey",
importpath = "github.com/smartystreets/goconvey",
sum = "h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=",
version = "v1.8.1",
)
go_repository(
name = "com_github_songgao_water",
importpath = "github.com/songgao/water",
Expand Down
1 change: 1 addition & 0 deletions private/env/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go_library(
"//pkg/scrypto:go_default_library",
"//private/config:go_default_library",
"@com_github_opentracing_opentracing_go//:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promhttp:go_default_library",
"@com_github_uber_jaeger_client_go//:go_default_library",
"@com_github_uber_jaeger_client_go//config:go_default_library",
Expand Down
14 changes: 13 additions & 1 deletion private/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"time"

opentracing "github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
jaeger "github.com/uber/jaeger-client-go"
jaegercfg "github.com/uber/jaeger-client-go/config"
Expand Down Expand Up @@ -61,6 +62,10 @@ const (
// ShutdownGraceInterval is the time applications wait after issuing a
// clean shutdown signal, before forcerfully tearing down the application.
ShutdownGraceInterval = 5 * time.Second

// HandlerTimeout is the time after which the http handler gives up on a request and
// returns an error instead.
HandlerTimeout = time.Minute
)

var sighupC chan os.Signal
Expand Down Expand Up @@ -185,7 +190,14 @@ func (cfg *Metrics) ServePrometheus(ctx context.Context) error {
if cfg.Prometheus == "" {
return nil
}
http.Handle("/metrics", promhttp.Handler())
handler := promhttp.InstrumentMetricHandler(
prometheus.DefaultRegisterer,
promhttp.HandlerFor(
prometheus.DefaultGatherer,
promhttp.HandlerOpts{Timeout: HandlerTimeout},
),
)
http.Handle("/metrics", handler)
log.Info("Exporting prometheus metrics", "addr", cfg.Prometheus)

server := &http.Server{Addr: cfg.Prometheus}
Expand Down
2 changes: 1 addition & 1 deletion private/revcache/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ go_test(
"//pkg/segment:go_default_library",
"//private/revcache/mock_revcache:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_smartystreets_goconvey//convey:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
],
)
1 change: 0 additions & 1 deletion private/revcache/memrevcache/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ go_test(
"//pkg/private/ctrl/path_mgmt:go_default_library",
"//private/revcache:go_default_library",
"//private/revcache/revcachetest:go_default_library",
"@com_github_smartystreets_goconvey//convey:go_default_library",
],
)
6 changes: 1 addition & 5 deletions private/revcache/memrevcache/memrevcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"testing"
"time"

. "github.com/smartystreets/goconvey/convey"

"github.com/scionproto/scion/pkg/private/ctrl/path_mgmt"
"github.com/scionproto/scion/private/revcache"
"github.com/scionproto/scion/private/revcache/revcachetest"
Expand Down Expand Up @@ -54,7 +52,5 @@ func (c *testRevCache) Prepare(t *testing.T, _ context.Context) {
}

func TestRevCacheSuite(t *testing.T) {
Convey("RevCache Suite", t, func() {
revcachetest.TestRevCache(t, &testRevCache{memRevCache: New()})
})
revcachetest.TestRevCache(t, &testRevCache{memRevCache: New()})
}
51 changes: 3 additions & 48 deletions private/revcache/revcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type Key struct {
}

// NewKey creates a new key for the revocation cache.
func NewKey(ia addr.IA, ifId common.IfIdType) *Key {
return &Key{
func NewKey(ia addr.IA, ifId common.IfIdType) Key {
return Key{
IA: ia,
IfId: ifId,
}
Expand All @@ -48,7 +48,7 @@ type KeySet map[Key]struct{}

// SingleKey is a convenience function to return a KeySet with a single key.
func SingleKey(ia addr.IA, ifId common.IfIdType) KeySet {
return KeySet{*NewKey(ia, ifId): {}}
return KeySet{Key{IA: ia, IfId: ifId}: {}}
}

// RevOrErr is either a revocation or an error.
Expand Down Expand Up @@ -86,48 +86,3 @@ type RevCache interface {

// Revocations is the map of revocations.
type Revocations map[Key]*path_mgmt.RevInfo

// RevocationToMap converts a slice of revocations to a revocation map. If extracting the info field
// fails from a revocation, nil and the error is returned.
func RevocationToMap(revs []*path_mgmt.RevInfo) (Revocations, error) {
res := make(Revocations)
for _, rev := range revs {
res[Key{IA: rev.IA(), IfId: rev.IfId}] = rev
}
return res, nil
}

// Keys returns the set of keys in this revocation map.
func (r Revocations) Keys() KeySet {
keys := make(KeySet, len(r))
for key := range r {
keys[key] = struct{}{}
}
return keys
}

// ToSlice extracts the values from this revocation map.
func (r Revocations) ToSlice() []*path_mgmt.RevInfo {
res := make([]*path_mgmt.RevInfo, 0, len(r))
for _, rev := range r {
res = append(res, rev)
}
return res
}

// FilterNew drops all revocations in r that are already in the revCache.
func (r Revocations) FilterNew(ctx context.Context, revCache RevCache) error {
inCache, err := revCache.Get(ctx, r.Keys())
if err != nil {
return err
}
for key, rev := range r {
existingRev, exists := inCache[key]
if exists {
if !newerInfo(existingRev, rev) {
delete(r, key)
}
}
}
return nil
}
1 change: 0 additions & 1 deletion private/revcache/revcachetest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ go_library(
"//pkg/private/ctrl/path_mgmt/proto:go_default_library",
"//pkg/private/util:go_default_library",
"//private/revcache:go_default_library",
"@com_github_smartystreets_goconvey//convey:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
"@com_github_stretchr_testify//require:go_default_library",
],
Expand Down
Loading

0 comments on commit e3ca243

Please sign in to comment.