Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements to the SNMP forwarding/proxying container setup #2637

Merged
merged 8 commits into from Jun 5, 2023

Commits on May 31, 2023

  1. Make signals propagate to remote socat process

    This ensures that the remote socat process is torn down when the
    forwarding container exits. Before this change, the socat process would
    linger forever, causing the forwarding port to stay bound forever on the
    remote hop-host.  Any subsequent attempts to restart the forwarding
    container would just result in an error that looked like this:
    
    ```
    socat[10092] E bind(5, {AF=2 0.0.0.0:10000}, 16): Address already in use
    ```
    
    Using the `-tt` option to ssh forces SSH to allocate a pseudo-terminal,
    even if the controlling process isn't attached to a real terminal.
    Using the pseudo-terminal ensures that signals are propagated from the
    ssh process to the socat process started on the remote, so when the SSH
    session dies, socat will also.
    
    We also drop the `-f` option, since that would cause the SSH process to
    send the termination signal as soon as it forks and exits.  This uses
    the shell to background the ssh process instead.
    lunkwill42 committed May 31, 2023
    Copy the full SHA
    f3fa03f View commit details
    Browse the repository at this point in the history
  2. Factor out local tunnel to a function

    This factors out the setup of the local socat tunnel to a function,
    backgrounds it and waits for all backgrounded processes to terminate.
    lunkwill42 committed May 31, 2023
    Copy the full SHA
    ee97f63 View commit details
    Browse the repository at this point in the history
  3. Stop container if any forwarding subprocess dies

    This ensures the whole process group, and thereby the forwarding
    container itself, dies if any of the forwarding subprocesses exit.
    
    This should be a very explicit failure signal to the developer using
    this forwarding container.
    lunkwill42 committed May 31, 2023
    Copy the full SHA
    1ec3dbf View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    20c485c View commit details
    Browse the repository at this point in the history
  5. Echo/log remote tunnel setup

    It's nice to know what's going on, even if -x isn't used.
    lunkwill42 committed May 31, 2023
    Copy the full SHA
    bf27a60 View commit details
    Browse the repository at this point in the history
  6. Set specific ssh ConnectTimeout

    For some weird reason, my SSH connection will not be properly
    established unless I add an explicit ConnectTimout option.
    lunkwill42 committed May 31, 2023
    Copy the full SHA
    62b78e9 View commit details
    Browse the repository at this point in the history
  7. Support SNMP agents on IPv6

    This ensures a remote IPv6 SNMP agent can be reached also, even if the
    local address is still IPv4.
    lunkwill42 committed May 31, 2023
    Copy the full SHA
    533f362 View commit details
    Browse the repository at this point in the history
  8. Move cache-busting COPY to end of Dockerfile

    Rebuilding much of the docker image just because the shell script is
    changing is tiresome. This ensures the last thing that happpens is the
    copying of the shell script.
    lunkwill42 committed May 31, 2023
    Copy the full SHA
    42743a6 View commit details
    Browse the repository at this point in the history