txn2 / kubefwd

Bulk port forwarding Kubernetes services for local development.
https://imti.co/kubernetes-port-forwarding/
Apache License 2.0
3.76k stars 203 forks source link

Hosts File Cleanup #229

Open aviv-ga opened 2 years ago

aviv-ga commented 2 years ago

Hosts file is not restored when a signal is sent to the process during the actual forwarding (still writing to hosts file). If the signal is sent after the process is done writing to the hosts file, restore is indeed happening. I think it should be able to clean up no matter when the process is interrupted. Atm, i'm cleaning hosts file myself. Other than that, great stuff!

cjimti commented 2 years ago

@aviv-ga, I agree that some work is to be done here. kubefwd tries to err on the side of not removing entries unless it is certain they should be removed. However, please note that you should not "have" to clean up the hosts' file if entires are left in it; they will not harm anything since they point to internal IPs. If you run kubefwd again, it will reassign hostnames if there are any duplicates. Personally, if my kubefwd process is interrupted for some reason, like my computer going to sleep, then I just restart the same command, let it finish, and control-c it; this ensures it removed what it added.