Skip to content

Commit 25b9646

Browse files
notandyfwiesel
authored andcommitted
EvictionController: Fix potential panic on header access
Use Header.Get() instead of direct array indexing to safely access X-Openstack-Request-Id header. This prevents panic if the header is missing or empty.
1 parent 865b456 commit 25b9646

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

internal/controller/eviction_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ func (r *EvictionReconciler) liveMigrate(ctx context.Context, uuid string, evict
400400
return err
401401
}
402402

403-
log.Info("Live migrating server", "server", uuid, "source", eviction.Spec.Hypervisor, "X-Openstack-Request-Id", res.Header["X-Openstack-Request-Id"][0])
403+
log.Info("Live migrating server", "server", uuid, "source", eviction.Spec.Hypervisor, "X-Openstack-Request-Id", res.Header.Get("X-Openstack-Request-Id"))
404404
return nil
405405
}
406406

@@ -419,7 +419,7 @@ func (r *EvictionReconciler) coldMigrate(ctx context.Context, uuid string, evict
419419
return err
420420
}
421421

422-
log.Info("Cold-migrating server", "server", uuid, "source", eviction.Spec.Hypervisor, "X-Openstack-Request-Id", res.Header["X-Openstack-Request-Id"][0])
422+
log.Info("Cold-migrating server", "server", uuid, "source", eviction.Spec.Hypervisor, "X-Openstack-Request-Id", res.Header.Get("X-Openstack-Request-Id"))
423423
return nil
424424
}
425425

0 commit comments

Comments
 (0)