Skip to content

Commit

Permalink
fix(vm): fix conditions with empty status (#502)
Browse files Browse the repository at this point in the history
fix conditions with empty status
---------
Signed-off-by: yaroslavborbat <[email protected]>
  • Loading branch information
yaroslavborbat authored Nov 6, 2024
1 parent 4f9c1ba commit 083032e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,17 @@ func rewriteObject(obj client.Object) {
conds = snap.Status.Conditions
}

rewriteEmptyReason(conds)
rewriteConditions(conds)
}

func rewriteEmptyReason(conds []metav1.Condition) {
func rewriteConditions(conds []metav1.Condition) {
for i := range conds {
if conds[i].Reason == "" {
conds[i].Reason = conditions.ReasonUnknown.String()
}
if conds[i].Status == "" {
conds[i].Status = metav1.ConditionUnknown
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ func (h *FilesystemHandler) Handle(ctx context.Context, s state.VirtualMachineSt
return reconcile.Result{}, err
}

cb := conditions.NewConditionBuilder(vmcondition.TypeFilesystemReady).Generation(changed.GetGeneration())
cb := conditions.NewConditionBuilder(vmcondition.TypeFilesystemReady).
Status(metav1.ConditionUnknown).
Generation(changed.GetGeneration())

defer func() { conditions.SetCondition(cb, &changed.Status.Conditions) }()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ func (h *SizePolicyHandler) Handle(ctx context.Context, s state.VirtualMachineSt
changed := s.VirtualMachine().Changed()

cb := conditions.NewConditionBuilder(vmcondition.TypeSizingPolicyMatched).
Status(metav1.ConditionUnknown).
Generation(current.GetGeneration())

defer func() { conditions.SetCondition(cb, &changed.Status.Conditions) }()

addAllUnknown(changed, vmcondition.TypeSizingPolicyMatched)

if isDeletion(current) {
return reconcile.Result{}, nil
}
Expand Down

0 comments on commit 083032e

Please sign in to comment.