Origin: There is no command to close a port forward

Created on 29 May 2018  路  10Comments  路  Source: openshift/origin

[provide a description of the issue]
I am exposing my mongo by the command
oc port-forward mongodb-0 27017:27017 --request-timeout=30s

First the timeout of 30s is not closing the connection.
Also there is no command to close the port forward in another thread

Version

oc v3.7.1+ab0f056
kubernetes v1.7.6+a08f5eeb62
features: Basic-Auth

Server https://ocp-admin.got.xxx.net
openshift v3.6.173.0.21
kubernetes v1.6.1+5115d708d7

Steps To Reproduce
  1. [step 1]
    run the command
    oc port-forward mongodb-0 27017:27017 --request-timeout=30s

  2. [step 2]

Current Result

The timeout does not work

Expected Result

The timeout should work

Additional Information

[try to run $ oc adm diagnostics (or oadm diagnostics) command if possible]
[if you are reporting issue related to builds, provide build logs with BUILD_LOGLEVEL=5]
[consider attaching output of the $ oc get all -o json -n <namespace> command to the issue]
[visit https://docs.openshift.org/latest/welcome/index.html]

lifecyclrotten simaster

Most helpful comment

I don't think --request-timeout applies to API calls like exec and port-forward

saving the PID of the running port-forward command and sending it a termination signal is what I would expect

$ oc port-forward nginx 8090:8080 > /dev/null 2>&1 &
$ PORT_FORWARD_PID=$!
...
$ kill -9 $PORT_FORWARD_PID

All 10 comments

This is one of they way you can use it in your scripts.

$ oc port-forward nginx 8090:8080 > /dev/null 2>&1 &
$ ps -ef | grep nginx

root 87849 1 0 14:58 pts/0 00:00:00 oc port-forward nginx 8090:8080
root 88431 85086 0 15:02 pts/0 00:00:00 grep --color=auto nginx
$ kill -9 87849

@openshift/sig-master

I don't think --request-timeout applies to API calls like exec and port-forward

saving the PID of the running port-forward command and sending it a termination signal is what I would expect

$ oc port-forward nginx 8090:8080 > /dev/null 2>&1 &
$ PORT_FORWARD_PID=$!
...
$ kill -9 $PORT_FORWARD_PID

Hello on the bash i could have this working, but on the jenkins pipeline build i got an error.
The line from the pipeline
sh "oc login ${openshiftUrl} --token=${openshiftToken}"
sh "oc port-forward mongodb-0 27017:27017 > /dev/null 2>&1 &"
sh "PORT_FORWARD_PID=\$!"
sh 'kill -9 $PORT_FORWARD_PID'

From the console with the error

[Pipeline] sh
[pdm] Running shell script

  • oc port-forward mongodb-0 27017:27017
    [Pipeline] sh
    [pdm] Running shell script
  • PORT_FORWARD_PID=
    [Pipeline] sh
    [pdm] Running shell script
  • kill -9
    kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
    ERROR: Pipeline error: hudson.AbortException: script returned exit code 1
    Finished: FAILURE

Could you try and pass the variable in curly bracket.
${PORT_FORWARD_PID}

Seems that the problem is here
sh "PORT_FORWARD_PID=$!"

Running shell script
[mongodb] + PORT_FORWARD_PID=

Because the PORT_FORWARD_PID is not getting any value.

See
mongodb] + kill -9 '{}'

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Was this page helpful?
0 / 5 - 0 ratings