...

Source file src/k8s.io/kubernetes/pkg/probe/exec/errors.go

Documentation: k8s.io/kubernetes/pkg/probe/exec

     1  /*
     2  Copyright 2020 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package exec
    18  
    19  import (
    20  	"time"
    21  )
    22  
    23  // NewTimeoutError returns a new TimeoutError.
    24  func NewTimeoutError(err error, timeout time.Duration) *TimeoutError {
    25  	return &TimeoutError{
    26  		err:     err,
    27  		timeout: timeout,
    28  	}
    29  }
    30  
    31  // TimeoutError is an error returned on exec probe timeouts. It should be returned by CRI implementations
    32  // in order for the exec prober to interpret exec timeouts as failed probes.
    33  // TODO: this error type can likely be removed when we support CRI errors.
    34  type TimeoutError struct {
    35  	err     error
    36  	timeout time.Duration
    37  }
    38  
    39  // Error returns the error string.
    40  func (t *TimeoutError) Error() string {
    41  	return t.err.Error()
    42  }
    43  
    44  // Timeout returns the timeout duration of the exec probe.
    45  func (t *TimeoutError) Timeout() time.Duration {
    46  	return t.timeout
    47  }
    48  

View as plain text