@@ -23,13 +23,11 @@ import (
2323 "sigs.k8s.io/controller-runtime/pkg/client"
2424
2525 "github.com/nvidia/nvsentinel/fault-remediation/pkg/annotation"
26- "github.com/nvidia/nvsentinel/fault-remediation/pkg/config"
2726)
2827
2928type CRStatusChecker struct {
30- client client.Client
31- remediationActions map [string ]config.MaintenanceResource
32- dryRun bool
29+ client client.Client
30+ dryRun bool
3331}
3432
3533type CRState string
@@ -43,39 +41,14 @@ const (
4341
4442func NewCRStatusChecker (
4543 client client.Client ,
46- remediationActions map [string ]config.MaintenanceResource ,
4744 dryRun bool ,
4845) * CRStatusChecker {
4946 return & CRStatusChecker {
50- client : client ,
51- remediationActions : remediationActions ,
52- dryRun : dryRun ,
47+ client : client ,
48+ dryRun : dryRun ,
5349 }
5450}
5551
56- // ShouldSkipCRCreation returns true if an existing CR should suppress creation of a new CR.
57- func (c * CRStatusChecker ) ShouldSkipCRCreation (ctx context.Context , actionName string , crName string ) bool {
58- state := c .GetCRState (ctx , actionName , crName )
59- return state == CRStateInProgress || state == CRStateSucceeded
60- }
61-
62- func (c * CRStatusChecker ) GetCRState (ctx context.Context , actionName string , crName string ) CRState {
63- resource , exists := c .remediationActions [actionName ]
64- if ! exists {
65- slog .ErrorContext (ctx , "No remediation configuration found for action" , "action" , actionName )
66- return CRStateNotFound
67- }
68-
69- resourceRef := annotation.MaintenanceResourceReference {
70- Namespace : resource .Namespace ,
71- Version : resource .Version ,
72- ApiGroup : resource .ApiGroup ,
73- Kind : resource .Kind ,
74- }
75-
76- return c .GetCRStateForReference (ctx , crName , resourceRef , resource .CompleteConditionType )
77- }
78-
7952func (c * CRStatusChecker ) GetCRStateForReference (
8053 ctx context.Context ,
8154 crName string ,
@@ -110,10 +83,6 @@ func (c *CRStatusChecker) GetCRStateForReference(
11083 return c .checkConditionType (obj , completeConditionType )
11184}
11285
113- func (c * CRStatusChecker ) checkCondition (obj * unstructured.Unstructured , resource config.MaintenanceResource ) CRState {
114- return c .checkConditionType (obj , resource .CompleteConditionType )
115- }
116-
11786func (c * CRStatusChecker ) checkConditionType (obj * unstructured.Unstructured , completeConditionType string ) CRState {
11887 status , found , err := unstructured .NestedMap (obj .Object , "status" )
11988 if err != nil || ! found {
0 commit comments