-
Notifications
You must be signed in to change notification settings - Fork 13
Add ServerCleaning controller #704
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
Draft
stefanhipfel
wants to merge
12
commits into
main
Choose a base branch
from
server_cleaning
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.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a75f3e4
Add unit tests for ServerCleaning controller and update test suite setup
stefanhipfel c248a19
Add CustomResourceDefinition for ServerCleaning and update API docume…
stefanhipfel 65e1eee
Merge branch 'main' into server_cleaning
stefanhipfel d261f20
Merge branch 'main' into server_cleaning
stefanhipfel 83c5a58
Add dedicated BMCTask controller for task polling
stefanhipfel ce4c1e5
Register BMCTask controller with manager
stefanhipfel 4496669
Update documentation to clarify API dependency
stefanhipfel cd62200
Add BMC Tasks API and GetTaskStatus method
stefanhipfel 76b338d
Fix conflicts after rebase: unify GetTaskStatus interface
stefanhipfel 6bae17f
Refactor ServerCleaning to use BMCTask controller pattern
stefanhipfel 314869d
updates crd
stefanhipfel 94c24ed
Fix package naming conflict in bmc directory
stefanhipfel 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| // SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // ServerCleaningSpec defines the desired cleaning operations | ||
| // +kubebuilder:validation:XValidation:rule="has(self.serverRef) || has(self.serverSelector)", message="either serverRef or serverSelector must be specified" | ||
| type ServerCleaningSpec struct { | ||
| // ServerRef references a specific Server to be cleaned. | ||
| // Mutually exclusive with ServerSelector. | ||
| // +optional | ||
| ServerRef *corev1.LocalObjectReference `json:"serverRef,omitempty"` | ||
|
|
||
| // ServerSelector specifies a label selector to identify servers to be cleaned. | ||
| // Mutually exclusive with ServerRef. | ||
| // +optional | ||
| ServerSelector *metav1.LabelSelector `json:"serverSelector,omitempty"` | ||
|
|
||
| // DiskWipe specifies disk erasing configuration | ||
| // +optional | ||
| DiskWipe *DiskWipeConfig `json:"diskWipe,omitempty"` | ||
|
|
||
| // BMCReset specifies if BMC should be reset to defaults | ||
| // +optional | ||
| BMCReset bool `json:"bmcReset,omitempty"` | ||
|
|
||
| // BIOSReset specifies if BIOS should be reset to defaults | ||
| // +optional | ||
| BIOSReset bool `json:"biosReset,omitempty"` | ||
|
|
||
| // NetworkCleanup specifies if network configurations should be cleared | ||
| // +optional | ||
| NetworkCleanup bool `json:"networkCleanup,omitempty"` | ||
|
|
||
| // ServerBootConfigurationTemplate defines the boot configuration for cleaning agent | ||
| // If not specified, cleaning operations are performed via BMC APIs | ||
| // +optional | ||
| ServerBootConfigurationTemplate *ServerBootConfigurationTemplate `json:"serverBootConfigurationTemplate,omitempty"` | ||
| } | ||
|
|
||
| // DiskWipeConfig defines disk erasing behavior | ||
| type DiskWipeConfig struct { | ||
| // Method specifies the disk erasing method | ||
| // +kubebuilder:validation:Enum=quick;secure;dod | ||
| // +kubebuilder:default=quick | ||
| Method DiskWipeMethod `json:"method"` | ||
|
|
||
| // IncludeBootDrives specifies whether to erase boot drives | ||
| // +optional | ||
| IncludeBootDrives bool `json:"includeBootDrives,omitempty"` | ||
| } | ||
|
|
||
| // DiskWipeMethod defines the available disk erasing methods | ||
| type DiskWipeMethod string | ||
|
|
||
| const ( | ||
| // DiskWipeMethodQuick performs a quick erase (single pass) | ||
| DiskWipeMethodQuick DiskWipeMethod = "quick" | ||
|
|
||
| // DiskWipeMethodSecure performs a secure erase (3 passes) | ||
| DiskWipeMethodSecure DiskWipeMethod = "secure" | ||
|
|
||
| // DiskWipeMethodDoD performs DoD 5220.22-M standard erase (7 passes) | ||
| DiskWipeMethodDoD DiskWipeMethod = "dod" | ||
| ) | ||
|
|
||
| // ServerCleaningState defines the state of the cleaning process | ||
| type ServerCleaningState string | ||
|
|
||
| const ( | ||
| // ServerCleaningStatePending indicates cleaning is waiting to start | ||
| ServerCleaningStatePending ServerCleaningState = "Pending" | ||
|
|
||
| // ServerCleaningStateInProgress indicates cleaning is in progress | ||
| ServerCleaningStateInProgress ServerCleaningState = "InProgress" | ||
|
|
||
| // ServerCleaningStateCompleted indicates cleaning completed successfully | ||
| ServerCleaningStateCompleted ServerCleaningState = "Completed" | ||
|
|
||
| // ServerCleaningStateFailed indicates cleaning failed | ||
| ServerCleaningStateFailed ServerCleaningState = "Failed" | ||
| ) | ||
|
|
||
| // ServerCleaningStatus defines the observed state of ServerCleaning | ||
| type ServerCleaningStatus struct { | ||
| // State represents the current state of the cleaning process | ||
| // +optional | ||
| State ServerCleaningState `json:"state,omitempty"` | ||
|
|
||
| // SelectedServers is the total number of servers selected for cleaning | ||
| // +optional | ||
| SelectedServers int32 `json:"selectedServers,omitempty"` | ||
|
|
||
| // PendingCleanings is the number of servers with pending cleaning | ||
| // +optional | ||
| PendingCleanings int32 `json:"pendingCleanings,omitempty"` | ||
|
|
||
| // InProgressCleanings is the number of servers currently being cleaned | ||
| // +optional | ||
| InProgressCleanings int32 `json:"inProgressCleanings,omitempty"` | ||
|
|
||
| // CompletedCleanings is the number of servers successfully cleaned | ||
| // +optional | ||
| CompletedCleanings int32 `json:"completedCleanings,omitempty"` | ||
|
|
||
| // FailedCleanings is the number of servers where cleaning failed | ||
| // +optional | ||
| FailedCleanings int32 `json:"failedCleanings,omitempty"` | ||
|
|
||
| // ServerCleaningStatuses contains per-server cleaning status | ||
| // +optional | ||
| ServerCleaningStatuses []ServerCleaningStatusEntry `json:"serverCleaningStatuses,omitempty"` | ||
|
|
||
| // Conditions represents the latest available observations | ||
| // +patchStrategy=merge | ||
| // +patchMergeKey=type | ||
| // +optional | ||
| Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` | ||
| } | ||
|
|
||
| // ServerCleaningStatusEntry represents the cleaning status for a single server | ||
| type ServerCleaningStatusEntry struct { | ||
| // ServerName is the name of the server | ||
| // +required | ||
| ServerName string `json:"serverName"` | ||
|
|
||
| // State is the cleaning state for this server | ||
| // +required | ||
| State ServerCleaningState `json:"state"` | ||
|
|
||
| // Message provides additional information about the cleaning state | ||
| // +optional | ||
| Message string `json:"message,omitempty"` | ||
|
|
||
| // LastUpdateTime is the last time this status was updated | ||
| // +optional | ||
| LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:resource:scope=Namespaced,shortName=scl | ||
| // +kubebuilder:printcolumn:name="Selected",type=integer,JSONPath=`.status.selectedServers` | ||
| // +kubebuilder:printcolumn:name="Completed",type=integer,JSONPath=`.status.completedCleanings` | ||
| // +kubebuilder:printcolumn:name="InProgress",type=integer,JSONPath=`.status.inProgressCleanings` | ||
| // +kubebuilder:printcolumn:name="Failed",type=integer,JSONPath=`.status.failedCleanings` | ||
| // +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state` | ||
| // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` | ||
|
|
||
| // ServerCleaning is the Schema for the servercleaning API | ||
| type ServerCleaning struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec ServerCleaningSpec `json:"spec,omitempty"` | ||
| Status ServerCleaningStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // ServerCleaningList contains a list of ServerCleaning | ||
| type ServerCleaningList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []ServerCleaning `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&ServerCleaning{}, &ServerCleaningList{}) | ||
| } |
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.
can be removed once #672 is merged