Skip to content

Watch keepalive not working anymore with 1.0.0 #2127

Description

@Alabate

Describe the bug
With the version 1.0.0, when a watch request is made and the connection drop, no more events are reported, but there is also no error that indicate that the connection was dropped. (I waited 10 minutes to be sure)

With version 0.22.2, under ~33s, I got the error read ETIMEDOUT, allowing me to retry the connection and restart the watch request.

This issue was already raised on #559 and fixed with PR #630. This PR add a config to configure keepalive packets in watch.ts, but I don't see this config on the version 1.0.0.

Client Version
1.0.0 (but working on 0.22.2)

Server Version
1.30.3

To Reproduce
In my case, I start the watch-example.ts and then cut the VPN connection to my cluster. As it's related to network perturbation, it's not easy to suggest an easy reproducible way to do it. I guess you can also use your firewall to drop packets in the middle of a watch request.

Expected behavior
I expect an error to be thrown when the Kubernetes api becomes unavailable while a watch request is running like it was the case for previous versions.

** Example Code**
I used the watch-example.ts

Environment (please complete the following information):

  • OS: Linux
  • NodeJS Version 20.16.0

Activity

  1. cjihrig commented on Dec 27, 2024

    @cjihrig
    Contributor

    My guess is that the fix from the v0.x branch just never made it to the v1.x branch. Does applying the fix from #630 fix the issue for you locally?

    If it does fix the issue, I also wonder if we even need the net-keepalive dependency from #630. It looks like they have documented that newer versions of Node used by the v1.x branch may not need the dependency - hertzg/node-net-keepalive#318.

  2. jportner commented on Dec 27, 2024

    @jportner
    Contributor

    node-fetch doesn't support keepalive out of the box, you need to use an Agent, see node-fetch/node-fetch#423

  3. cjihrig commented on Dec 27, 2024

    @cjihrig
    Contributor

    Ah, ok. We do support Agents in the new version. This call returns an object containing an agent (created in src/config.ts). So maybe we need to update those relevant code paths.

  4. Alabate commented on Dec 27, 2024

    @Alabate
    Author

    Actually, in 0.22.2, net-keepalive is already removed in favor of socket.setKeepAlive(): https://github.com/kubernetes-client/javascript/blob/0.22.2/src/watch.ts#L120 (PR: #635)

    So I guess, we need to access the socket and apply the same options, I will try to do a PR.

  5. k8s-triage-robot commented on Mar 27, 2025

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  6. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions