From 00b2d07d017916543fb84ae72124f787393b36b0 Mon Sep 17 00:00:00 2001 From: Umair Idris Date: Fri, 28 Feb 2020 17:06:13 +0000 Subject: [PATCH] Revert "add health check" (#55) * Revert "add health check (#44)" This reverts commit 3b5d037a270d3e9e11587562e83fbaa6628f4526. * Update provider.go --- cdap/provider.go | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/cdap/provider.go b/cdap/provider.go index ab8b415..3e654bd 100644 --- a/cdap/provider.go +++ b/cdap/provider.go @@ -17,9 +17,6 @@ package cdap import ( "context" - "encoding/json" - "fmt" - "log" "net/http" "time" @@ -82,38 +79,9 @@ func configureProvider(d *schema.ResourceData) (interface{}, error) { return nil, err } - c := &Config{ + return &Config{ host: d.Get("host").(string), httpClient: httpClient, storageClient: storageClient, - } - - if err := healthcheck(c); err != nil { - log.Printf("failed health check, trying again after 5 seconds: %v", err) - time.Sleep(5 * time.Second) - if err := healthcheck(c); err != nil { - return nil, fmt.Errorf("failed health check, possibly due to an invalid host or credentials: %v", err) - } - } - return c, nil -} - -func healthcheck(c *Config) error { - addr := urlJoin(c.host, "/v3/namespaces") - req, err := http.NewRequest(http.MethodGet, addr, nil) - if err != nil { - return err - } - b, err := httpCall(c.httpClient, req) - if err != nil { - return err - } - - // Invalid credentials currently result in a redirect to sign in page instead of an error. - // So check for a valid return value by unmarshalling the JSON. - var v interface{} - if err := json.Unmarshal(b, &v); err != nil { - return fmt.Errorf("failed to unmarshal response: %v\n%v", err, string(b)) - } - return nil + }, nil }