Skip to content

Commit

Permalink
Add resource type check interval
Browse files Browse the repository at this point in the history
  • Loading branch information
Caprowni committed May 27, 2022
1 parent 2a6b9fd commit 0fd2b9b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions atc/atccmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ type RunCommand struct {

GlobalResourceCheckTimeout time.Duration `long:"global-resource-check-timeout" default:"1h" description:"Time limit on checking for new versions of resources."`
ResourceCheckingInterval time.Duration `long:"resource-checking-interval" default:"1m" description:"Interval on which to check for new versions of resources."`
ResourceTypeCheckingInterval time.Duration `long:"resource-type-checking-interval" default:"1m" description:"Interval on which to check for new versions of resource types."`
ResourceWithWebhookCheckingInterval time.Duration `long:"resource-with-webhook-checking-interval" default:"1m" description:"Interval on which to check for new versions of resources that has webhook defined."`
MaxChecksPerSecond int `long:"max-checks-per-second" description:"Maximum number of checks that can be started per second. If not specified, this will be calculated as (# of resources)/(resource checking interval). -1 value will remove this maximum limit of checks per second."`
PausePipelinesAfter int `long:"pause-pipelines-after" default:"0" description:"The number of days after which a pipeline will be automatically paused if none of its jobs have run in more than the given number of days. A value of zero disables this component."`
Expand Down Expand Up @@ -531,6 +532,7 @@ func (cmd *RunCommand) Runner(positionalArguments []string) (ifrit.Runner, error
atc.EnableResourceCausality = cmd.FeatureFlags.EnableResourceCausality
atc.DefaultCheckInterval = cmd.ResourceCheckingInterval
atc.DefaultWebhookInterval = cmd.ResourceWithWebhookCheckingInterval
atc.DefaultResourceTypeInterval = cmd.ResourceTypeCheckingInterval

if cmd.BaseResourceTypeDefaults.Path() != "" {
content, err := ioutil.ReadFile(cmd.BaseResourceTypeDefaults.Path())
Expand Down Expand Up @@ -1071,6 +1073,15 @@ func (cmd *RunCommand) backendComponents(
cmd.ResourceWithWebhookCheckingInterval = cmd.ResourceCheckingInterval
}

if cmd.ResourceTypeCheckingInterval < cmd.ResourceCheckingInterval {
logger.Info("update-resource-type-checking-interval",
lager.Data{
"oldValue": cmd.ResourceTypeCheckingInterval,
"newValue": cmd.ResourceCheckingInterval,
})
cmd.ResourceTypeCheckingInterval = cmd.ResourceCheckingInterval
}

components := []RunnableComponent{
{
Component: atc.Component{
Expand Down
1 change: 1 addition & 0 deletions atc/db/resource_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ func setResourceConfigScopeForResourceType(conn sq.Runner, scope ResourceConfigS
}

func (r *resourceType) CheckPlan(planFactory atc.PlanFactory, imagePlanner atc.ImagePlanner, from atc.Version, interval atc.CheckEvery, sourceDefaults atc.Source, skipInterval bool, skipIntervalRecursively bool) atc.Plan {
interval.Interval = atc.DefaultResourceTypeInterval
plan := planFactory.NewPlan(atc.CheckPlan{
Name: r.name,
Type: r.type_,
Expand Down
1 change: 1 addition & 0 deletions atc/resourcecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "time"
var (
DefaultCheckInterval time.Duration
DefaultWebhookInterval time.Duration
DefaultResourceTypeInterval time.Duration
)

type CheckRequestBody struct {
Expand Down

0 comments on commit 0fd2b9b

Please sign in to comment.