-
Notifications
You must be signed in to change notification settings - Fork 6
feat: adding pipeline options #799
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
Open
mblos
wants to merge
23
commits into
main
Choose a base branch
from
pipeline-refactor-configs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
36b7d94
feat: adding pipeline options
mblos ad66112
example usage
mblos 4a7bc9e
adding: MaxCandidates, IgnoredReservationTypes, ReadOnly
mblos d298e75
validate options
mblos 54639d1
refactor
mblos c2d0fc2
.
mblos 4de31f9
refactor
mblos c2f0b56
comments
mblos 7a014b2
.
mblos cc9b6e6
refactor CreateHistory
mblos 4886d37
.
mblos 3b8cf87
moving to api package
mblos b6a6139
Merge branch 'main' into pipeline-refactor-configs
mblos 037f74c
fix merge main
mblos 811a1c3
Merge branch 'main' into pipeline-refactor-configs
mblos 91dfe3e
refactor
mblos f84ba71
Merge remote-tracking branch 'origin/pipeline-refactor-configs' into …
mblos 5c6ecae
refactor
mblos 2871d18
fix
mblos 4ee2c6a
fixes
mblos 532200d
refactor
mblos 8b2ffa0
Merge branch 'main' into pipeline-refactor-configs
mblos b535ec0
.
mblos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright SAP SE | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package scheduling | ||
|
|
||
| import ( | ||
| "errors" | ||
|
|
||
| "github.com/cobaltcore-dev/cortex/api/v1alpha1" | ||
| ) | ||
|
|
||
| // Options configure the behavior of a single pipeline run at call time. | ||
| // These are distinct from per-step YAML options (FilterWeigherPipelineStepOpts), | ||
| // which are static and set when the pipeline is initialized. | ||
| type Options struct { | ||
| // ReadOnly means the pipeline run does not modify shared scheduling state (reservations, | ||
| // history, inflight records). Concurrent read-only runs are safe under a shared read lock. | ||
| ReadOnly bool `json:"read_only,omitempty"` | ||
| // LockReservations prevents reservation unlocking, i.e. considering those as unavailable resources. | ||
| LockReservations bool `json:"lock_reservations,omitempty"` | ||
| // AssumeEmptyHosts ignores running instances on hosts, considering them as empty. | ||
| AssumeEmptyHosts bool `json:"assume_empty_hosts,omitempty"` | ||
| // IgnoredReservationTypes lists reservation types whose reserved capacity the capacity filter does not block. | ||
| IgnoredReservationTypes []v1alpha1.ReservationType `json:"ignored_reservation_types,omitempty"` | ||
| // MaxCandidates limits the number of hosts returned after weighing. 0 means no limit. | ||
| MaxCandidates int `json:"max_candidates,omitempty"` | ||
|
|
||
| // SkipHistory skips recording the placement decision in placement history. | ||
| SkipHistory bool `json:"skip_history,omitempty"` | ||
| // SkipInflight skips creating pessimistic blocking reservations for returned candidates. | ||
| SkipInflight bool `json:"skip_inflight,omitempty"` | ||
| } | ||
|
|
||
| // Validate checks for mutually exclusive or inconsistent option combinations. | ||
| func (o Options) Validate() error { | ||
| if o.ReadOnly && !o.SkipHistory { | ||
| return errors.New("read-only runs must not write scheduling history: set SkipHistory=true") | ||
| } | ||
| if o.ReadOnly && !o.SkipInflight { | ||
| return errors.New("read-only runs cannot create inflight reservations") | ||
| } | ||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright SAP SE | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package scheduling | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestOptions_Validate(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| opts Options | ||
| wantErr bool | ||
| }{ | ||
| {"zero value is valid", Options{}, false}, | ||
| {"read-only run, skipping history and inflight", Options{ReadOnly: true, SkipHistory: true, SkipInflight: true}, false}, | ||
| {"ReadOnly without SkipHistory is invalid", Options{ReadOnly: true}, true}, | ||
| {"ReadOnly without SkipInflight is invalid", Options{ReadOnly: true, SkipHistory: true}, true}, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| err := tt.opts.Validate() | ||
| if tt.wantErr && err == nil { | ||
| t.Error("expected error, got nil") | ||
| } | ||
| if !tt.wantErr && err != nil { | ||
| t.Errorf("expected no error, got %v", err) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.