Documentation
¶
Overview ¶
nolint:wsl,gocognit,cyclop,gocyclo,nestif // Business logic migrated from old code
nolint:wsl,lll,gocognit,cyclop,gocyclo,nestif // Business logic migrated from old code
Index ¶
- func ConfigureFieldIndexers(mgr ctrl.Manager, cfg *config.Config) error
- func NewCondition(condType v1alpha1.GPUResetConditionType, status metav1.ConditionStatus, ...) metav1.Condition
- type GPUResetReconciler
- type MockCSPBehavior
- type MockCSPServer
- func (s *MockCSPServer) IsNodeReady(ctx context.Context, req *cspv1alpha1.IsNodeReadyRequest) (*cspv1alpha1.IsNodeReadyResponse, error)
- func (s *MockCSPServer) SendRebootSignal(ctx context.Context, req *cspv1alpha1.SendRebootSignalRequest) (*cspv1alpha1.SendRebootSignalResponse, error)
- func (s *MockCSPServer) SendTerminateSignal(ctx context.Context, req *cspv1alpha1.SendTerminateSignalRequest) (*cspv1alpha1.SendTerminateSignalResponse, error)
- func (s *MockCSPServer) SetBehavior(behavior *MockCSPBehavior)
- func (s *MockCSPServer) SetFailure()
- func (s *MockCSPServer) SetNodeReady(ready bool)
- func (s *MockCSPServer) SetNodeReadyError(err error)
- func (s *MockCSPServer) SetRebootFailure(err error)
- func (s *MockCSPServer) SetRebootSuccess(requestID string)
- func (s *MockCSPServer) SetSuccess()
- func (s *MockCSPServer) SetTerminateFailure(err error)
- func (s *MockCSPServer) SetTerminateSuccess(requestID string)
- type MockCSPTestHelper
- type RebootNodeReconciler
- type TerminateNodeReconciler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureFieldIndexers ¶
func NewCondition ¶
func NewCondition( condType v1alpha1.GPUResetConditionType, status metav1.ConditionStatus, reason v1alpha1.GPUResetReason, msg string, ) metav1.Condition
NewCondition creates a new Condition object.
Types ¶
type GPUResetReconciler ¶
type GPUResetReconciler struct {
client.Client
Scheme *runtime.Scheme
// FieldIndexer enables client-side field indexing, allowing for mocking in tests.
FieldIndexer client.FieldIndexer
// Config holds controller-specific configuration.
Config *config.GPUResetControllerConfig
// NodeLock provides node-level locking across Janitor controllers
NodeLock distributedlock.NodeLock
LockNamespace string
// contains filtered or unexported fields
}
GPUResetReconciler reconciles a GPUReset object
func (*GPUResetReconciler) SetupWithManager ¶
func (r *GPUResetReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager. It configures watches for GPUResets and owned Jobs, and adds field indexers for efficient lookups of GPUResets by node name and Jobs by their controlling owner.
type MockCSPBehavior ¶
type MockCSPBehavior struct {
// SendTerminateSignal behavior
TerminateError error
TerminateRequestID string
// SendRebootSignal behavior
RebootError error
RebootRequestID string
// IsNodeReady behavior
IsNodeReadyError error
IsNodeReady bool
}
MockCSPBehavior defines how the mock CSP server should behave for each operation. This allows tests to configure success/failure per operation type.
func DefaultFailureBehavior ¶
func DefaultFailureBehavior() *MockCSPBehavior
DefaultFailureBehavior returns a MockCSPBehavior configured for all operations to fail.
func DefaultSuccessBehavior ¶
func DefaultSuccessBehavior() *MockCSPBehavior
DefaultSuccessBehavior returns a MockCSPBehavior configured for all operations to succeed.
type MockCSPServer ¶
type MockCSPServer struct {
cspv1alpha1.UnimplementedCSPProviderServiceServer
// contains filtered or unexported fields
}
MockCSPServer is a configurable mock implementation of CSPProviderServiceServer. Behavior can be changed at runtime via SetBehavior for per-test configuration.
func NewMockCSPServer ¶
func NewMockCSPServer() *MockCSPServer
NewMockCSPServer creates a new MockCSPServer with default success behavior.
func (*MockCSPServer) IsNodeReady ¶
func (s *MockCSPServer) IsNodeReady( ctx context.Context, req *cspv1alpha1.IsNodeReadyRequest, ) (*cspv1alpha1.IsNodeReadyResponse, error)
func (*MockCSPServer) SendRebootSignal ¶
func (s *MockCSPServer) SendRebootSignal( ctx context.Context, req *cspv1alpha1.SendRebootSignalRequest, ) (*cspv1alpha1.SendRebootSignalResponse, error)
func (*MockCSPServer) SendTerminateSignal ¶
func (s *MockCSPServer) SendTerminateSignal( ctx context.Context, req *cspv1alpha1.SendTerminateSignalRequest, ) (*cspv1alpha1.SendTerminateSignalResponse, error)
func (*MockCSPServer) SetBehavior ¶
func (s *MockCSPServer) SetBehavior(behavior *MockCSPBehavior)
SetBehavior updates the mock server's behavior. This is thread-safe and can be called from within tests to change behavior between reconciliations.
func (*MockCSPServer) SetFailure ¶
func (s *MockCSPServer) SetFailure()
SetFailure configures the server to fail on all operations.
func (*MockCSPServer) SetNodeReady ¶
func (s *MockCSPServer) SetNodeReady(ready bool)
SetNodeReady configures the IsNodeReady response.
func (*MockCSPServer) SetNodeReadyError ¶
func (s *MockCSPServer) SetNodeReadyError(err error)
SetNodeReadyError configures IsNodeReady to return an error.
func (*MockCSPServer) SetRebootFailure ¶
func (s *MockCSPServer) SetRebootFailure(err error)
SetRebootFailure configures only reboot operations to fail.
func (*MockCSPServer) SetRebootSuccess ¶
func (s *MockCSPServer) SetRebootSuccess(requestID string)
SetRebootSuccess configures only reboot operations to succeed.
func (*MockCSPServer) SetSuccess ¶
func (s *MockCSPServer) SetSuccess()
SetSuccess configures the server to succeed on all operations.
func (*MockCSPServer) SetTerminateFailure ¶
func (s *MockCSPServer) SetTerminateFailure(err error)
SetTerminateFailure configures only terminate operations to fail.
func (*MockCSPServer) SetTerminateSuccess ¶
func (s *MockCSPServer) SetTerminateSuccess(requestID string)
SetTerminateSuccess configures only terminate operations to succeed.
type MockCSPTestHelper ¶
type MockCSPTestHelper struct {
Server *MockCSPServer
Client cspv1alpha1.CSPProviderServiceClient
// contains filtered or unexported fields
}
MockCSPTestHelper manages the mock gRPC server lifecycle and provides a CSP client. This should be created once per test suite and used across all tests.
func NewMockCSPTestHelper ¶
func NewMockCSPTestHelper() *MockCSPTestHelper
NewMockCSPTestHelper creates and starts a mock CSP gRPC server. The server runs in the background and the returned helper provides a ready-to-use client. Call Stop() when done (typically in AfterSuite).
func (*MockCSPTestHelper) Stop ¶
func (h *MockCSPTestHelper) Stop()
Stop gracefully shuts down the mock gRPC server.
type RebootNodeReconciler ¶
type RebootNodeReconciler struct {
client.Client
Scheme *runtime.Scheme
Config *config.RebootNodeControllerConfig
NodeLock distributedlock.NodeLock
LockNamespace string
// contains filtered or unexported fields
}
RebootNodeReconciler reconciles a RebootNode object
func (*RebootNodeReconciler) Reconcile ¶
func (r *RebootNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state.
func (*RebootNodeReconciler) SetupWithManager ¶
func (r *RebootNodeReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type TerminateNodeReconciler ¶
type TerminateNodeReconciler struct {
client.Client
Scheme *runtime.Scheme
Config *config.TerminateNodeControllerConfig
NodeLock distributedlock.NodeLock
LockNamespace string
// contains filtered or unexported fields
}
TerminateNodeReconciler manages the terminate node operation.
func (*TerminateNodeReconciler) Reconcile ¶
func (r *TerminateNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Steps of the terminate node reconciliation loop: 1. Initialize conditions and start time. 2. Check if a terminate signal has already been sent. 3. Delete the node if it is not ready. 4. If node is ready, check for timeout. 5. If signal has not been sent, send it to the CSP instance. 6. Write status updates to the TerminateNode CR.
func (*TerminateNodeReconciler) SetupWithManager ¶
func (r *TerminateNodeReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.