This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy patherrors.go
146 lines (109 loc) · 4.68 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/**
* Copyright 2018 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package controller
import (
"fmt"
"os"
)
// TODO need to remove this error, since its moved to ubiquity it self
type NoMounterForVolumeError struct {
mounter string
}
func (e *NoMounterForVolumeError) Error() string {
return fmt.Sprintf("Mounter not found for backend: %s", e.mounter)
}
const MissingWwnMountRequestErrorStr = "volume related to scbe backend must have mountRequest.Opts[Wwn] not found (expect to have wwn for scbe backend volume type)"
const FailRemovePVorigDirErrorStr = "Failed removing existing volume directory"
type FailRemovePVorigDirError struct {
err string
dir error
}
func (e *FailRemovePVorigDirError) Error() string {
return fmt.Sprintf(FailRemovePVorigDirErrorStr+". dir=[%s], err=[%#v]", e.dir, e.err)
}
const WrongSlinkErrorStr = "Idempotent - The existing slink point to a wrong mountpoint."
type wrongSlinkError struct {
slink string
wrongPointTo string
expectedPointTo string
}
func (e *wrongSlinkError) Error() string {
return fmt.Sprintf(WrongSlinkErrorStr+" slink=[%s] expected-mountpoint=[%s], wrong-mountpoint=[%s]", e.slink, e.expectedPointTo, e.wrongPointTo)
}
const SupportK8sVesion = "Support only k8s version >= 1.6."
type k8sVersionNotSupported struct {
version string
}
func (e *k8sVersionNotSupported) Error() string {
return fmt.Sprintf(SupportK8sVesion+" Version [%s] is not supported.", e.version)
}
const K8sPVDirectoryIsNotDirNorSlinkErrorStr = "k8s PV directory, k8s-mountpoint, is not a directory nor slink."
type k8sPVDirectoryIsNotDirNorSlinkError struct {
slink string
fileInfo os.FileInfo
}
func (e *k8sPVDirectoryIsNotDirNorSlinkError) Error() string {
// The error string contains also the fileInfo for debug purpose, in order to identify for example what is the actual FileInfo.Mode().
return fmt.Sprintf(K8sPVDirectoryIsNotDirNorSlinkErrorStr+" slink=[%s], fileInfo=[%#v]",
e.slink, e.fileInfo)
}
const IdempotentUnmountSkipOnVolumeNotExistWarnigMsg = "Unmount operation requested to work on not exist volume. Assume its idempotent issue - so skip Unmount."
const K8sPVDirectoryIsNotSlinkErrorStr = "k8s PV directory, k8s-mountpoint, is not slink."
type k8sPVDirectoryIsNotSlinkError struct {
slink string
fileInfo os.FileInfo
}
func (e *k8sPVDirectoryIsNotSlinkError) Error() string {
// The error string contains also the fileInfo for debug purpose, in order to identify for example what is the actual FileInfo.Mode().
return fmt.Sprintf(K8sPVDirectoryIsNotSlinkErrorStr+" slink=[%s], fileInfo=[%#v]",
e.slink, e.fileInfo)
}
const PvBackendNotSupportedErrorStr = "Backend type not supported."
type PvBackendNotSupportedError struct {
Backend string
}
func (e *PvBackendNotSupportedError) Error() string {
return fmt.Sprintf(PvBackendNotSupportedErrorStr+" backend=[%s]", e.Backend)
}
const BackendNotImplementedGetRealMountpointErrorStr = "Backend do not support getting the real mountpoint from PV"
type BackendNotImplementedGetRealMountpointError struct {
Backend string
}
func (e *BackendNotImplementedGetRealMountpointError) Error() string {
return fmt.Sprintf(BackendNotImplementedGetRealMountpointErrorStr+" backend=[%s]", e.Backend)
}
const PVIsAlreadyUsedByAnotherPodMessage = "PV is already in use by another pod and has an existing slink to mountpoint."
type PVIsAlreadyUsedByAnotherPod struct {
mountpoint string
slink []string
}
func (e *PVIsAlreadyUsedByAnotherPod) Error() string {
return fmt.Sprintf(PVIsAlreadyUsedByAnotherPodMessage + " mountpoint=[%s], slinks=[%s]", e.mountpoint, e.slink)
}
var WrongK8sDirectoryPathErrorMessage = fmt.Sprintf("Expected to find [%s] directory in k8s mount path.",K8sPodsDirecotryName)
type WrongK8sDirectoryPathError struct {
k8smountdir string
}
func (e *WrongK8sDirectoryPathError) Error() string {
return fmt.Sprintf(PVIsAlreadyUsedByAnotherPodMessage + "k8smountdir=[%s]", e.k8smountdir)
}
const MissingMountPointVolumeErrorStr = "MountPoint Missing in Volume Config."
type MissingMountPointVolumeError struct {
VolumeName string
}
func (e *MissingMountPointVolumeError) Error() string {
return fmt.Sprintf(MissingMountPointVolumeErrorStr+" volume=[%s]", e.VolumeName)
}