Fix fetcher of newdeploy pod error out when starting up (#1210)

* Connect to k8s API server to ensure network connectivity
* Fix readiness probe path
This commit is contained in:
Ta-Ching Chen
2019-07-14 21:09:35 +08:00
committed by GitHub
parent 56beac6508
commit a9dd4bf81a
7 changed files with 214 additions and 46 deletions
+107
View File
@@ -0,0 +1,107 @@
/*
Copyright 2019 The Fission Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package network
import (
"net"
"net/url"
"os"
"strings"
"syscall"
)
type (
Error struct {
err error
}
)
// Adapter returns an Error if the pass-in error is a network error;
// otherwise, nil will be returned.
func Adapter(err error) *Error {
if err == nil {
return nil
}
netErr, ok := err.(net.Error)
if !ok {
return nil
}
return &Error{err: netErr}
}
func (e Error) Error() string {
return e.err.Error()
}
// IsDialError returns true if its a network dial error
func (e Error) IsDialError() bool {
netOpErr, ok := e.err.(*net.OpError)
if !ok {
return false
}
if netOpErr.Op == "dial" {
return true
}
return false
}
// IsConnRefusedError returns true if an error is a "connection refused" error
func (e Error) IsConnRefusedError() bool {
urlErr, ok := e.err.(*url.Error)
if !ok {
return false
}
if strings.Contains(urlErr.Error(), "connection refused") {
return true
}
netOpErr, ok := e.err.(*net.OpError)
if !ok {
return false
}
switch t := netOpErr.Err.(type) {
case *os.SyscallError:
if errno, ok := t.Err.(syscall.Errno); ok {
switch errno {
case syscall.ECONNREFUSED:
return true
}
}
}
return false
}
// IsUnsupportedProtoScheme returns true if an error is a "unsupported protocol scheme" error
func (e Error) IsUnsupportedProtoScheme() bool {
urlErr, ok := e.err.(*url.Error)
if !ok {
return false
}
if strings.Contains(urlErr.Error(), "unsupported protocol scheme") {
return true
}
return false
}