@@ -266,7 +266,7 @@ func (d *defaultManager) stopRemoteWorkload(ctx context.Context, name string, ru
266
266
267
267
// Stop proxy if running
268
268
if runConfig .BaseName != "" {
269
- d .stopProxyIfNeeded (name , runConfig .BaseName )
269
+ d .stopProxyIfNeeded (ctx , name , runConfig .BaseName )
270
270
}
271
271
272
272
// For remote workloads, we only need to clean up client configurations
@@ -497,7 +497,7 @@ func (d *defaultManager) deleteRemoteWorkload(ctx context.Context, name string,
497
497
498
498
// Stop proxy if running
499
499
if runConfig .BaseName != "" {
500
- d .stopProxyIfNeeded (name , runConfig .BaseName )
500
+ d .stopProxyIfNeeded (ctx , name , runConfig .BaseName )
501
501
}
502
502
503
503
// Clean up associated resources
@@ -532,7 +532,7 @@ func (d *defaultManager) deleteContainerWorkload(ctx context.Context, name strin
532
532
533
533
// Stop proxy if running
534
534
if container .IsRunning () {
535
- d .stopProxyIfNeeded (name , baseName )
535
+ d .stopProxyIfNeeded (ctx , name , baseName )
536
536
}
537
537
538
538
// Remove the container
@@ -570,14 +570,14 @@ func (d *defaultManager) getWorkloadContainer(ctx context.Context, name string)
570
570
}
571
571
572
572
// stopProcess stops the proxy process associated with the container
573
- func (* defaultManager ) stopProcess (name string ) {
573
+ func (d * defaultManager ) stopProcess (ctx context. Context , name string ) {
574
574
if name == "" {
575
575
logger .Warnf ("Warning: Could not find base container name in labels" )
576
576
return
577
577
}
578
578
579
- // Try to read the PID file and kill the process
580
- pid , err := process . ReadPIDFile ( name )
579
+ // Try to read the PID and kill the process
580
+ pid , err := d . statuses . GetWorkloadPID ( ctx , name )
581
581
if err != nil {
582
582
logger .Errorf ("No PID file found for %s, proxy may not be running in detached mode" , name )
583
583
return
@@ -598,10 +598,10 @@ func (*defaultManager) stopProcess(name string) {
598
598
}
599
599
600
600
// stopProxyIfNeeded stops the proxy process if the workload has a base name
601
- func (d * defaultManager ) stopProxyIfNeeded (name , baseName string ) {
601
+ func (d * defaultManager ) stopProxyIfNeeded (ctx context. Context , name , baseName string ) {
602
602
logger .Infof ("Removing proxy process for %s..." , name )
603
603
if baseName != "" {
604
- d .stopProcess (baseName )
604
+ d .stopProcess (ctx , baseName )
605
605
}
606
606
}
607
607
@@ -992,7 +992,7 @@ func (d *defaultManager) stopSingleContainerWorkload(ctx context.Context, worklo
992
992
993
993
name := labels .GetContainerBaseName (workload .Labels )
994
994
// Stop the proxy process
995
- d .stopProcess (name )
995
+ d .stopProcess (ctx , name )
996
996
// TODO: refactor the StopProcess function to stop dealing explicitly with PID files.
997
997
// Note that this is not a blocker for k8s since this code path is not called there.
998
998
if err := d .statuses .ResetWorkloadPID (ctx , name ); err != nil {
0 commit comments