-
Notifications
You must be signed in to change notification settings - Fork 55
webapp: add per scale set job queue view #836
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -219,6 +219,10 @@ type ScaleSet struct { | |
| Enabled bool | ||
| LastMessageID int64 | ||
| DesiredRunnerCount int | ||
| // RunnerStatistics is the last RunnerScaleSetStatistic received from | ||
| // GitHub on the message session (busy/idle/assigned counts as GitHub | ||
| // sees them). | ||
| RunnerStatistics datatypes.JSON | ||
| // ExtraSpecs is an opaque json that gets sent to the provider | ||
| // as part of the bootstrap params for instances. It can contain | ||
| // any kind of data needed by providers. | ||
|
|
@@ -474,6 +478,11 @@ type WorkflowJob struct { | |
| // ScaleSetJobID is the job ID for a scaleset job. | ||
| ScaleSetJobID string `gorm:"index:scaleset_job_id_idx"` | ||
|
|
||
| // ScaleSetFkID is the ID of the scale set that this job was assigned to, | ||
| // if the job came in through a scale set listener. | ||
| ScaleSetFkID *uint `gorm:"index"` | ||
| ScaleSet ScaleSet `gorm:"foreignKey:ScaleSetFkID"` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs a: Otherwise we'd get a foreign key constraint error when trying to remove a scaleset if a job is associated with it. We have guards to not allow a scaleset to be removed if it has a runner, but a runner may not be spun up instantly as a job is recorded. |
||
|
|
||
| // RunID is the ID of the workflow run. A run may have multiple jobs. | ||
| RunID int64 | ||
| // Action is the specific activity that triggered the event. | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -489,6 +489,14 @@ func (s *sqlDatabase) sqlToCommonScaleSet(scaleSet ScaleSet) (params.ScaleSet, e | |||||||||||||||||
| ret.ProxyName = scaleSet.Proxy.Name | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if len(scaleSet.RunnerStatistics) > 0 { | ||||||||||||||||||
| var stats params.RunnerScaleSetStatistic | ||||||||||||||||||
| if err := json.Unmarshal(scaleSet.RunnerStatistics, &stats); err != nil { | ||||||||||||||||||
| return params.ScaleSet{}, fmt.Errorf("error unmarshaling runner statistics: %w", err) | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we ever run into a corrupted stat, listing scalesets will fail. This should probably be logged as an error, but not bail here. See: Lines 81 to 88 in 2edcc2f
as a reference. |
||||||||||||||||||
| } | ||||||||||||||||||
| ret.Statistics = &stats | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| var ep GithubEndpoint | ||||||||||||||||||
| if scaleSet.RepoID != nil { | ||||||||||||||||||
| ret.RepoID = scaleSet.RepoID.String() | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,9 @@ import { | |
| ProxiesApi, | ||
| ObjectsApi, | ||
| ToolsApi, | ||
| JobsApi, | ||
| type GARMAgentRelease, | ||
| type Job, | ||
| type Repository, | ||
| type Organization, | ||
| type Enterprise, | ||
|
|
@@ -152,6 +154,7 @@ export class GeneratedGarmApiClient { | |
| private proxiesApi: ProxiesApi; | ||
| private objectsApi: ObjectsApi; | ||
| private toolsApi: ToolsApi; | ||
| private jobsApi: JobsApi; | ||
|
|
||
| constructor(baseUrl: string = '') { | ||
| this.baseUrl = baseUrl || window.location.origin; | ||
|
|
@@ -188,6 +191,7 @@ export class GeneratedGarmApiClient { | |
| this.proxiesApi = new ProxiesApi(this.config); | ||
| this.objectsApi = new ObjectsApi(this.config); | ||
| this.toolsApi = new ToolsApi(this.config); | ||
| this.jobsApi = new JobsApi(this.config); | ||
| } | ||
|
|
||
| // Set authentication token | ||
|
|
@@ -222,6 +226,7 @@ export class GeneratedGarmApiClient { | |
| this.providersApi = new ProvidersApi(this.config); | ||
| this.firstRunApi = new FirstRunApi(this.config); | ||
| this.hooksApi = new HooksApi(this.config); | ||
| this.jobsApi = new JobsApi(this.config); | ||
| } | ||
|
|
||
| // Authentication | ||
|
|
@@ -644,6 +649,12 @@ export class GeneratedGarmApiClient { | |
| await this.scaleSetsApi.deleteScaleSet(id.toString()); | ||
| } | ||
|
|
||
| // Jobs | ||
| async listJobs(): Promise<Job[]> { | ||
| const response = await this.jobsApi.listJobs(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might have the potential to overload the DB. If the jobs table stays small, this should be fine, but if we ever end up with many jobs, it might impact performance. Worth keeping track of. |
||
| return response.data || []; | ||
| } | ||
|
|
||
| // Instances | ||
| async listInstances(): Promise<Instance[]> { | ||
| const response = await this.instancesApi.listInstances(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2325,6 +2325,12 @@ export interface Job { | |
| * @memberof Job | ||
| */ | ||
| 'runner_name'?: string; | ||
| /** | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm. Did you use: to update this file, or was it manually edited? This file is meant to be generated from the swagger definitions. Have a look here: https://openapi-generator.tech/docs/installation/ and here: https://github.com/cloudbase/garm/blob/main/webapp/DEV_SETUP.md |
||
| * ScaleSetID is the garm ID of the scale set this job was assigned to, if it came in through a scale set listener. | ||
| * @type {number} | ||
| * @memberof Job | ||
| */ | ||
| 'scale_set_id'?: number; | ||
| /** | ||
| * ScaleSetJobID is the job ID when generated for a scale set. | ||
| * @type {string} | ||
|
|
@@ -3003,6 +3009,20 @@ export interface RunnerPrefix { | |
| * @export | ||
| * @interface ScaleSet | ||
| */ | ||
| /** | ||
| * RunnerScaleSetStatistic is the last runner scale set statistic received from GitHub on the message session. | ||
| * @export | ||
| * @interface RunnerScaleSetStatistic | ||
| */ | ||
| export interface RunnerScaleSetStatistic { | ||
| 'totalAvailableJobs'?: number; | ||
| 'totalAcquiredJobs'?: number; | ||
| 'totalAssignedJobs'?: number; | ||
| 'totalRunningJobs'?: number; | ||
| 'totalRegisteredRunners'?: number; | ||
| 'totalBusyRunners'?: number; | ||
| 'totalIdleRunners'?: number; | ||
| } | ||
| export interface ScaleSet { | ||
| /** | ||
| * | ||
|
|
@@ -3160,6 +3180,12 @@ export interface ScaleSet { | |
| * @memberof ScaleSet | ||
| */ | ||
| 'proxy_name'?: string; | ||
| /** | ||
| * Statistics is the last runner scale set statistic received from GitHub on the message session. | ||
| * @type {RunnerScaleSetStatistic} | ||
| * @memberof ScaleSet | ||
| */ | ||
| 'statistics'?: RunnerScaleSetStatistic; | ||
| /** | ||
| * | ||
| * @type {string} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model changes will require a migration to be added. We switched to
gormigrateto do away with the custom code insql.go(and the convoluted conditionals we used to have).A file in
database/sql/migrations/0007_scaleset_job_queue.gowith something like:At the end, your migrations table should look like this: