Skip to content

feat: add scheduling configuration for prebuilds #408

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

Merged
merged 19 commits into from
Jun 18, 2025

Conversation

evgeniy-scherbina
Copy link
Contributor

@evgeniy-scherbina evgeniy-scherbina commented May 29, 2025

Relates to coder/internal#312
Needed for coder/coder#18126

Exposes an autoscaling field under coder_workspace_preset:

data "coder_workspace_preset" "us-nix" {
  ...
  
  prebuilds = {
	  instances = 0                  # default to 0 instances
	  
	  scheduling {
		  timezone = "UTC"             # only a single timezone may be used for simplicity
		  
		  # scale to 3 instances during the work week
		  schedule {
		    cron = "* 8-18 * * 1-5"    # from 8AM-6:59PM, Mon-Fri, UTC
		    instances = 3              # scale to 3 instances
		  }
		  
		  # scale to 1 instance on Saturdays for urgent support queries
		  schedule {
		    cron = "* 8-14 * * 6"      # from 8AM-2:59PM, Sat, UTC
		    instances = 1              # scale to 1 instance
		  }
	  }
  }
}

@evgeniy-scherbina evgeniy-scherbina force-pushed the prebuilds-autoscaling-mechanism branch from 15cae29 to 543a735 Compare June 11, 2025 17:35
@spikecurtis
Copy link
Contributor

I really don't think we should call this "autoscaling" as that already has a specific meaning in Cloud circles which this is not.

Autoscaling is adjusting instance counts dynamically based on measured load.

This is adjusting instance counts based on a schedule. Some possible names:

  • Scale sceduling
  • Schedule-scaling
  • Pool scheduling
  • Prebuild scheduling

@dannykopping
Copy link
Contributor

I really don't think we should call this "autoscaling" as that already has a specific meaning in Cloud circles which this is not.

Autoscaling is adjusting instance counts dynamically based on measured load.

This is adjusting instance counts based on a schedule. Some possible names:

  • Scale sceduling
  • Schedule-scaling
  • Pool scheduling
  • Prebuild scheduling

I agree with @spikecurtis; autoscaling does indeed feel muddy in retrospect.
I'll offer scheduling as a another alternative.

Comment on lines +19 to +20
return xerrors.Errorf("schedules overlap: %s and %s",
schedules[i], schedules[j])
Copy link
Contributor

Choose a reason for hiding this comment

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

This error message could be more helpful. We know which aspect of the schedules overlap, so let's help template authors out by telling them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It means everything (minutes, hours and days) overlap.


// SchedulesOverlap checks if two schedules overlap by checking
// days, months, and hours separately
func SchedulesOverlap(schedule1, schedule2 string) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is excellent work @evgeniy-scherbina!

I really like how clean the code is, how complete the code-coverage, and how clear the intentions are.

@evgeniy-scherbina evgeniy-scherbina changed the title feat: add autoscaling configuration for prebuilds feat: add scheduling configuration for prebuilds Jun 18, 2025
@evgeniy-scherbina
Copy link
Contributor Author

I really don't think we should call this "autoscaling" as that already has a specific meaning in Cloud circles which this is not.

Autoscaling is adjusting instance counts dynamically based on measured load.

This is adjusting instance counts based on a schedule. Some possible names:

  • Scale sceduling
  • Schedule-scaling
  • Pool scheduling
  • Prebuild scheduling

@spikecurtis I renamed everything to scheduling

@evgeniy-scherbina evgeniy-scherbina merged commit 6570400 into main Jun 18, 2025
6 checks passed
@evgeniy-scherbina evgeniy-scherbina deleted the prebuilds-autoscaling-mechanism branch June 18, 2025 20:34
@github-actions github-actions bot locked and limited conversation to collaborators Jun 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants