Skip to content

Hosts not removed from host file on clean exit #291

@deadwards90

Description

@deadwards90

If for any reason the application loses connection to the pod, it will not get removed from the hosts file.

I've seen this happen in a few different ways it can lose connection but the problem is always the same.

Example below where both services were left in the file after exit.

INFO[12:10:36]  _          _           __             _
INFO[12:10:36] | | ___   _| |__   ___ / _|_      ____| |
INFO[12:10:36] | |/ / | | | '_ \ / _ \ |_\ \ /\ / / _  |
INFO[12:10:36] |   <| |_| | |_) |  __/  _|\ V  V / (_| |
INFO[12:10:36] |_|\_\\__,_|_.__/ \___|_|   \_/\_/ \__,_|
INFO[12:10:36]
INFO[12:10:36] Version 1.22.5
INFO[12:10:36] https://github.com/txn2/kubefwd
INFO[12:10:36]
INFO[12:10:36] Press [Ctrl-C] to stop forwarding.
INFO[12:10:36] 'cat /etc/hosts' to see all host entries.
INFO[12:10:36] Loaded hosts file C:\Windows\System32\Drivers\etc\hosts
INFO[12:10:36] HostFile management: Original hosts backup already exists at C:\Users\user/hosts.original
INFO[12:10:36] Adding custom domain prod01 to all forwarded entries
INFO[12:10:37] Successfully connected context: prod01
INFO[12:10:37] Port-Forward:       127.1.27.1 ledgers:80 to pod ledgers-7dbb48d674-sqmsf:8080
INFO[12:10:37] Port-Forward:       127.1.27.2 portfolios:80 to pod portfolios-59c5989f54-2ntdb:8080
ERRO[12:12:10] Runtime: error copying from local connection to remote stream: read tcp4 127.1.27.1:80->127.0.0.1:63192: wsarecv: An existing connection was forcibly closed by the remote host.
ERRO[12:12:10] Runtime: error copying from local connection to remote stream: read tcp4 127.1.27.1:80->127.0.0.1:63191: wsarecv: An existing connection was forcibly closed by the remote host.
ERRO[13:08:11] Runtime: lost connection to pod
WARN[13:08:11] Stopped forwarding pod ledgers-7dbb48d674-sqmsf for ledgers.prod01.prod01
ERRO[13:08:28] Runtime: lost connection to pod
WARN[13:08:28] Stopped forwarding pod portfolios-59c5989f54-2ntdb for portfolios.prod01.prod01
INFO[13:53:50] Received shutdown signal
INFO[13:53:50] Stopped watching Service events in namespace prod01 in prod01 context
INFO[13:53:50] Clean exit

Image


This is quite similar to this issue but this does not seem to be a race condition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions