You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by da...@apache.org on 2017/09/14 02:27:23 UTC

[incubator-openwhisk-wskdeploy] branch master updated: Add default http timeout (#481)

This is an automated email from the ASF dual-hosted git repository.

daisyguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-wskdeploy.git


The following commit(s) were added to refs/heads/master by this push:
     new 33b6694  Add default http timeout (#481)
33b6694 is described below

commit 33b6694f3fea5c74c107b42443a0d0a9b1082254
Author: Vincent <sh...@us.ibm.com>
AuthorDate: Wed Sep 13 22:27:21 2017 -0400

    Add default http timeout (#481)
    
    This PR adds 30 seconds as the default http timeout.
    Closes-Bug: #206
---
 Godeps/Godeps.json       | 4 ++--
 cmd/report.go            | 5 ++---
 cmd/root.go              | 5 ++---
 deployers/whiskclient.go | 8 ++++++--
 utils/misc.go            | 8 ++------
 5 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index 0ad04e5..62c977b 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -105,11 +105,11 @@
 		},
 		{
 			"ImportPath": "github.com/apache/incubator-openwhisk-client-go/whisk",
-			"Rev": "6572868460e856f5658a57fb64f98236b73aaee0"
+			"Rev": "00db68b4507d77e3202295ba2e3f86eab2598909"
 		},
 		{
 			"ImportPath": "github.com/apache/incubator-openwhisk-client-go/wski18n",
-			"Rev": "6572868460e856f5658a57fb64f98236b73aaee0"
+			"Rev": "00db68b4507d77e3202295ba2e3f86eab2598909"
 		},
 		{
 			"ImportPath": "github.com/pelletier/go-buffruneio",
diff --git a/cmd/report.go b/cmd/report.go
index 58330f2..05a8c02 100644
--- a/cmd/report.go
+++ b/cmd/report.go
@@ -27,7 +27,6 @@ import (
 	"github.com/spf13/cobra"
 	"path"
 	"sync"
-    "net/http"
 )
 
 var wskpropsPath string
@@ -46,14 +45,14 @@ located under current user home.`,
 	RunE: func(cmd *cobra.Command, args []string) error {
 		if wskpropsPath != "" {
 			config, _ := deployers.NewWhiskConfig(wskpropsPath, utils.Flags.DeploymentPath, utils.Flags.ManifestPath, false)
-            client, _ := deployers.CreateNewClient(http.DefaultClient, config)
+            client, _ := deployers.CreateNewClient(config)
             return printDeploymentInfo(client)
 		} else {
             //default to ~/.wskprops
             userHome := utils.GetHomeDirectory()
             propPath := path.Join(userHome, ".wskprops")
             config, _ := deployers.NewWhiskConfig(propPath, utils.Flags.DeploymentPath, utils.Flags.ManifestPath, false)
-            client, _ := deployers.CreateNewClient(http.DefaultClient, config)
+            client, _ := deployers.CreateNewClient(config)
             return printDeploymentInfo(client)
         }
 	},
diff --git a/cmd/root.go b/cmd/root.go
index d715aaf..b01fd6d 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -29,7 +29,6 @@ import (
 	"os"
 	"path"
 	"path/filepath"
-    "net/http"
 	"regexp"
 	"strings"
 )
@@ -205,7 +204,7 @@ func Deploy() error {
             return error
         }
 
-        whiskClient, error := deployers.CreateNewClient(http.DefaultClient, clientConfig)
+        whiskClient, error := deployers.CreateNewClient(clientConfig)
         if error != nil {
             return error
         }
@@ -296,7 +295,7 @@ func Undeploy() error {
             return error
         }
 
-        whiskClient, error := deployers.CreateNewClient(http.DefaultClient, clientConfig)
+        whiskClient, error := deployers.CreateNewClient(clientConfig)
         if error != nil {
             return error
         }
diff --git a/deployers/whiskclient.go b/deployers/whiskclient.go
index dc35a0d..d136aca 100644
--- a/deployers/whiskclient.go
+++ b/deployers/whiskclient.go
@@ -28,6 +28,7 @@ import (
     "github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
 	"github.com/apache/incubator-openwhisk-wskdeploy/utils"
     "path"
+    "time"
 )
 
 const (
@@ -63,8 +64,11 @@ var GetCommandLineFlags = func () (string, string, string) {
 	return utils.Flags.ApiHost, utils.Flags.Auth, utils.Flags.Namespace
 }
 
-var CreateNewClient = func (httpClient *http.Client, config_input *whisk.Config) (*whisk.Client, error) {
-	return whisk.NewClient(http.DefaultClient, clientConfig)
+var CreateNewClient = func (config_input *whisk.Config) (*whisk.Client, error) {
+    var netClient = &http.Client{
+        Timeout: time.Second * utils.DEFAULT_HTTP_TIMEOUT,
+    }
+	return whisk.NewClient(netClient, clientConfig)
 }
 
 func NewWhiskConfig(proppath string, deploymentPath string, manifestPath string, isInteractive bool) (*whisk.Config, error) {
diff --git a/utils/misc.go b/utils/misc.go
index d23e91f..0c6dec9 100644
--- a/utils/misc.go
+++ b/utils/misc.go
@@ -43,7 +43,7 @@ import (
 )
 
 const (
-    HTTP_TIMEOUT = 30
+    DEFAULT_HTTP_TIMEOUT = 30
     DEFAULT_PROJECT_PATH = "."
 )
 // ActionRecord is a container to keep track of
@@ -456,16 +456,12 @@ func ParseOpenWhisk(apiHost string) (op OpenWhiskInfo, err error) {
 		InsecureSkipVerify: true,
 	}
 
-	http.DefaultClient.Transport = &http.Transport{
-		TLSClientConfig: tlsConfig,
-	}
-
     var netTransport = &http.Transport{
         TLSClientConfig: tlsConfig,
     }
 
     var netClient = &http.Client{
-        Timeout: time.Second * HTTP_TIMEOUT,
+        Timeout: time.Second * DEFAULT_HTTP_TIMEOUT,
         Transport: netTransport,
     }
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].