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

[usage] Refactor controller package into scheduler #12831

Merged
merged 2 commits into from
Sep 13, 2022

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented Sep 9, 2022

Description

Refactor existing controller package into the following:

  • Scheduler, capable of scheduling a function with a specified schedule
  • Scheduler now tracks metrics for all jobs it runs
  • Job Mutex moves outside of the scheduler and into each job

Related Issue(s)

Fixes #

How to test

Unit

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@easyCZ easyCZ force-pushed the mp/usage-refactor-controller-package branch from bb0f3f4 to 5f90ea5 Compare September 9, 2022 13:39
@easyCZ easyCZ changed the base branch from main to mp/usage-remove-unused-config-and-funcs September 9, 2022 13:39
@roboquat roboquat added size/XL and removed size/XXL labels Sep 9, 2022
Base automatically changed from mp/usage-remove-unused-config-and-funcs to main September 12, 2022 06:35
@roboquat roboquat added size/XXL and removed size/XL labels Sep 12, 2022
@easyCZ easyCZ force-pushed the mp/usage-refactor-controller-package branch from 8390b0b to 8b65faa Compare September 12, 2022 12:43
@roboquat roboquat added size/XL and removed size/XXL labels Sep 12, 2022
# This is the 1st commit message:

[usage] Refactor controller package into scheduler

# This is the commit message #2:

[usage] Refactor controller package into scheduler
@easyCZ easyCZ force-pushed the mp/usage-refactor-controller-package branch from 8b65faa to aa51c3b Compare September 12, 2022 12:50
Comment on lines 53 to 65
select {
// attempt a write to signal we want to run
case r.running <- struct{}{}:
// we managed to write, there's no other job executing. Cases are not fall through so we continue executing our main logic.
default:
// we could not write, so another instance is already running. Skip current run.
log.Infof("Skipping ledger run, another run is already in progress.")
return nil
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutex logic moves into the job, away from the controller itself. This is needed to allow us to run multiple control loops with the same scheduler.

@@ -16,26 +16,26 @@ const (
)

var (
reconcileStartedTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
jobStartedSeconds = prometheus.NewCounterVec(prometheus.CounterOpts{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are now general job metrics, rather than specific for the reconcile with ledger. If a job desires more metrics, those can be added in job direclty rather than on the scheduler level.

@easyCZ easyCZ force-pushed the mp/usage-refactor-controller-package branch from aa51c3b to 972ee4f Compare September 12, 2022 14:24
@easyCZ easyCZ marked this pull request as ready for review September 12, 2022 14:24
@easyCZ easyCZ requested a review from a team September 12, 2022 14:24
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Sep 12, 2022
@easyCZ easyCZ force-pushed the mp/usage-refactor-controller-package branch from 972ee4f to 0d1f67c Compare September 12, 2022 14:52
Copy link
Contributor

@andrew-farries andrew-farries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/hold for a couple of questions

components/usage/pkg/scheduler/job.go Show resolved Hide resolved
components/usage/pkg/scheduler/reporter.go Outdated Show resolved Hide resolved
@easyCZ easyCZ force-pushed the mp/usage-refactor-controller-package branch from 0d1f67c to f98b45b Compare September 13, 2022 08:09
@easyCZ easyCZ force-pushed the mp/usage-refactor-controller-package branch from f98b45b to 675be73 Compare September 13, 2022 08:24
@easyCZ
Copy link
Member Author

easyCZ commented Sep 13, 2022

/unhold

@roboquat roboquat merged commit 8dcbb57 into main Sep 13, 2022
@roboquat roboquat deleted the mp/usage-refactor-controller-package branch September 13, 2022 09:17
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/XL team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants