mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
rebase: update controller-runtime package to v0.9.2
This commit updates controller-runtime to v0.9.2 and makes changes in persistentvolume.go to add context to various functions and function calls made here instead of context.TODO(). Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
26
vendor/k8s.io/utils/io/read.go
generated
vendored
26
vendor/k8s.io/utils/io/read.go
generated
vendored
@ -30,6 +30,9 @@ var ErrLimitReached = errors.New("the read limit is reached")
|
||||
// ConsistentRead repeatedly reads a file until it gets the same content twice.
|
||||
// This is useful when reading files in /proc that are larger than page size
|
||||
// and kernel may modify them between individual read() syscalls.
|
||||
// It returns InconsistentReadError when it cannot get a consistent read in
|
||||
// given nr. of attempts. Caller should retry, kernel is probably under heavy
|
||||
// mount/unmount load.
|
||||
func ConsistentRead(filename string, attempts int) ([]byte, error) {
|
||||
return consistentReadSync(filename, attempts, nil)
|
||||
}
|
||||
@ -56,7 +59,28 @@ func consistentReadSync(filename string, attempts int, sync func(int)) ([]byte,
|
||||
// Files are different, continue reading
|
||||
oldContent = newContent
|
||||
}
|
||||
return nil, fmt.Errorf("could not get consistent content of %s after %d attempts", filename, attempts)
|
||||
return nil, InconsistentReadError{filename, attempts}
|
||||
}
|
||||
|
||||
// InconsistentReadError is returned from ConsistentRead when it cannot get
|
||||
// a consistent read in given nr. of attempts. Caller should retry, kernel is
|
||||
// probably under heavy mount/unmount load.
|
||||
type InconsistentReadError struct {
|
||||
filename string
|
||||
attempts int
|
||||
}
|
||||
|
||||
func (i InconsistentReadError) Error() string {
|
||||
return fmt.Sprintf("could not get consistent content of %s after %d attempts", i.filename, i.attempts)
|
||||
}
|
||||
|
||||
var _ error = InconsistentReadError{}
|
||||
|
||||
func IsInconsistentReadError(err error) bool {
|
||||
if _, ok := err.(InconsistentReadError); ok {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ReadAtMost reads up to `limit` bytes from `r`, and reports an error
|
||||
|
Reference in New Issue
Block a user