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

Fix Webhook discovery, refresh pool before getting pool size #2413

Merged
merged 3 commits into from
May 23, 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: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#### Broadcaster
- \#2392 Add LP_EXTEND_TIMEOUTS env variable to extend timeouts for Stream Tester (@leszko)
- \#2413 Fix Webhook discovery, refresh pool before getting pool size (@leszko)

#### Orchestrator

Expand Down
11 changes: 7 additions & 4 deletions cmd/livepeer/livepeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func main() {
}

vFlag.Value.Set(*verbosity)
extendTimeouts()
streamTesterMode()

cfg = updateNilsForUnsetFlags(cfg)

Expand Down Expand Up @@ -202,14 +202,17 @@ func updateNilsForUnsetFlags(cfg starter.LivepeerConfig) starter.LivepeerConfig
return res
}

// extendTimeouts extends transcoding timeouts for the testing purpose.
// streamTesterMode extends transcoding timeouts and disable caching for the testing purpose.
// This functionality is intended for Stream Tester to avoid timing out while measuring orchestrator performance.
func extendTimeouts() {
if boolVal, _ := strconv.ParseBool(os.Getenv("LP_EXTEND_TIMEOUTS")); boolVal {
func streamTesterMode() {
if boolVal, _ := strconv.ParseBool(os.Getenv("LP_IS_ORCH_TESTER")); boolVal {
// Make all timeouts 8s for the common segment durations
common.SegUploadTimeoutMultiplier = 4.0
common.SegmentUploadTimeout = 8 * time.Second
common.HTTPDialTimeout = 8 * time.Second
common.SegHttpPushTimeoutMultiplier = 4.0

// Disable caching for Orchestrator Discovery Webhook
common.WebhookDiscoveryRefreshInterval = 0
}
}
3 changes: 3 additions & 0 deletions common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ var SegUploadTimeoutMultiplier = 0.5
// SegmentUploadTimeout timeout used in HTTP connections for uploading the segment duration is not defined
var SegmentUploadTimeout = 2 * time.Second

// WebhookDiscoveryRefreshInterval defines for long the Webhook Discovery values should be cached
var WebhookDiscoveryRefreshInterval = 1 * time.Minute

// Max Segment Duration
var MaxDuration = (5 * time.Minute)

Expand Down
7 changes: 4 additions & 3 deletions discovery/wh_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"github.com/golang/glog"
)

var whRefreshInterval = 1 * time.Minute

type webhookResponse struct {
Address string `json:"address,omitempty"`
Score float32 `json:"score,omitempty"`
Expand Down Expand Up @@ -50,7 +48,7 @@ func (w *webhookPool) getInfos() ([]common.OrchestratorLocalInfo, error) {
w.mu.RUnlock()

// retrive addrs from cache if time since lastRequest is less than the refresh interval
if time.Since(lastReq) < whRefreshInterval {
if time.Since(lastReq) < common.WebhookDiscoveryRefreshInterval {
return pool.GetInfos(), nil
}

Expand Down Expand Up @@ -100,6 +98,9 @@ func (w *webhookPool) Size() int {
}

func (w *webhookPool) SizeWith(scorePred common.ScorePred) int {
// Refresh pool
w.GetInfos()

var size int
w.mu.RLock()
if w.pool != nil {
Expand Down