Skip to content

Commit c7fd67c

Browse files
committed
++ review comments: last ones
Signed-off-by: Ivan Mikheykin <[email protected]>
1 parent a4265bf commit c7fd67c

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

images/virtualization-artifact/pkg/controller/dvcr-maintenance/condition/deployment.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,34 +45,27 @@ func NewMaintenanceCondition(reason dvcrdeploymentcondition.MaintenanceReason, m
4545
}
4646

4747
// UpdateMaintenanceCondition replaces or removes Maintenance condition from deployment status.
48-
// Return true if status was changed.
4948
func UpdateMaintenanceCondition(deploy *appsv1.Deployment, reason dvcrdeploymentcondition.MaintenanceReason, msgf string, args ...any) {
5049
if deploy == nil {
5150
return
5251
}
5352

5453
condition := NewMaintenanceCondition(reason, msgf, args...)
5554

56-
// Deploy has no conditions, create new slice.
57-
if len(deploy.Status.Conditions) == 0 {
58-
deploy.Status.Conditions = []appsv1.DeploymentCondition{condition}
59-
}
60-
6155
// Add or update existing condition.
62-
filteredConditions := make([]appsv1.DeploymentCondition, 0)
63-
existed := false
56+
filteredConditions := make([]appsv1.DeploymentCondition, 0, len(deploy.Status.Conditions))
57+
existing := false
6458
for _, cond := range deploy.Status.Conditions {
6559
if cond.Type == dvcrdeploymentcondition.MaintenanceType {
6660
if cond.Reason != condition.Reason || cond.Message != condition.Message {
6761
condition.LastTransitionTime = metav1.Now()
6862
}
6963
cond = condition
70-
existed = true
64+
existing = true
7165
}
72-
// Copy non-maintenance conditions.
7366
filteredConditions = append(filteredConditions, cond)
7467
}
75-
if !existed {
68+
if !existing {
7669
filteredConditions = append(filteredConditions, condition)
7770
}
7871
deploy.Status.Conditions = filteredConditions

images/virtualization-artifact/pkg/controller/dvcr-maintenance/internal/life_cycle.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ func NewLifeCycleHandler(client client.Client, dvcrService dvcrtypes.DVCRService
4545
}
4646

4747
func (h LifeCycleHandler) Handle(ctx context.Context, req reconcile.Request, deploy *appsv1.Deployment) (reconcile.Result, error) {
48+
if deploy == nil || deploy.GetDeletionTimestamp() != nil {
49+
return reconcile.Result{}, nil
50+
}
51+
4852
if req.Namespace == dvcrtypes.CronSourceNamespace && req.Name == dvcrtypes.CronSourceRunGC {
4953
dvcrcondition.UpdateMaintenanceCondition(deploy,
5054
dvcr_deployment_condition.InProgress,

0 commit comments

Comments
 (0)