Skip to content

Commit

Permalink
chore: fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockopp committed Jun 27, 2023
1 parent 15d8699 commit e0840d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions cmd/vela-server/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

const baseErr = "unable to schedule build"

func processSchedules(base time.Duration, compiler compiler.Engine, database database.Interface, metadata *types.Metadata, queue queue.Service, scm scm.Service) error {
func processSchedules(interval time.Duration, compiler compiler.Engine, database database.Interface, metadata *types.Metadata, queue queue.Service, scm scm.Service) error {
logrus.Infof("processing active schedules to create builds")

// send API call to capture the list of active schedules
Expand Down Expand Up @@ -78,9 +78,9 @@ func processSchedules(base time.Duration, compiler compiler.Engine, database dat

// determine if schedule is due for processing
//
// The current time must be past the next occurrence and the current time (minus sweep gap) must be
// after the previous occurrence to ensure the schedule will run at the correct time.
due := time.Now().After(nextTime) && prevTime.After(time.Now().Add(-base))
// The current time must be past the next occurrence and the current time (minus schedule interval)
// must be after the previous occurrence to ensure the schedule will run at the correct time.
due := time.Now().After(nextTime) && prevTime.After(time.Now().Add(-interval))

// check if the schedule is due to trigger a build
if !due {
Expand Down
6 changes: 3 additions & 3 deletions cmd/vela-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,19 @@ func server(c *cli.Context) error {
// We need to sleep for some amount of time before we attempt to process schedules
// setup in the database. Since the schedule interval is configurable, we use that
// as the base duration to determine how long to sleep for.
base := c.Duration("schedule-interval")
interval := c.Duration("schedule-interval")

// This should prevent multiple servers from processing schedules at the same time by
// leveraging a base duration along with a standard deviation of randomness a.k.a.
// "jitter". To create the jitter, we use the configured schedule interval duration
// along with a scale factor of 0.5.
jitter := wait.Jitter(base, 0.5)
jitter := wait.Jitter(interval, 0.5)

logrus.Infof("sleeping for %v before scheduling builds", jitter)
// sleep for a duration of time before processing schedules
time.Sleep(jitter)

err = processSchedules(base, compiler, database, metadata, queue, scm)
err = processSchedules(interval, compiler, database, metadata, queue, scm)
if err != nil {
logrus.WithError(err).Warn("unable to process schedules")
} else {
Expand Down

0 comments on commit e0840d5

Please sign in to comment.