Skip to content

Commit

Permalink
Merge pull request #451 from buildkite/higher-priority-jobs-first
Browse files Browse the repository at this point in the history
Schedule jobs in priority order
  • Loading branch information
DrJosh9000 authored Dec 16, 2024
2 parents 6135a89 + 2c634b8 commit 9dc59c3
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 115 deletions.
48 changes: 34 additions & 14 deletions api/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

197 changes: 101 additions & 96 deletions api/genqlient.graphql
Original file line number Diff line number Diff line change
@@ -1,148 +1,153 @@
fragment Job on Job {
... on JobTypeCommand {
...CommandJob
}
... on JobTypeCommand {
...CommandJob
}
}

fragment CommandJob on JobTypeCommand {
uuid
env
scheduledAt
agentQueryRules
command
uuid
env
priority {
number
}
agentQueryRules
command
}

fragment Build on Build {
uuid
id
number
state
jobs(first: 100) {
edges {
# @genqlient(flatten: true)
node {
...Job
}
uuid
id
number
state
jobs(first: 100) {
edges {
# @genqlient(flatten: true)
node {
...Job
}
}
}
}
}

mutation BuildCreate($input: BuildCreateInput!) {
buildCreate(input: $input) {
build {
...Build
buildCreate(input: $input) {
build {
...Build
}
}
}
}

mutation BuildCancel($input: BuildCancelInput!) {
buildCancel(input: $input) {
clientMutationId
}
buildCancel(input: $input) {
clientMutationId
}
}

query GetOrganization($slug: ID!) {
organization(slug: $slug) {
id
}
organization(slug: $slug) {
id
}
}

query GetBuild($uuid: ID!) {
build(uuid: $uuid) {
...Build
}
build(uuid: $uuid) {
...Build
}
}

query GetScheduledJobs($slug: ID!, $agentQueryRules: [String!]) {
organization(slug: $slug) {
# @genqlient(pointer: true)
id
jobs(
state: [SCHEDULED]
type: [COMMAND]
first: 100
order: RECENTLY_ASSIGNED
agentQueryRules: $agentQueryRules
clustered: false
) {
count
edges {
# @genqlient(flatten: true)
node {
...Job
organization(slug: $slug) {
# @genqlient(pointer: true)
id
jobs(
state: [SCHEDULED]
type: [COMMAND]
first: 100
order: RECENTLY_ASSIGNED
agentQueryRules: $agentQueryRules
clustered: false
) {
count
edges {
# @genqlient(flatten: true)
node {
...Job
}
}
}
}
}
}
}

query GetScheduledJobsClustered($slug: ID!, $agentQueryRules: [String!], $cluster: ID!) {
organization(slug: $slug) {
# @genqlient(pointer: true)
id
jobs(
state: [SCHEDULED]
type: [COMMAND]
first: 100
order: RECENTLY_ASSIGNED
agentQueryRules: $agentQueryRules
cluster: $cluster
) {
count
edges {
# @genqlient(flatten: true)
node {
...Job
query GetScheduledJobsClustered(
$slug: ID!
$agentQueryRules: [String!]
$cluster: ID!
) {
organization(slug: $slug) {
# @genqlient(pointer: true)
id
jobs(
state: [SCHEDULED]
type: [COMMAND]
first: 100
order: RECENTLY_ASSIGNED
agentQueryRules: $agentQueryRules
cluster: $cluster
) {
count
edges {
# @genqlient(flatten: true)
node {
...Job
}
}
}
}
}
}
}

query GetBuilds($slug: ID!, $state: [BuildStates!], $first: Int) {
pipeline(slug: $slug) {
builds(state: $state, first: $first) {
edges {
node {
...Build
pipeline(slug: $slug) {
builds(state: $state, first: $first) {
edges {
node {
...Build
}
}
}
}
}
}
}

query GetCommandJob($uuid: ID!) {
job(uuid: $uuid) {
... on JobTypeCommand {
id
state
job(uuid: $uuid) {
... on JobTypeCommand {
id
state
}
}
}
}

mutation CancelCommandJob($input: JobTypeCommandCancelInput!) {
jobTypeCommandCancel(input: $input) {
clientMutationId
}
jobTypeCommandCancel(input: $input) {
clientMutationId
}
}


### The following are used in the cleanup integration "test"
mutation PipelineDelete($input: PipelineDeleteInput!) {
pipelineDelete(input: $input) {
clientMutationId
}
pipelineDelete(input: $input) {
clientMutationId
}
}

query SearchPipelines($slug: ID!, $search: String!, $first: Int!) {
organization(slug: $slug) {
pipelines(search: $search, first: $first) {
edges {
node {
id
name
organization(slug: $slug) {
pipelines(search: $search, first: $first) {
edges {
node {
id
name
}
}
}
}
}
}
}
Loading

0 comments on commit 9dc59c3

Please sign in to comment.