generated from cobaltcore-dev/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor Decision CRD to History 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
Merged
Merged
Changes from all commits
Commits
Show all changes
49 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 09020de
Merge branch 'main' into refactor-decision-crd-v2
SoWieMarkus 03285ad
Merge remote-tracking branch 'origin/main' into refactor-decision-crd-v2
SoWieMarkus b7c7df6
Merge branch 'main' into refactor-decision-crd-v2
SoWieMarkus b26be9f
Refactor history upsert logic in FilterWeigherPipelineController for …
SoWieMarkus 68d0cf6
Feedback
SoWieMarkus c70c701
make crds deepcopy
SoWieMarkus 6ce1706
Refactor scheduling reason constants in HistoryClient and tests for i…
SoWieMarkus 83f2ace
Refactor scheduling intent handling across decision types and history…
SoWieMarkus c4c641b
Refactor ProcessNewPod method to set default scheduling intent and si…
SoWieMarkus 905f652
Add docs
SoWieMarkus a5972ca
Remove panel from status dashboard
SoWieMarkus 12bbacd
Merge branch 'main' into refactor-decision-crd-v2
SoWieMarkus f40f424
Fix createDecisions to createHistory in kvm-general-purpose-load-bala…
SoWieMarkus ea864a4
Refactor cleanup tasks to use history naming convention in values.yam…
SoWieMarkus abac426
Add History and HistoryList GVKs to values.yaml for cinder, ironcore,…
SoWieMarkus 1fdabd9
Refactor HistoryManager initialization to use multicluster.Client for…
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
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,127 @@ | ||
| // 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" | ||
| ) | ||
|
|
||
| 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"` | ||
| } | ||
|
|
||
| const ( | ||
| // The scheduling decision is ready (a host was successfully selected). | ||
| HistoryConditionReady = "Ready" | ||
| // The scheduling decision selected a target host. | ||
| HistoryReasonSchedulingSucceeded = "SchedulingSucceeded" | ||
| // The pipeline run failed before a host could be selected. | ||
| HistoryReasonPipelineRunFailed = "PipelineRunFailed" | ||
| // The pipeline completed but no suitable host was found. | ||
| HistoryReasonNoHostFound = "NoHostFound" | ||
| ) | ||
|
|
||
| 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
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"` | ||
SoWieMarkus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // +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" | ||
|
|
||
| // The history is a CRD that provides a record of past scheduling decisions for a given resource (e.g., a nova instance). | ||
| // A new history entry is created for each scheduling decision, and the most recent decision is stored in the status.current field. The history is capped at 10 entries to prevent unbounded growth. | ||
| // This CRD is designed to be used by an operations team to troubleshoot scheduling decisions and understand the context around why a particular host was selected (or not selected) for a resource. | ||
| 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
Oops, something went wrong.
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.
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.
If we're making this a kubernetes value, I would prefer
live-migrationoverlive_migration