What happened:
waypointCache.DeleteService() removes the waypoint entry but leaves references to it in serviceToWaypoint and workloadToWaypoint.
If one of those resources is updated afterwards, the controller calls deleteService() or deleteWorkload() on a missing map entry and panics.
What you expected to happen:
Deleting a waypoint should clean up its associations without crashing on later updates.
How to reproduce it (as minimally and precisely as possible):
This unit test reproduces it:
func TestDeleteWaypointBeforeAssociatedService(t *testing.T) {
serviceCache := NewServiceCache()
cache := NewWaypointCache(serviceCache)
waypoint := "default/waypoint.default.svc.cluster.local"
svc := common.CreateFakeService("app", "10.240.10.1", waypoint, nil)
cache.AddOrUpdateService(svc)
cache.DeleteService(waypoint)
svc.Waypoint = nil
cache.AddOrUpdateService(svc) // nil pointer panic
}
The same state can happen when the waypoint service is removed before updates for its associated services or workloads arrive.
Anything else we need to know?:
DeleteService() guards the lookup when removing an associated service, but the add/update paths dereference it directly.
Environment:
Kmesh version: main (43d5f93)
Kmesh mode: Dual-Engine Mode
Istio version: N/A
Kernel version: N/A
Others: N/A
What happened:
waypointCache.DeleteService()removes the waypoint entry but leaves references to it inserviceToWaypointandworkloadToWaypoint.If one of those resources is updated afterwards, the controller calls
deleteService()ordeleteWorkload()on a missing map entry and panics.What you expected to happen:
Deleting a waypoint should clean up its associations without crashing on later updates.
How to reproduce it (as minimally and precisely as possible):
This unit test reproduces it:
The same state can happen when the waypoint service is removed before updates for its associated services or workloads arrive.
Anything else we need to know?:
DeleteService() guards the lookup when removing an associated service, but the add/update paths dereference it directly.
Environment:
Kmesh version: main (43d5f93)
Kmesh mode: Dual-Engine Mode
Istio version: N/A
Kernel version: N/A
Others: N/A