fix some typos

This commit is contained in:
gaorong
2018-11-08 10:59:06 +08:00
parent 988c9d619e
commit 545aca3d18
7 changed files with 44 additions and 44 deletions

View File

@@ -17,9 +17,12 @@ limitations under the License.
package kubelet
import (
"errors"
"fmt"
"sync"
"time"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
)
type runtimeState struct {
@@ -70,32 +73,32 @@ func (s *runtimeState) podCIDR() string {
return s.cidr
}
func (s *runtimeState) runtimeErrors() []string {
func (s *runtimeState) runtimeErrors() error {
s.RLock()
defer s.RUnlock()
var ret []string
errs := []error{}
if s.lastBaseRuntimeSync.IsZero() {
ret = append(ret, "container runtime status check may not have completed yet")
errs = append(errs, errors.New("container runtime status check may not have completed yet."))
} else if !s.lastBaseRuntimeSync.Add(s.baseRuntimeSyncThreshold).After(time.Now()) {
ret = append(ret, "container runtime is down")
errs = append(errs, errors.New("container runtime is down."))
}
for _, hc := range s.healthChecks {
if ok, err := hc.fn(); !ok {
ret = append(ret, fmt.Sprintf("%s is not healthy: %v", hc.name, err))
errs = append(errs, fmt.Errorf("%s is not healthy: %v.", hc.name, err))
}
}
return ret
return utilerrors.NewAggregate(errs)
}
func (s *runtimeState) networkErrors() []string {
func (s *runtimeState) networkErrors() error {
s.RLock()
defer s.RUnlock()
var ret []string
errs := []error{}
if s.networkError != nil {
ret = append(ret, s.networkError.Error())
errs = append(errs, s.networkError)
}
return ret
return utilerrors.NewAggregate(errs)
}
func newRuntimeState(
@@ -104,6 +107,6 @@ func newRuntimeState(
return &runtimeState{
lastBaseRuntimeSync: time.Time{},
baseRuntimeSyncThreshold: runtimeSyncThreshold,
networkError: fmt.Errorf("network state unknown"),
networkError: ErrNetworkUnknown,
}
}