forked from portworx/torpedo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
99 lines (82 loc) · 3.17 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package portworx
import (
"fmt"
"github.com/portworx/torpedo/drivers/node"
)
// ErrFailedToInspectVolume error type for failing to inspect a volume
type ErrFailedToInspectVolume struct {
// ID is the ID/name of the volume that failed to inspect
ID string
// Cause is the underlying cause of the error
Cause string
}
func (e *ErrFailedToInspectVolume) Error() string {
return fmt.Sprintf("Failed to inspect volume: %v due to err: %v", e.ID, e.Cause)
}
func errFailedToInspectVolume(ID, key string, expected, actual interface{}) error {
return &ErrFailedToInspectVolume{
ID: ID,
Cause: fmt.Sprintf("volume has invalid %v value. Expected:%#v Actual:%#v",
key, expected, actual),
}
}
// ErrFailedToDeleteVolume error type for failing to delete a volume
type ErrFailedToDeleteVolume struct {
// ID is the ID/name of the volume that failed to delete
ID string
// Cause is the underlying cause of the error
Cause string
}
func (e *ErrFailedToDeleteVolume) Error() string {
return fmt.Sprintf("Failed to delete volume: %v due to err: %v", e.ID, e.Cause)
}
// ErrFailedToWaitForPx error type for failing to wait for PX to be up on a node
type ErrFailedToWaitForPx struct {
// Node is the node on which PX was waited upon
Node node.Node
// Cause is the underlying cause of the error
Cause string
}
func (e *ErrFailedToWaitForPx) Error() string {
return fmt.Sprintf("Failed to wait for px status on: %v due to err: %v", e.Node.Name, e.Cause)
}
// ErrFailedToUpgradeVolumeDriver error type for failed volume driver upgrade
type ErrFailedToUpgradeVolumeDriver struct {
// Version is the new image used to upgrade the volume driver
Version string
// Cause is the underlying cause of the error
Cause string
}
func (e *ErrFailedToUpgradeVolumeDriver) Error() string {
return fmt.Sprintf("Failed to upgrade volume driver to version: %v due to err: %v", e.Version, e.Cause)
}
// ErrFailedToRecoverDriver error type for failing to recover PX on a node
type ErrFailedToRecoverDriver struct {
// Node is the node on which PX failed to recover on
Node node.Node
// Cause is the underlying cause of the error
Cause string
}
func (e *ErrFailedToRecoverDriver) Error() string {
return fmt.Sprintf("Failed to wait for px to be up on: %v due to err: %v", e.Node.Name, e.Cause)
}
// ErrFailedToSetReplicationFactor error type for failing to set replication factor to given value
type ErrFailedToSetReplicationFactor struct {
// ID is the ID/name of the volume for which we could not set the replication factor
ID string
// Cause is the underlying cause of the error
Cause string
}
func (e *ErrFailedToSetReplicationFactor) Error() string {
return fmt.Sprintf("Failed to set replication factor of the volume: %v due to err: %v", e.ID, e.Cause)
}
// ErrFailedToGetReplicationFactor error type for failing to get/query the current replication factor
type ErrFailedToGetReplicationFactor struct {
// ID is the ID/name of the volume for which we could not get the replication factor
ID string
// Cause is the underlying cause of the error
Cause string
}
func (e *ErrFailedToGetReplicationFactor) Error() string {
return fmt.Sprintf("Failed to get replication factor of the volume: %v due to err: %v", e.ID, e.Cause)
}