Skip to content

Commit 623468b

Browse files
committed
fix(network): preserve hosts in cloud disruptions
Use DeepCopy before Status().Update() to prevent in-memory spec changes from being lost. Without this, cloud disruption hosts were cleared after the first chaos pod creation, causing subsequent pods to have no hosts injected. Jira: CHAOSPLT-1364
1 parent f9c5119 commit 623468b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

controllers/disruption_controller.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,10 @@ func (r *DisruptionReconciler) createChaosPods(ctx context.Context, instance *ch
701701
instance.Status.RunCount++
702702
r.log.Infow("incremented disruption run count", tagutil.RunCountKey, instance.Status.RunCount, tagutil.DisruptionNameKey, instance.Name)
703703

704-
// Update the status in the cluster
705-
if err := r.Client.Status().Update(ctx, instance); err != nil {
704+
// Update the status in the cluster using a deep copy to preserve in-memory spec changes
705+
// (such as cloud disruption hosts populated by UpdateHostsOnCloudDisruption)
706+
statusCopy := instance.DeepCopy()
707+
if err := r.Client.Status().Update(ctx, statusCopy); err != nil {
706708
return fmt.Errorf("error updating disruption status with run count: %w", err)
707709
}
708710
}

0 commit comments

Comments
 (0)