mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 12:41:58 +00:00
Add global timeout flag
This patch adds a global timeout flag (viewable with `kubectl -h`) with a default value of `0s` (meaning no timeout). The timeout value is added to the default http client, so that zero values and default behavior are enforced by the client. **Example** ``` $ kubectl get pods # no timeout flag set - default to 0s (which means no timeout) NAME READY STATUS RESTARTS AGE docker-registry-1-h7etw 1/1 Running 1 2h router-1-uv0f9 1/1 Running 1 2h $ kubectl get pods --timeout=0 # zero means no timeout no timeout flag set NAME READY STATUS RESTARTS AGE docker-registry-1-h7etw 1/1 Running 1 2h router-1-uv0f9 1/1 Running 1 2h $kubectl get pods --timeout=1ms Unable to connect to the server: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) ```
This commit is contained in:
@@ -1184,6 +1184,39 @@ __EOF__
|
||||
kube::test::if_has_string "${output_message}" "/apis/extensions/v1beta1/namespaces/default/replicasets 200 OK"
|
||||
|
||||
|
||||
##################
|
||||
# Global timeout #
|
||||
##################
|
||||
|
||||
### Test global request timeout option
|
||||
# Pre-condition: no POD exists
|
||||
create_and_use_new_namespace
|
||||
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
# Command
|
||||
kubectl create "${kube_flags[@]}" -f test/fixtures/doc-yaml/admin/limitrange/valid-pod.yaml
|
||||
# Post-condition: valid-pod POD is created
|
||||
kubectl get "${kube_flags[@]}" pods -o json
|
||||
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" 'valid-pod:'
|
||||
|
||||
## check --request-timeout on 'get pod'
|
||||
output_message=$(kubectl get pod valid-pod --request-timeout=1)
|
||||
kube::test::if_has_string "${output_message}" 'valid-pod'
|
||||
|
||||
## check --request-timeout on 'get pod' with --watch
|
||||
output_message=$(kubectl get pod valid-pod --request-timeout=1 --watch 2>&1)
|
||||
kube::test::if_has_string "${output_message}" 'Timeout exceeded while reading body'
|
||||
|
||||
## check --request-timeout value with no time unit
|
||||
output_message=$(kubectl get pod valid-pod --request-timeout=1 2>&1)
|
||||
kube::test::if_has_string "${output_message}" 'valid-pod'
|
||||
|
||||
## check --request-timeout value with invalid time unit
|
||||
output_message=$(! kubectl get pod valid-pod --request-timeout="1p" 2>&1)
|
||||
kube::test::if_has_string "${output_message}" 'Invalid value for option'
|
||||
|
||||
# cleanup
|
||||
kubectl delete pods valid-pod "${kube_flags[@]}"
|
||||
|
||||
#####################################
|
||||
# Third Party Resources #
|
||||
#####################################
|
||||
|
Reference in New Issue
Block a user