generated from cobaltcore-dev/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor Decision CRD #569
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
SoWieMarkus
wants to merge
33
commits into
main
Choose a base branch
from
refactor-decision-crd-v2
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
33 commits
Select commit
Hold shift + click to select a range
409f754
Add History CRD and related types for scheduling history management
SoWieMarkus 97892a8
Add note that we keep the name of the flag to avoid breaking changes
SoWieMarkus 5d24cc4
Remove explanation controller from configs
SoWieMarkus 57b7cd1
Remove explanation controller
SoWieMarkus 1483969
Unify scheduling intent types
SoWieMarkus 326b2cd
Add histories resource to ClusterRole and update event permissions
SoWieMarkus e6f8124
Refactor history types to include CurrentDecision structure and enhan…
SoWieMarkus f09e933
Implement HistoryManager for decision tracking in scheduling controllers
SoWieMarkus d6a7ba6
Merge branch 'main' into refactor-decision-crd-v2
SoWieMarkus ca94a11
Refactor clean up tasks to clean up history crd
SoWieMarkus f1aa74d
Refactor explanation formatting in TestGenerateExplanation for clarity
SoWieMarkus ea4f99e
Lint fix
SoWieMarkus 36b9195
Add AvailabilityZone field to HistorySpec and update related logic
SoWieMarkus 3dd85ca
Add host list cap to explanation generation and enhance tests for lar…
SoWieMarkus 328a2ef
Refactor UpsertFromGoroutine test to use WaitGroup for synchronizatio…
SoWieMarkus 45977be
Refactor comments in DecisionsCleanup functions to clarify history en…
SoWieMarkus c2abd19
Add nil check for decision parameter in Upsert method
SoWieMarkus e82b766
Add MaxItems validation to OrderedHosts in SchedulingHistoryEntry
SoWieMarkus 0bcae9d
Add orderedHosts to required fields in History spec
SoWieMarkus a790c7b
Refactor decision upsert logic to remove goroutine and ensure proper …
SoWieMarkus 47ea72b
lint fix
SoWieMarkus 5f9b2f2
Update ResourceID format to include pod namespace in decision spec
SoWieMarkus 572adbf
Make OrderedHosts field optional in SchedulingHistoryEntry
SoWieMarkus 8fa4dbb
Fix ResourceID format in decision spec and history deletion to use do…
SoWieMarkus 64c5f5e
Refactor history upsert logic to use context and avoid goroutine for …
SoWieMarkus 24f31f1
Handle nil OrderedHosts in Upsert method to prevent potential nil poi…
SoWieMarkus 45d827b
Remove magic number
SoWieMarkus d9404b8
Refactor Upsert method to handle OrderedHosts more efficiently and us…
SoWieMarkus 1e4a0e8
Refactor Upsert method to simplify OrderedHosts length check by remov…
SoWieMarkus d69b026
Refactor Upsert method to improve history management and handle concu…
SoWieMarkus a3736b6
Refactor Upsert method to add first attempt tracking for retry logic …
SoWieMarkus b797d04
Refactor ProcessNewMachine method to use context in Upsert call for h…
SoWieMarkus a3044e6
Refactor history validation to enforce max items limit for OrderedHos…
SoWieMarkus 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| // Copyright SAP SE | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // SchedulingIntent defines the intent of a scheduling decision. | ||
| type SchedulingIntent string | ||
|
|
||
| // Other intents can be defined by the operators. | ||
| const ( | ||
| // Used as default intent if the operator does not specify one. | ||
| SchedulingIntentUnknown SchedulingIntent = "Unknown" | ||
| ) | ||
|
|
||
| type SchedulingHistoryEntry struct { | ||
| // The timestamp of when the decision was made. | ||
| Timestamp metav1.Time `json:"timestamp"` | ||
| // The pipeline that was used for the decision. | ||
| PipelineRef corev1.ObjectReference `json:"pipelineRef"` | ||
| // The intent of the decision (e.g., initial scheduling, rescheduling, etc.). | ||
| Intent SchedulingIntent `json:"intent"` | ||
| // The top hosts ordered by score for the decision (limited to 3). | ||
| // This is not a complete list of all candidates — only the highest-ranked | ||
| // hosts are retained to keep the history compact. | ||
| // +kubebuilder:validation:Optional | ||
| // +kubebuilder:validation:MaxItems=3 | ||
| OrderedHosts []string `json:"orderedHosts,omitempty"` | ||
| // Whether the scheduling decision was successful. | ||
| // +kubebuilder:validation:Optional | ||
| Successful bool `json:"successful"` | ||
| } | ||
|
|
||
| type HistorySpec struct { | ||
| // The scheduling domain this object with the history belongs to. | ||
| SchedulingDomain SchedulingDomain `json:"schedulingDomain"` | ||
| // The resource ID this history belongs to (e.g., the UUID of a nova instance). | ||
| ResourceID string `json:"resourceID"` | ||
| // The availability zone of the resource, if known. Only set for scheduling | ||
| // domains that provide AZ information (e.g., Nova). | ||
| // +kubebuilder:validation:Optional | ||
| AvailabilityZone *string `json:"availabilityZone,omitempty"` | ||
| } | ||
|
|
||
| // CurrentDecision holds the full context of the most recent scheduling | ||
| // decision. When a new decision arrives the previous CurrentDecision is | ||
| // compacted into a SchedulingHistoryEntry and appended to History. | ||
| type CurrentDecision struct { | ||
| // The timestamp of when the decision was made. | ||
| Timestamp metav1.Time `json:"timestamp"` | ||
| // The pipeline that was used for the decision. | ||
| PipelineRef corev1.ObjectReference `json:"pipelineRef"` | ||
| // The intent of the decision (e.g., initial scheduling, rescheduling, etc.). | ||
| Intent SchedulingIntent `json:"intent"` | ||
| // Whether the scheduling decision was successful. | ||
| Successful bool `json:"successful"` | ||
| // The target host selected for the resource. nil when no host was found. | ||
| // +kubebuilder:validation:Optional | ||
| TargetHost *string `json:"targetHost,omitempty"` | ||
| // A human-readable explanation of the scheduling decision. | ||
| // +kubebuilder:validation:Optional | ||
| Explanation string `json:"explanation,omitempty"` | ||
| // The top hosts ordered by score (limited to 3). | ||
| // +kubebuilder:validation:Optional | ||
SoWieMarkus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // +kubebuilder:validation:MaxItems=3 | ||
| OrderedHosts []string `json:"orderedHosts,omitempty"` | ||
| } | ||
|
|
||
| type HistoryStatus struct { | ||
| // Current represents the latest scheduling decision with full context. | ||
| // +kubebuilder:validation:Optional | ||
| Current CurrentDecision `json:"current,omitempty"` | ||
| // History of past scheduling decisions (limited to last 10). | ||
| // +kubebuilder:validation:Optional | ||
| History []SchedulingHistoryEntry `json:"history,omitempty"` | ||
|
|
||
| // Conditions represent the latest available observations of the history's state. | ||
| // +kubebuilder:validation:Optional | ||
| Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:resource:scope=Cluster | ||
| // +kubebuilder:printcolumn:name="Domain",type="string",JSONPath=".spec.schedulingDomain" | ||
| // +kubebuilder:printcolumn:name="Resource ID",type="string",JSONPath=".spec.resourceID" | ||
| // +kubebuilder:printcolumn:name="AZ",type="string",JSONPath=".spec.availabilityZone" | ||
| // +kubebuilder:printcolumn:name="Target Host",type="string",JSONPath=".status.current.targetHost" | ||
| // +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason" | ||
| // +kubebuilder:printcolumn:name="Created",type="date",JSONPath=".metadata.creationTimestamp" | ||
|
|
||
| // History is the Schema for the history API | ||
| type History struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
|
|
||
| // Standard object metadata. | ||
| // +optional | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| // Spec defines the desired state of History. | ||
| // +required | ||
| Spec HistorySpec `json:"spec"` | ||
| // Status defines the observed state of History. | ||
| // +optional | ||
| Status HistoryStatus `json:"status,omitempty"` | ||
SoWieMarkus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // HistoryList contains a list of History | ||
| type HistoryList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []History `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&History{}, &HistoryList{}) | ||
| } | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.