mirror of https://github.com/kubernetes/kops.git
Satisfy the Is interface with ValidationTimeoutError and change callers of err check
Signed-off-by: Jack Andersen <jandersen@plaid.com>
This commit is contained in:
parent
4eb455c6b9
commit
f5f71f17f9
|
|
@ -54,6 +54,15 @@ func (v *ValidationTimeoutError) Error() string {
|
|||
return fmt.Sprintf("error validating cluster%s: %v", v.Operation, v.Err)
|
||||
}
|
||||
|
||||
// Is checks that a given error is a ValidationTimeoutError.
|
||||
func (v *ValidationTimeoutError) Is(err error) bool {
|
||||
// Currently all validation timeout errors are equivalent
|
||||
// If you wish to differentiate, please update the instances of `errors.Is` that check
|
||||
// this error to take that into account
|
||||
_, ok := err.(*ValidationTimeoutError)
|
||||
return ok
|
||||
}
|
||||
|
||||
// promptInteractive asks the user to continue, mostly copied from vendor/google.golang.org/api/examples/gmail.go.
|
||||
func promptInteractive(upgradedHostID, upgradedHostName string) (stopPrompting bool, err error) {
|
||||
stopPrompting = false
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package instancegroups
|
|||
|
||||
import (
|
||||
"context"
|
||||
stderrors "errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"sync"
|
||||
|
|
@ -187,7 +188,7 @@ func (c *RollingUpdateCluster) RollingUpdate(groups map[string]*cloudinstances.C
|
|||
|
||||
for _, k := range sortGroups(apiServerGroups) {
|
||||
err := c.rollingUpdateInstanceGroup(apiServerGroups[k], c.NodeInterval)
|
||||
if err != nil && exitableError(err) {
|
||||
if err != nil && isExitableError(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +210,7 @@ func (c *RollingUpdateCluster) RollingUpdate(groups map[string]*cloudinstances.C
|
|||
|
||||
for _, k := range sortGroups(nodeGroups) {
|
||||
err := c.rollingUpdateInstanceGroup(nodeGroups[k], c.NodeInterval)
|
||||
if err != nil && exitableError(err) {
|
||||
if err != nil && isExitableError(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -237,13 +238,12 @@ func sortGroups(groupMap map[string]*cloudinstances.CloudInstanceGroup) []string
|
|||
return groups
|
||||
}
|
||||
|
||||
// exitableError inspects an error to determine if the error is
|
||||
// isExitableError inspects an error to determine if the error is
|
||||
// fatal enough that the rolling update cannot continue.
|
||||
//
|
||||
// For example, if a cluster is unable to be validated by the deadline, then it
|
||||
// is unlikely that it will validate on the next instance roll, so an early exit as a
|
||||
// warning to the user is more appropriate.
|
||||
func isExitableError(err error) bool {
|
||||
_, ok := err.(*ValidationTimeoutError)
|
||||
return ok
|
||||
return stderrors.Is(err, &ValidationTimeoutError{})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue