Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
7d3c67f0
Unverified
Commit
7d3c67f0
authored
Jan 28, 2026
by
hhzhang16
Committed by
GitHub
Jan 28, 2026
Browse files
feat: use consts instead of hardcoded string for statuses (#5696)
Signed-off-by:
Hannah Zhang
<
hannahz@nvidia.com
>
parent
36ce39bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
66 deletions
+66
-66
deploy/operator/internal/controller/dynamographdeployment_controller.go
...r/internal/controller/dynamographdeployment_controller.go
+9
-9
deploy/operator/internal/controller/dynamographdeployment_controller_test.go
...ernal/controller/dynamographdeployment_controller_test.go
+9
-9
deploy/operator/internal/controller/dynamographdeploymentrequest_controller.go
...nal/controller/dynamographdeploymentrequest_controller.go
+35
-35
deploy/operator/internal/controller/dynamographdeploymentrequest_controller_test.go
...ontroller/dynamographdeploymentrequest_controller_test.go
+13
-13
No files found.
deploy/operator/internal/controller/dynamographdeployment_controller.go
View file @
7d3c67f0
...
...
@@ -61,9 +61,9 @@ type Reason string
type
Message
string
const
(
Failed
State
State
=
"failed"
Ready
State
State
=
"successful"
Pending
State
State
=
"pending"
DGDState
Failed
State
=
"failed"
DGDState
Ready
State
=
"successful"
DGDState
Pending
State
=
"pending"
)
type
etcdStorage
interface
{
...
...
@@ -109,7 +109,7 @@ func (r *DynamoGraphDeploymentReconciler) Reconcile(ctx context.Context, req ctr
reason
:=
Reason
(
"undefined"
)
message
:=
Message
(
""
)
state
:=
Pending
State
state
:=
DGDState
Pending
// retrieve the CRD
dynamoDeployment
:=
&
nvidiacomv1alpha1
.
DynamoGraphDeployment
{}
if
err
=
r
.
Get
(
ctx
,
req
.
NamespacedName
,
dynamoDeployment
);
err
!=
nil
{
...
...
@@ -124,14 +124,14 @@ func (r *DynamoGraphDeploymentReconciler) Reconcile(ctx context.Context, req ctr
}
if
err
!=
nil
{
state
=
Failed
State
state
=
DGDState
Failed
message
=
Message
(
err
.
Error
())
logger
.
Error
(
err
,
"Reconciliation failed"
)
}
dynamoDeployment
.
SetState
(
string
(
state
))
readyStatus
:=
metav1
.
ConditionFalse
if
state
==
Ready
State
{
if
state
==
DGDState
Ready
{
readyStatus
=
metav1
.
ConditionTrue
}
...
...
@@ -173,7 +173,7 @@ func (r *DynamoGraphDeploymentReconciler) Reconcile(ctx context.Context, req ctr
logger
.
Error
(
validationErr
,
"DynamoGraphDeployment validation failed, refusing to reconcile"
)
// Set validation error state and reason (defer will update status)
state
=
Failed
State
state
=
DGDState
Failed
reason
=
Reason
(
"ValidationFailed"
)
message
=
Message
(
fmt
.
Sprintf
(
"Validation failed: %v"
,
validationErr
))
...
...
@@ -903,14 +903,14 @@ func (r *DynamoGraphDeploymentReconciler) checkResourcesReadiness(resources []Re
if
len
(
notReadyResources
)
==
0
{
return
ReconcileResult
{
State
:
Ready
State
,
State
:
DGDState
Ready
,
Reason
:
"all_resources_are_ready"
,
Message
:
Message
(
"All resources are ready"
),
ServiceStatus
:
serviceStatuses
,
}
}
return
ReconcileResult
{
State
:
Pending
State
,
State
:
DGDState
Pending
,
Reason
:
"some_resources_are_not_ready"
,
Message
:
Message
(
fmt
.
Sprintf
(
"Resources not ready: %s"
,
strings
.
Join
(
notReadyReasons
,
"; "
))),
ServiceStatus
:
serviceStatuses
,
...
...
deploy/operator/internal/controller/dynamographdeployment_controller_test.go
View file @
7d3c67f0
...
...
@@ -405,7 +405,7 @@ func Test_reconcileGroveResources(t *testing.T) {
},
},
wantReconcileResult
:
ReconcileResult
{
State
:
Ready
State
,
State
:
DGDState
Ready
,
Reason
:
"all_resources_are_ready"
,
Message
:
"All resources are ready"
,
ServiceStatus
:
map
[
string
]
v1alpha1
.
ServiceReplicaStatus
{
...
...
@@ -467,7 +467,7 @@ func Test_reconcileGroveResources(t *testing.T) {
},
},
wantReconcileResult
:
ReconcileResult
{
State
:
Pending
State
,
State
:
DGDState
Pending
,
Reason
:
"some_resources_are_not_ready"
,
Message
:
Message
(
"Resources not ready: test-dgd: podclique/test-dgd-0-decode: desired=2, ready=1"
),
ServiceStatus
:
map
[
string
]
v1alpha1
.
ServiceReplicaStatus
{
...
...
@@ -542,7 +542,7 @@ func Test_reconcileGroveResources(t *testing.T) {
},
},
wantReconcileResult
:
ReconcileResult
{
State
:
Ready
State
,
State
:
DGDState
Ready
,
Reason
:
"all_resources_are_ready"
,
Message
:
"All resources are ready"
,
ServiceStatus
:
map
[
string
]
v1alpha1
.
ServiceReplicaStatus
{
...
...
@@ -614,7 +614,7 @@ func Test_reconcileGroveResources(t *testing.T) {
},
},
wantReconcileResult
:
ReconcileResult
{
State
:
Pending
State
,
State
:
DGDState
Pending
,
Reason
:
"some_resources_are_not_ready"
,
Message
:
Message
(
"Resources not ready: test-dgd: pcsg/test-dgd-0-aggregated: desired=2, available=1"
),
ServiceStatus
:
map
[
string
]
v1alpha1
.
ServiceReplicaStatus
{
...
...
@@ -1402,7 +1402,7 @@ func Test_reconcileDynamoComponentsDeployments(t *testing.T) {
},
},
wantReconcileResult
:
ReconcileResult
{
State
:
Ready
State
,
State
:
DGDState
Ready
,
Reason
:
"all_resources_are_ready"
,
Message
:
"All resources are ready"
,
ServiceStatus
:
map
[
string
]
v1alpha1
.
ServiceReplicaStatus
{
...
...
@@ -1462,7 +1462,7 @@ func Test_reconcileDynamoComponentsDeployments(t *testing.T) {
},
},
wantReconcileResult
:
ReconcileResult
{
State
:
Pending
State
,
State
:
DGDState
Pending
,
Reason
:
"some_resources_are_not_ready"
,
Message
:
"Resources not ready: test-dgd-frontend: Component deployment not ready - Available condition not true"
,
ServiceStatus
:
map
[
string
]
v1alpha1
.
ServiceReplicaStatus
{
...
...
@@ -1592,7 +1592,7 @@ func Test_reconcileDynamoComponentsDeployments(t *testing.T) {
},
},
wantReconcileResult
:
ReconcileResult
{
State
:
Ready
State
,
State
:
DGDState
Ready
,
Reason
:
"all_resources_are_ready"
,
Message
:
"All resources are ready"
,
ServiceStatus
:
map
[
string
]
v1alpha1
.
ServiceReplicaStatus
{
...
...
@@ -1738,7 +1738,7 @@ func Test_reconcileDynamoComponentsDeployments(t *testing.T) {
},
},
wantReconcileResult
:
ReconcileResult
{
State
:
Pending
State
,
State
:
DGDState
Pending
,
Reason
:
"some_resources_are_not_ready"
,
Message
:
"Resources not ready: test-dgd-decode: Component deployment not ready - Available condition not true"
,
ServiceStatus
:
map
[
string
]
v1alpha1
.
ServiceReplicaStatus
{
...
...
@@ -1849,7 +1849,7 @@ func Test_reconcileDynamoComponentsDeployments(t *testing.T) {
},
},
wantReconcileResult
:
ReconcileResult
{
State
:
Pending
State
,
State
:
DGDState
Pending
,
Reason
:
"some_resources_are_not_ready"
,
Message
:
"Resources not ready: test-dgd-decode: Component deployment not ready - Available condition not true; test-dgd-frontend: Component deployment not ready - Available condition not true"
,
ServiceStatus
:
map
[
string
]
v1alpha1
.
ServiceReplicaStatus
{
...
...
deploy/operator/internal/controller/dynamographdeploymentrequest_controller.go
View file @
7d3c67f0
...
...
@@ -52,14 +52,14 @@ import (
)
const
(
//
S
tate constants
StateEmpty
=
""
StatePending
=
"Pending"
StateProfiling
=
"Profiling"
StateDeploying
=
"Deploying"
StateReady
=
"Ready"
StateDeploymentDeleted
=
"DeploymentDeleted"
StateFailed
=
"Failed"
//
DGDR s
tate constants
DGDR
StateEmpty
=
""
DGDR
StatePending
=
"Pending"
DGDR
StateProfiling
=
"Profiling"
DGDR
StateDeploying
=
"Deploying"
DGDR
StateReady
=
"Ready"
DGDR
StateDeploymentDeleted
=
"DeploymentDeleted"
DGDR
StateFailed
=
"Failed"
// Condition types
ConditionTypeValidation
=
"Validation"
...
...
@@ -297,8 +297,8 @@ func (r *DynamoGraphDeploymentRequestReconciler) Reconcile(ctx context.Context,
// Check for spec changes (immutability enforcement)
if
dgdr
.
Status
.
ObservedGeneration
>
0
&&
dgdr
.
Status
.
ObservedGeneration
!=
dgdr
.
Generation
{
// Spec changed after initial processing
if
dgdr
.
Status
.
State
==
StateProfiling
||
dgdr
.
Status
.
State
==
StateDeploying
||
dgdr
.
Status
.
State
==
StateReady
||
dgdr
.
Status
.
State
==
StateDeploymentDeleted
{
if
dgdr
.
Status
.
State
==
DGDR
StateProfiling
||
dgdr
.
Status
.
State
==
DGDR
StateDeploying
||
dgdr
.
Status
.
State
==
DGDR
StateReady
||
dgdr
.
Status
.
State
==
DGDR
StateDeploymentDeleted
{
logger
.
Info
(
"Spec change detected in immutable state"
,
"state"
,
dgdr
.
Status
.
State
,
"observedGeneration"
,
dgdr
.
Status
.
ObservedGeneration
,
...
...
@@ -314,23 +314,23 @@ func (r *DynamoGraphDeploymentRequestReconciler) Reconcile(ctx context.Context,
}
// State machine: handle different states
switch
dgdr
.
Status
.
State
{
case
StateEmpty
:
case
DGDR
StateEmpty
:
return
r
.
handleInitialState
(
ctx
,
dgdr
)
case
StatePending
:
case
DGDR
StatePending
:
return
r
.
handlePendingState
(
ctx
,
dgdr
)
case
StateProfiling
:
case
DGDR
StateProfiling
:
return
r
.
handleProfilingState
(
ctx
,
dgdr
)
case
StateDeploying
:
case
DGDR
StateDeploying
:
return
r
.
handleDeployingState
(
ctx
,
dgdr
)
case
StateReady
:
case
DGDR
StateReady
:
return
r
.
handleReadyState
(
ctx
,
dgdr
)
case
StateDeploymentDeleted
:
case
DGDR
StateDeploymentDeleted
:
return
r
.
handleDeploymentDeletedState
(
ctx
,
dgdr
)
case
StateFailed
:
case
DGDR
StateFailed
:
return
r
.
handleFailedState
(
ctx
,
dgdr
)
default
:
logger
.
Info
(
"Unknown state"
,
"state"
,
dgdr
.
Status
.
State
)
return
r
.
updateStateAndRequeue
(
ctx
,
dgdr
,
StateFailed
,
MessageInvalidState
)
return
r
.
updateStateAndRequeue
(
ctx
,
dgdr
,
DGDR
StateFailed
,
MessageInvalidState
)
}
}
...
...
@@ -342,7 +342,7 @@ func (r *DynamoGraphDeploymentRequestReconciler) handleInitialState(ctx context.
// Validate the spec
if
err
:=
r
.
validateSpec
(
ctx
,
dgdr
);
err
!=
nil
{
r
.
Recorder
.
Event
(
dgdr
,
corev1
.
EventTypeWarning
,
EventReasonValidationFailed
,
err
.
Error
())
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
StateFailed
,
ConditionTypeValidation
,
metav1
.
ConditionFalse
,
EventReasonValidationFailed
,
err
.
Error
())
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
DGDR
StateFailed
,
ConditionTypeValidation
,
metav1
.
ConditionFalse
,
EventReasonValidationFailed
,
err
.
Error
())
}
// Set observedGeneration to track the spec we're processing
...
...
@@ -353,7 +353,7 @@ func (r *DynamoGraphDeploymentRequestReconciler) handleInitialState(ctx context.
// Initialize status
r
.
Recorder
.
Event
(
dgdr
,
corev1
.
EventTypeNormal
,
EventReasonInitialized
,
MessageInitialized
)
return
r
.
updateStateAndRequeue
(
ctx
,
dgdr
,
StatePending
,
MessageInitialized
)
return
r
.
updateStateAndRequeue
(
ctx
,
dgdr
,
DGDR
StatePending
,
MessageInitialized
)
}
// handlePendingState starts the profiling process
...
...
@@ -364,7 +364,7 @@ func (r *DynamoGraphDeploymentRequestReconciler) handlePendingState(ctx context.
// Create profiling job (online or AIC)
if
err
:=
r
.
createProfilingJob
(
ctx
,
dgdr
);
err
!=
nil
{
r
.
Recorder
.
Event
(
dgdr
,
corev1
.
EventTypeWarning
,
EventReasonProfilingJobFailed
,
err
.
Error
())
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
StateFailed
,
ConditionTypeProfiling
,
metav1
.
ConditionFalse
,
MessageJobCreationFailed
,
err
.
Error
())
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
DGDR
StateFailed
,
ConditionTypeProfiling
,
metav1
.
ConditionFalse
,
MessageJobCreationFailed
,
err
.
Error
())
}
// Record event with appropriate message
...
...
@@ -375,7 +375,7 @@ func (r *DynamoGraphDeploymentRequestReconciler) handlePendingState(ctx context.
}
// Update to Profiling state with Running status
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
StateProfiling
,
ConditionTypeProfiling
,
metav1
.
ConditionFalse
,
"ProfilingRunning"
,
MessageProfilingInProgress
)
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
DGDR
StateProfiling
,
ConditionTypeProfiling
,
metav1
.
ConditionFalse
,
"ProfilingRunning"
,
MessageProfilingInProgress
)
}
// handleProfilingState monitors profiling progress and generates spec when complete
...
...
@@ -389,7 +389,7 @@ func (r *DynamoGraphDeploymentRequestReconciler) handleProfilingState(ctx contex
if
err
!=
nil
{
r
.
Recorder
.
Event
(
dgdr
,
corev1
.
EventTypeWarning
,
MessageProfilingCheckFailed
,
err
.
Error
())
// Job failed - transition to Failed state
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
StateFailed
,
ConditionTypeProfiling
,
metav1
.
ConditionFalse
,
"ProfilingFailed"
,
err
.
Error
())
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
DGDR
StateFailed
,
ConditionTypeProfiling
,
metav1
.
ConditionFalse
,
"ProfilingFailed"
,
err
.
Error
())
}
if
!
completed
{
...
...
@@ -410,7 +410,7 @@ func (r *DynamoGraphDeploymentRequestReconciler) handleProfilingState(ctx contex
// Retrieve profiling results and generate spec
if
err
:=
r
.
generateDGDSpec
(
ctx
,
dgdr
);
err
!=
nil
{
r
.
Recorder
.
Event
(
dgdr
,
corev1
.
EventTypeWarning
,
MessageGenerationFailed
,
err
.
Error
())
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
StateFailed
,
ConditionTypeSpecGenerated
,
metav1
.
ConditionFalse
,
MessageGenerationFailed
,
err
.
Error
())
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
DGDR
StateFailed
,
ConditionTypeSpecGenerated
,
metav1
.
ConditionFalse
,
MessageGenerationFailed
,
err
.
Error
())
}
// Record spec generation event
...
...
@@ -432,11 +432,11 @@ func (r *DynamoGraphDeploymentRequestReconciler) handleProfilingState(ctx contex
// If autoApply is enabled, transition to Deploying state
if
dgdr
.
Spec
.
AutoApply
{
logger
.
Info
(
"AutoApply enabled, transitioning to Deploying state"
)
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
StateDeploying
,
ConditionTypeSpecGenerated
,
metav1
.
ConditionTrue
,
EventReasonSpecGenerated
,
MessageSpecGenerated
)
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
DGDR
StateDeploying
,
ConditionTypeSpecGenerated
,
metav1
.
ConditionTrue
,
EventReasonSpecGenerated
,
MessageSpecGenerated
)
}
// Otherwise, transition to Ready state
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
StateReady
,
ConditionTypeSpecGenerated
,
metav1
.
ConditionTrue
,
EventReasonSpecGenerated
,
MessageSpecAvailable
)
return
r
.
updateStateWithCondition
(
ctx
,
dgdr
,
DGDR
StateReady
,
ConditionTypeSpecGenerated
,
metav1
.
ConditionTrue
,
EventReasonSpecGenerated
,
MessageSpecAvailable
)
}
// handleReadyState handles DGDR in Ready state
...
...
@@ -469,11 +469,11 @@ func (r *DynamoGraphDeploymentRequestReconciler) handleReadyState(ctx context.Co
dgdr
.
Status
.
Deployment
.
State
=
dgd
.
Status
.
State
// Check if DGD degraded from Ready
if
dgd
.
Status
.
State
!=
"
Ready
"
{
if
dgd
.
Status
.
State
!=
string
(
DGDState
Ready
)
{
logger
.
Info
(
"DGD degraded, transitioning back to Deploying"
,
"dgdState"
,
dgd
.
Status
.
State
)
dgdr
.
Status
.
State
=
StateDeploying
dgdr
.
Status
.
State
=
DGDR
StateDeploying
r
.
Recorder
.
Event
(
dgdr
,
corev1
.
EventTypeWarning
,
EventReasonDeploymentDegraded
,
fmt
.
Sprintf
(
MessageDeploymentDegraded
,
dgd
.
Name
,
dgd
.
Status
.
State
))
...
...
@@ -497,7 +497,7 @@ func (r *DynamoGraphDeploymentRequestReconciler) handleDeployingState(ctx contex
if
!
dgdr
.
Spec
.
AutoApply
{
// Shouldn't be in this state without autoApply
logger
.
Info
(
"AutoApply not enabled, transitioning to Ready"
)
dgdr
.
Status
.
State
=
StateReady
dgdr
.
Status
.
State
=
DGDR
StateReady
return
ctrl
.
Result
{},
r
.
Status
()
.
Update
(
ctx
,
dgdr
)
}
...
...
@@ -526,9 +526,9 @@ func (r *DynamoGraphDeploymentRequestReconciler) handleDeployingState(ctx contex
dgdr
.
Status
.
Deployment
.
State
=
dgd
.
Status
.
State
// Check if DGD is Ready
if
dgd
.
Status
.
State
==
"
Ready
"
{
if
dgd
.
Status
.
State
==
string
(
DGDState
Ready
)
{
logger
.
Info
(
"DGD is Ready, transitioning to Ready state"
)
dgdr
.
Status
.
State
=
StateReady
dgdr
.
Status
.
State
=
DGDR
StateReady
r
.
Recorder
.
Event
(
dgdr
,
corev1
.
EventTypeNormal
,
EventReasonDeploymentReady
,
fmt
.
Sprintf
(
MessageDeploymentReady
,
dgd
.
Name
))
...
...
@@ -556,8 +556,8 @@ func (r *DynamoGraphDeploymentRequestReconciler) handleDGDDeleted(ctx context.Co
logger
:=
log
.
FromContext
(
ctx
)
logger
.
Info
(
"DGD was deleted by user, transitioning to DeploymentDeleted state"
)
dgdr
.
Status
.
State
=
StateDeploymentDeleted
dgdr
.
Status
.
Deployment
.
State
=
"
Deleted
"
dgdr
.
Status
.
State
=
DGDR
StateDeploymentDeleted
dgdr
.
Status
.
Deployment
.
State
=
""
r
.
Recorder
.
Event
(
dgdr
,
corev1
.
EventTypeWarning
,
EventReasonDeploymentDeleted
,
fmt
.
Sprintf
(
MessageDeploymentDeleted
,
dgdr
.
Status
.
Deployment
.
Name
))
...
...
@@ -669,7 +669,7 @@ func (r *DynamoGraphDeploymentRequestReconciler) createDGD(ctx context.Context,
dgdr
.
Status
.
Deployment
=
&
nvidiacomv1alpha1
.
DeploymentStatus
{
Name
:
dgdName
,
Namespace
:
dgdNamespace
,
State
:
"
Pending
"
,
State
:
string
(
DGDState
Pending
)
,
Created
:
true
,
}
return
ctrl
.
Result
{},
r
.
Status
()
.
Update
(
ctx
,
dgdr
)
...
...
@@ -682,7 +682,7 @@ func (r *DynamoGraphDeploymentRequestReconciler) createDGD(ctx context.Context,
dgdr
.
Status
.
Deployment
=
&
nvidiacomv1alpha1
.
DeploymentStatus
{
Name
:
dgdName
,
Namespace
:
dgdNamespace
,
State
:
"
Pending
"
,
State
:
string
(
DGDState
Pending
)
,
Created
:
true
,
}
...
...
deploy/operator/internal/controller/dynamographdeploymentrequest_controller_test.go
View file @
7d3c67f0
...
...
@@ -140,7 +140,7 @@ var _ = Describe("DynamoGraphDeploymentRequest Controller", func() {
var
updated
nvidiacomv1alpha1
.
DynamoGraphDeploymentRequest
_
=
k8sClient
.
Get
(
ctx
,
types
.
NamespacedName
{
Name
:
dgdrName
,
Namespace
:
namespace
},
&
updated
)
return
updated
.
Status
.
State
},
timeout
,
interval
)
.
Should
(
Equal
(
StatePending
))
},
timeout
,
interval
)
.
Should
(
Equal
(
DGDR
StatePending
))
// Verify observedGeneration is set
var
updated
nvidiacomv1alpha1
.
DynamoGraphDeploymentRequest
...
...
@@ -190,7 +190,7 @@ var _ = Describe("DynamoGraphDeploymentRequest Controller", func() {
var
updated
nvidiacomv1alpha1
.
DynamoGraphDeploymentRequest
_
=
k8sClient
.
Get
(
ctx
,
types
.
NamespacedName
{
Name
:
dgdrName
,
Namespace
:
namespace
},
&
updated
)
return
updated
.
Status
.
State
},
timeout
,
interval
)
.
Should
(
Equal
(
StatePending
))
},
timeout
,
interval
)
.
Should
(
Equal
(
DGDR
StatePending
))
})
})
...
...
@@ -424,7 +424,7 @@ var _ = Describe("DynamoGraphDeploymentRequest Controller", func() {
defer
func
()
{
_
=
k8sClient
.
Delete
(
ctx
,
dgdr
)
}()
// Update status to Profiling using Status subresource
dgdr
.
Status
.
State
=
StateProfiling
dgdr
.
Status
.
State
=
DGDR
StateProfiling
Expect
(
k8sClient
.
Status
()
.
Update
(
ctx
,
dgdr
))
.
Should
(
Succeed
())
// Create completed profiling job
...
...
@@ -499,7 +499,7 @@ spec:
Expect
(
updated
.
Status
.
GeneratedDeployment
)
.
NotTo
(
BeNil
())
// Verify state transitioned to Ready (since autoApply is false by default)
Expect
(
updated
.
Status
.
State
)
.
Should
(
Equal
(
StateReady
))
Expect
(
updated
.
Status
.
State
)
.
Should
(
Equal
(
DGDR
StateReady
))
})
})
...
...
@@ -539,7 +539,7 @@ spec:
defer
func
()
{
_
=
k8sClient
.
Delete
(
ctx
,
dgdr
)
}()
// Update status to Profiling using Status subresource
dgdr
.
Status
.
State
=
StateProfiling
dgdr
.
Status
.
State
=
DGDR
StateProfiling
Expect
(
k8sClient
.
Status
()
.
Update
(
ctx
,
dgdr
))
.
Should
(
Succeed
())
// Create completed profiling job
...
...
@@ -609,7 +609,7 @@ spec:
// Get updated DGDR and check state is Deploying
var
updated
nvidiacomv1alpha1
.
DynamoGraphDeploymentRequest
Expect
(
k8sClient
.
Get
(
ctx
,
types
.
NamespacedName
{
Name
:
dgdrName
,
Namespace
:
namespace
},
&
updated
))
.
Should
(
Succeed
())
Expect
(
updated
.
Status
.
State
)
.
Should
(
Equal
(
StateDeploying
))
Expect
(
updated
.
Status
.
State
)
.
Should
(
Equal
(
DGDR
StateDeploying
))
// Reconcile again to create DGD
_
,
err
=
reconciler
.
Reconcile
(
ctx
,
reconcile
.
Request
{
...
...
@@ -680,7 +680,7 @@ spec:
observedGeneration
:=
current
.
Status
.
ObservedGeneration
// Manually set state to Profiling to simulate in-progress profiling
current
.
Status
.
State
=
StateProfiling
current
.
Status
.
State
=
DGDR
StateProfiling
Expect
(
k8sClient
.
Status
()
.
Update
(
ctx
,
&
current
))
.
Should
(
Succeed
())
// Try to modify spec
...
...
@@ -702,7 +702,7 @@ spec:
Expect
(
k8sClient
.
Get
(
ctx
,
types
.
NamespacedName
{
Name
:
dgdrName
,
Namespace
:
namespace
},
&
current
))
.
Should
(
Succeed
())
Expect
(
current
.
Generation
)
.
Should
(
BeNumerically
(
">"
,
initialGeneration
))
Expect
(
current
.
Status
.
ObservedGeneration
)
.
Should
(
Equal
(
observedGeneration
))
Expect
(
current
.
Status
.
State
)
.
Should
(
Equal
(
StateProfiling
))
// State unchanged
Expect
(
current
.
Status
.
State
)
.
Should
(
Equal
(
DGDR
StateProfiling
))
// State unchanged
// Verify event was recorded
Eventually
(
func
()
bool
{
...
...
@@ -752,12 +752,12 @@ spec:
defer
func
()
{
_
=
k8sClient
.
Delete
(
ctx
,
dgdr
)
}()
// Update status to Ready with Deployment info using Status subresource
dgdr
.
Status
.
State
=
StateReady
dgdr
.
Status
.
State
=
DGDR
StateReady
dgdr
.
Status
.
Deployment
=
&
nvidiacomv1alpha1
.
DeploymentStatus
{
Name
:
"test-dgd-to-delete"
,
Namespace
:
namespace
,
Created
:
true
,
State
:
"
Ready
"
,
State
:
DGDRState
Ready
,
}
Expect
(
k8sClient
.
Status
()
.
Update
(
ctx
,
dgdr
))
.
Should
(
Succeed
())
...
...
@@ -770,7 +770,7 @@ spec:
// Get updated DGDR and check state transitioned to DeploymentDeleted
var
updated
nvidiacomv1alpha1
.
DynamoGraphDeploymentRequest
Expect
(
k8sClient
.
Get
(
ctx
,
types
.
NamespacedName
{
Name
:
dgdrName
,
Namespace
:
namespace
},
&
updated
))
.
Should
(
Succeed
())
Expect
(
updated
.
Status
.
State
)
.
Should
(
Equal
(
StateDeploymentDeleted
))
Expect
(
updated
.
Status
.
State
)
.
Should
(
Equal
(
DGDR
StateDeploymentDeleted
))
})
})
})
...
...
@@ -1249,7 +1249,7 @@ var _ = Describe("DGDR Error Handling", func() {
defer
func
()
{
_
=
k8sClient
.
Delete
(
ctx
,
dgdr
)
}()
// Set status to Profiling
dgdr
.
Status
.
State
=
StateProfiling
dgdr
.
Status
.
State
=
DGDR
StateProfiling
Expect
(
k8sClient
.
Status
()
.
Update
(
ctx
,
dgdr
))
.
Should
(
Succeed
())
// Create failed job
...
...
@@ -1331,7 +1331,7 @@ var _ = Describe("DGDR Error Handling", func() {
// Verify DGDR transitioned to Failed state
var
updated
nvidiacomv1alpha1
.
DynamoGraphDeploymentRequest
Expect
(
k8sClient
.
Get
(
ctx
,
types
.
NamespacedName
{
Name
:
dgdrName
,
Namespace
:
namespace
},
&
updated
))
.
Should
(
Succeed
())
Expect
(
updated
.
Status
.
State
)
.
Should
(
Equal
(
StateFailed
))
Expect
(
updated
.
Status
.
State
)
.
Should
(
Equal
(
DGDR
StateFailed
))
// Verify error condition contains detailed error
condition
:=
meta
.
FindStatusCondition
(
updated
.
Status
.
Conditions
,
ConditionTypeProfiling
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment