mirror of https://github.com/k3s-io/k3s
Rename UniqueDeviceName to UniqueVolumeName
Rename UniqueDeviceName to UniqueVolumeName and move helper functions from attacherdetacher to volumehelper package. Introduce UniquePodName aliaspull/6/head
parent
130341b5f1
commit
9b6a505f8a
|
@ -16765,9 +16765,9 @@
|
||||||
"volumesInUse": {
|
"volumesInUse": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "v1.UniqueDeviceName"
|
"$ref": "v1.UniqueVolumeName"
|
||||||
},
|
},
|
||||||
"description": "List of volumes in use (mounted) by the node."
|
"description": "List of attachable volume devices in use (mounted) by the node."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -16926,8 +16926,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"v1.UniqueDeviceName": {
|
"v1.UniqueVolumeName": {
|
||||||
"id": "v1.UniqueDeviceName",
|
"id": "v1.UniqueVolumeName",
|
||||||
"properties": {}
|
"properties": {}
|
||||||
},
|
},
|
||||||
"v1.PersistentVolumeClaimList": {
|
"v1.PersistentVolumeClaimList": {
|
||||||
|
|
|
@ -594,10 +594,6 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="sect2">
|
|
||||||
<h3 id="_v1_uniquedevicename">v1.UniqueDeviceName</h3>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="sect2">
|
<div class="sect2">
|
||||||
<h3 id="_v1_preconditions">v1.Preconditions</h3>
|
<h3 id="_v1_preconditions">v1.Preconditions</h3>
|
||||||
|
@ -2810,7 +2806,9 @@ Populated by the system when a graceful deletion is requested. Read-only. More i
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="sect2">
|
||||||
|
<h3 id="_v1_uniquevolumename">v1.UniqueVolumeName</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="sect2">
|
<div class="sect2">
|
||||||
<h3 id="_v1_endpointsubset">v1.EndpointSubset</h3>
|
<h3 id="_v1_endpointsubset">v1.EndpointSubset</h3>
|
||||||
|
@ -4757,9 +4755,9 @@ The resulting set of endpoints can be viewed as:<br>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">volumesInUse</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">volumesInUse</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">List of volumes in use (mounted) by the node.</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">List of attachable volume devices in use (mounted) by the node.</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_uniquedevicename">v1.UniqueDeviceName</a> array</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_uniquevolumename">v1.UniqueVolumeName</a> array</p></td>
|
||||||
<td class="tableblock halign-left valign-top"></td>
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -1603,7 +1603,7 @@ func DeepCopy_api_NodeStatus(in NodeStatus, out *NodeStatus, c *conversion.Clone
|
||||||
}
|
}
|
||||||
if in.VolumesInUse != nil {
|
if in.VolumesInUse != nil {
|
||||||
in, out := in.VolumesInUse, &out.VolumesInUse
|
in, out := in.VolumesInUse, &out.VolumesInUse
|
||||||
*out = make([]UniqueDeviceName, len(in))
|
*out = make([]UniqueVolumeName, len(in))
|
||||||
for i := range in {
|
for i := range in {
|
||||||
(*out)[i] = in[i]
|
(*out)[i] = in[i]
|
||||||
}
|
}
|
||||||
|
|
|
@ -36754,7 +36754,7 @@ func (x *NodeStatus) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
_ = yym32
|
_ = yym32
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
h.encSliceUniqueDeviceName(([]UniqueDeviceName)(x.VolumesInUse), e)
|
h.encSliceUniqueVolumeName(([]UniqueVolumeName)(x.VolumesInUse), e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -36772,7 +36772,7 @@ func (x *NodeStatus) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
_ = yym33
|
_ = yym33
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
h.encSliceUniqueDeviceName(([]UniqueDeviceName)(x.VolumesInUse), e)
|
h.encSliceUniqueVolumeName(([]UniqueVolumeName)(x.VolumesInUse), e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36917,7 +36917,7 @@ func (x *NodeStatus) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
||||||
_ = yym16
|
_ = yym16
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
h.decSliceUniqueDeviceName((*[]UniqueDeviceName)(yyv15), d)
|
h.decSliceUniqueVolumeName((*[]UniqueVolumeName)(yyv15), d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -37103,7 +37103,7 @@ func (x *NodeStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
|
||||||
_ = yym30
|
_ = yym30
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
h.decSliceUniqueDeviceName((*[]UniqueDeviceName)(yyv29), d)
|
h.decSliceUniqueVolumeName((*[]UniqueVolumeName)(yyv29), d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
|
@ -37122,7 +37122,7 @@ func (x *NodeStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x UniqueDeviceName) CodecEncodeSelf(e *codec1978.Encoder) {
|
func (x UniqueVolumeName) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
var h codecSelfer1234
|
var h codecSelfer1234
|
||||||
z, r := codec1978.GenHelperEncoder(e)
|
z, r := codec1978.GenHelperEncoder(e)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
|
@ -37135,7 +37135,7 @@ func (x UniqueDeviceName) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *UniqueDeviceName) CodecDecodeSelf(d *codec1978.Decoder) {
|
func (x *UniqueVolumeName) CodecDecodeSelf(d *codec1978.Decoder) {
|
||||||
var h codecSelfer1234
|
var h codecSelfer1234
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
|
@ -57367,7 +57367,7 @@ func (x codecSelfer1234) decSliceContainerImage(v *[]ContainerImage, d *codec197
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x codecSelfer1234) encSliceUniqueDeviceName(v []UniqueDeviceName, e *codec1978.Encoder) {
|
func (x codecSelfer1234) encSliceUniqueVolumeName(v []UniqueVolumeName, e *codec1978.Encoder) {
|
||||||
var h codecSelfer1234
|
var h codecSelfer1234
|
||||||
z, r := codec1978.GenHelperEncoder(e)
|
z, r := codec1978.GenHelperEncoder(e)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
|
@ -57379,7 +57379,7 @@ func (x codecSelfer1234) encSliceUniqueDeviceName(v []UniqueDeviceName, e *codec
|
||||||
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *codec1978.Decoder) {
|
func (x codecSelfer1234) decSliceUniqueVolumeName(v *[]UniqueVolumeName, d *codec1978.Decoder) {
|
||||||
var h codecSelfer1234
|
var h codecSelfer1234
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
|
@ -57390,7 +57390,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
_ = yyc1
|
_ = yyc1
|
||||||
if yyl1 == 0 {
|
if yyl1 == 0 {
|
||||||
if yyv1 == nil {
|
if yyv1 == nil {
|
||||||
yyv1 = []UniqueDeviceName{}
|
yyv1 = []UniqueVolumeName{}
|
||||||
yyc1 = true
|
yyc1 = true
|
||||||
} else if len(yyv1) != 0 {
|
} else if len(yyv1) != 0 {
|
||||||
yyv1 = yyv1[:0]
|
yyv1 = yyv1[:0]
|
||||||
|
@ -57408,10 +57408,10 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
if yyrl1 <= cap(yyv1) {
|
if yyrl1 <= cap(yyv1) {
|
||||||
yyv1 = yyv1[:yyrl1]
|
yyv1 = yyv1[:yyrl1]
|
||||||
} else {
|
} else {
|
||||||
yyv1 = make([]UniqueDeviceName, yyrl1)
|
yyv1 = make([]UniqueVolumeName, yyrl1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
yyv1 = make([]UniqueDeviceName, yyrl1)
|
yyv1 = make([]UniqueVolumeName, yyrl1)
|
||||||
}
|
}
|
||||||
yyc1 = true
|
yyc1 = true
|
||||||
yyrr1 = len(yyv1)
|
yyrr1 = len(yyv1)
|
||||||
|
@ -57425,7 +57425,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
yyv1[yyj1] = ""
|
yyv1[yyj1] = ""
|
||||||
} else {
|
} else {
|
||||||
yyv1[yyj1] = UniqueDeviceName(r.DecodeString())
|
yyv1[yyj1] = UniqueVolumeName(r.DecodeString())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57436,7 +57436,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
yyv1[yyj1] = ""
|
yyv1[yyj1] = ""
|
||||||
} else {
|
} else {
|
||||||
yyv1[yyj1] = UniqueDeviceName(r.DecodeString())
|
yyv1[yyj1] = UniqueVolumeName(r.DecodeString())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57447,7 +57447,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
for ; !r.CheckBreak(); yyj1++ {
|
for ; !r.CheckBreak(); yyj1++ {
|
||||||
|
|
||||||
if yyj1 >= len(yyv1) {
|
if yyj1 >= len(yyv1) {
|
||||||
yyv1 = append(yyv1, "") // var yyz1 UniqueDeviceName
|
yyv1 = append(yyv1, "") // var yyz1 UniqueVolumeName
|
||||||
yyc1 = true
|
yyc1 = true
|
||||||
}
|
}
|
||||||
yyh1.ElemContainerState(yyj1)
|
yyh1.ElemContainerState(yyj1)
|
||||||
|
@ -57455,7 +57455,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
yyv1[yyj1] = ""
|
yyv1[yyj1] = ""
|
||||||
} else {
|
} else {
|
||||||
yyv1[yyj1] = UniqueDeviceName(r.DecodeString())
|
yyv1[yyj1] = UniqueVolumeName(r.DecodeString())
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -57467,7 +57467,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
yyv1 = yyv1[:yyj1]
|
yyv1 = yyv1[:yyj1]
|
||||||
yyc1 = true
|
yyc1 = true
|
||||||
} else if yyj1 == 0 && yyv1 == nil {
|
} else if yyj1 == 0 && yyv1 == nil {
|
||||||
yyv1 = []UniqueDeviceName{}
|
yyv1 = []UniqueVolumeName{}
|
||||||
yyc1 = true
|
yyc1 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1987,11 +1987,11 @@ type NodeStatus struct {
|
||||||
NodeInfo NodeSystemInfo `json:"nodeInfo,omitempty"`
|
NodeInfo NodeSystemInfo `json:"nodeInfo,omitempty"`
|
||||||
// List of container images on this node
|
// List of container images on this node
|
||||||
Images []ContainerImage `json:"images,omitempty"`
|
Images []ContainerImage `json:"images,omitempty"`
|
||||||
// List of attachable volume devices in use (mounted) by the node.
|
// List of attachable volumes in use (mounted) by the node.
|
||||||
VolumesInUse []UniqueDeviceName `json:"volumesInUse,omitempty"`
|
VolumesInUse []UniqueVolumeName `json:"volumesInUse,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UniqueDeviceName string
|
type UniqueVolumeName string
|
||||||
|
|
||||||
// Describe a container image
|
// Describe a container image
|
||||||
type ContainerImage struct {
|
type ContainerImage struct {
|
||||||
|
|
|
@ -3390,9 +3390,9 @@ func autoConvert_v1_NodeStatus_To_api_NodeStatus(in *NodeStatus, out *api.NodeSt
|
||||||
}
|
}
|
||||||
if in.VolumesInUse != nil {
|
if in.VolumesInUse != nil {
|
||||||
in, out := &in.VolumesInUse, &out.VolumesInUse
|
in, out := &in.VolumesInUse, &out.VolumesInUse
|
||||||
*out = make([]api.UniqueDeviceName, len(*in))
|
*out = make([]api.UniqueVolumeName, len(*in))
|
||||||
for i := range *in {
|
for i := range *in {
|
||||||
(*out)[i] = api.UniqueDeviceName((*in)[i])
|
(*out)[i] = api.UniqueVolumeName((*in)[i])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out.VolumesInUse = nil
|
out.VolumesInUse = nil
|
||||||
|
@ -3473,9 +3473,9 @@ func autoConvert_api_NodeStatus_To_v1_NodeStatus(in *api.NodeStatus, out *NodeSt
|
||||||
}
|
}
|
||||||
if in.VolumesInUse != nil {
|
if in.VolumesInUse != nil {
|
||||||
in, out := &in.VolumesInUse, &out.VolumesInUse
|
in, out := &in.VolumesInUse, &out.VolumesInUse
|
||||||
*out = make([]UniqueDeviceName, len(*in))
|
*out = make([]UniqueVolumeName, len(*in))
|
||||||
for i := range *in {
|
for i := range *in {
|
||||||
(*out)[i] = UniqueDeviceName((*in)[i])
|
(*out)[i] = UniqueVolumeName((*in)[i])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out.VolumesInUse = nil
|
out.VolumesInUse = nil
|
||||||
|
|
|
@ -1550,7 +1550,7 @@ func DeepCopy_v1_NodeStatus(in NodeStatus, out *NodeStatus, c *conversion.Cloner
|
||||||
}
|
}
|
||||||
if in.VolumesInUse != nil {
|
if in.VolumesInUse != nil {
|
||||||
in, out := in.VolumesInUse, &out.VolumesInUse
|
in, out := in.VolumesInUse, &out.VolumesInUse
|
||||||
*out = make([]UniqueDeviceName, len(in))
|
*out = make([]UniqueVolumeName, len(in))
|
||||||
for i := range in {
|
for i := range in {
|
||||||
(*out)[i] = in[i]
|
(*out)[i] = in[i]
|
||||||
}
|
}
|
||||||
|
|
|
@ -21633,7 +21633,7 @@ func (m *NodeStatus) Unmarshal(data []byte) error {
|
||||||
if postIndex > l {
|
if postIndex > l {
|
||||||
return io.ErrUnexpectedEOF
|
return io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
m.VolumesInUse = append(m.VolumesInUse, UniqueDeviceName(data[iNdEx:postIndex]))
|
m.VolumesInUse = append(m.VolumesInUse, UniqueVolumeName(data[iNdEx:postIndex]))
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
|
|
|
@ -1304,7 +1304,7 @@ message NodeStatus {
|
||||||
// List of container images on this node
|
// List of container images on this node
|
||||||
repeated ContainerImage images = 8;
|
repeated ContainerImage images = 8;
|
||||||
|
|
||||||
// List of volumes in use (mounted) by the node.
|
// List of attachable volume devices in use (mounted) by the node.
|
||||||
repeated string volumesInUse = 9;
|
repeated string volumesInUse = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36559,7 +36559,7 @@ func (x *NodeStatus) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
_ = yym32
|
_ = yym32
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
h.encSliceUniqueDeviceName(([]UniqueDeviceName)(x.VolumesInUse), e)
|
h.encSliceUniqueVolumeName(([]UniqueVolumeName)(x.VolumesInUse), e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -36577,7 +36577,7 @@ func (x *NodeStatus) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
_ = yym33
|
_ = yym33
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
h.encSliceUniqueDeviceName(([]UniqueDeviceName)(x.VolumesInUse), e)
|
h.encSliceUniqueVolumeName(([]UniqueVolumeName)(x.VolumesInUse), e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36722,7 +36722,7 @@ func (x *NodeStatus) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
||||||
_ = yym16
|
_ = yym16
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
h.decSliceUniqueDeviceName((*[]UniqueDeviceName)(yyv15), d)
|
h.decSliceUniqueVolumeName((*[]UniqueVolumeName)(yyv15), d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -36908,7 +36908,7 @@ func (x *NodeStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
|
||||||
_ = yym30
|
_ = yym30
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
h.decSliceUniqueDeviceName((*[]UniqueDeviceName)(yyv29), d)
|
h.decSliceUniqueVolumeName((*[]UniqueVolumeName)(yyv29), d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
|
@ -36927,7 +36927,7 @@ func (x *NodeStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x UniqueDeviceName) CodecEncodeSelf(e *codec1978.Encoder) {
|
func (x UniqueVolumeName) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
var h codecSelfer1234
|
var h codecSelfer1234
|
||||||
z, r := codec1978.GenHelperEncoder(e)
|
z, r := codec1978.GenHelperEncoder(e)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
|
@ -36940,7 +36940,7 @@ func (x UniqueDeviceName) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *UniqueDeviceName) CodecDecodeSelf(d *codec1978.Decoder) {
|
func (x *UniqueVolumeName) CodecDecodeSelf(d *codec1978.Decoder) {
|
||||||
var h codecSelfer1234
|
var h codecSelfer1234
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
|
@ -57420,7 +57420,7 @@ func (x codecSelfer1234) decSliceContainerImage(v *[]ContainerImage, d *codec197
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x codecSelfer1234) encSliceUniqueDeviceName(v []UniqueDeviceName, e *codec1978.Encoder) {
|
func (x codecSelfer1234) encSliceUniqueVolumeName(v []UniqueVolumeName, e *codec1978.Encoder) {
|
||||||
var h codecSelfer1234
|
var h codecSelfer1234
|
||||||
z, r := codec1978.GenHelperEncoder(e)
|
z, r := codec1978.GenHelperEncoder(e)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
|
@ -57432,7 +57432,7 @@ func (x codecSelfer1234) encSliceUniqueDeviceName(v []UniqueDeviceName, e *codec
|
||||||
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *codec1978.Decoder) {
|
func (x codecSelfer1234) decSliceUniqueVolumeName(v *[]UniqueVolumeName, d *codec1978.Decoder) {
|
||||||
var h codecSelfer1234
|
var h codecSelfer1234
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
|
@ -57443,7 +57443,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
_ = yyc1
|
_ = yyc1
|
||||||
if yyl1 == 0 {
|
if yyl1 == 0 {
|
||||||
if yyv1 == nil {
|
if yyv1 == nil {
|
||||||
yyv1 = []UniqueDeviceName{}
|
yyv1 = []UniqueVolumeName{}
|
||||||
yyc1 = true
|
yyc1 = true
|
||||||
} else if len(yyv1) != 0 {
|
} else if len(yyv1) != 0 {
|
||||||
yyv1 = yyv1[:0]
|
yyv1 = yyv1[:0]
|
||||||
|
@ -57461,10 +57461,10 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
if yyrl1 <= cap(yyv1) {
|
if yyrl1 <= cap(yyv1) {
|
||||||
yyv1 = yyv1[:yyrl1]
|
yyv1 = yyv1[:yyrl1]
|
||||||
} else {
|
} else {
|
||||||
yyv1 = make([]UniqueDeviceName, yyrl1)
|
yyv1 = make([]UniqueVolumeName, yyrl1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
yyv1 = make([]UniqueDeviceName, yyrl1)
|
yyv1 = make([]UniqueVolumeName, yyrl1)
|
||||||
}
|
}
|
||||||
yyc1 = true
|
yyc1 = true
|
||||||
yyrr1 = len(yyv1)
|
yyrr1 = len(yyv1)
|
||||||
|
@ -57478,7 +57478,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
yyv1[yyj1] = ""
|
yyv1[yyj1] = ""
|
||||||
} else {
|
} else {
|
||||||
yyv1[yyj1] = UniqueDeviceName(r.DecodeString())
|
yyv1[yyj1] = UniqueVolumeName(r.DecodeString())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57489,7 +57489,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
yyv1[yyj1] = ""
|
yyv1[yyj1] = ""
|
||||||
} else {
|
} else {
|
||||||
yyv1[yyj1] = UniqueDeviceName(r.DecodeString())
|
yyv1[yyj1] = UniqueVolumeName(r.DecodeString())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57500,7 +57500,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
for ; !r.CheckBreak(); yyj1++ {
|
for ; !r.CheckBreak(); yyj1++ {
|
||||||
|
|
||||||
if yyj1 >= len(yyv1) {
|
if yyj1 >= len(yyv1) {
|
||||||
yyv1 = append(yyv1, "") // var yyz1 UniqueDeviceName
|
yyv1 = append(yyv1, "") // var yyz1 UniqueVolumeName
|
||||||
yyc1 = true
|
yyc1 = true
|
||||||
}
|
}
|
||||||
yyh1.ElemContainerState(yyj1)
|
yyh1.ElemContainerState(yyj1)
|
||||||
|
@ -57508,7 +57508,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
yyv1[yyj1] = ""
|
yyv1[yyj1] = ""
|
||||||
} else {
|
} else {
|
||||||
yyv1[yyj1] = UniqueDeviceName(r.DecodeString())
|
yyv1[yyj1] = UniqueVolumeName(r.DecodeString())
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -57520,7 +57520,7 @@ func (x codecSelfer1234) decSliceUniqueDeviceName(v *[]UniqueDeviceName, d *code
|
||||||
yyv1 = yyv1[:yyj1]
|
yyv1 = yyv1[:yyj1]
|
||||||
yyc1 = true
|
yyc1 = true
|
||||||
} else if yyj1 == 0 && yyv1 == nil {
|
} else if yyj1 == 0 && yyv1 == nil {
|
||||||
yyv1 = []UniqueDeviceName{}
|
yyv1 = []UniqueVolumeName{}
|
||||||
yyc1 = true
|
yyc1 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2386,11 +2386,11 @@ type NodeStatus struct {
|
||||||
NodeInfo NodeSystemInfo `json:"nodeInfo,omitempty" protobuf:"bytes,7,opt,name=nodeInfo"`
|
NodeInfo NodeSystemInfo `json:"nodeInfo,omitempty" protobuf:"bytes,7,opt,name=nodeInfo"`
|
||||||
// List of container images on this node
|
// List of container images on this node
|
||||||
Images []ContainerImage `json:"images,omitempty" protobuf:"bytes,8,rep,name=images"`
|
Images []ContainerImage `json:"images,omitempty" protobuf:"bytes,8,rep,name=images"`
|
||||||
// List of volumes in use (mounted) by the node.
|
// List of attachable volume devices in use (mounted) by the node.
|
||||||
VolumesInUse []UniqueDeviceName `json:"volumesInUse,omitempty" protobuf:"bytes,9,rep,name=volumesInUse"`
|
VolumesInUse []UniqueVolumeName `json:"volumesInUse,omitempty" protobuf:"bytes,9,rep,name=volumesInUse"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UniqueDeviceName string
|
type UniqueVolumeName string
|
||||||
|
|
||||||
// Describe a container image
|
// Describe a container image
|
||||||
type ContainerImage struct {
|
type ContainerImage struct {
|
||||||
|
|
|
@ -880,7 +880,7 @@ var map_NodeStatus = map[string]string{
|
||||||
"daemonEndpoints": "Endpoints of daemons running on the Node.",
|
"daemonEndpoints": "Endpoints of daemons running on the Node.",
|
||||||
"nodeInfo": "Set of ids/uuids to uniquely identify the node. More info: http://releases.k8s.io/HEAD/docs/admin/node.md#node-info",
|
"nodeInfo": "Set of ids/uuids to uniquely identify the node. More info: http://releases.k8s.io/HEAD/docs/admin/node.md#node-info",
|
||||||
"images": "List of container images on this node",
|
"images": "List of container images on this node",
|
||||||
"volumesInUse": "List of volumes in use (mounted) by the node.",
|
"volumesInUse": "List of attachable volume devices in use (mounted) by the node.",
|
||||||
}
|
}
|
||||||
|
|
||||||
func (NodeStatus) SwaggerDoc() map[string]string {
|
func (NodeStatus) SwaggerDoc() map[string]string {
|
||||||
|
|
|
@ -1154,7 +1154,7 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa
|
||||||
|
|
||||||
// Add annBoundByController (used in deleting the volume)
|
// Add annBoundByController (used in deleting the volume)
|
||||||
setAnnotation(&volume.ObjectMeta, annBoundByController, "yes")
|
setAnnotation(&volume.ObjectMeta, annBoundByController, "yes")
|
||||||
setAnnotation(&volume.ObjectMeta, annDynamicallyProvisioned, plugin.Name())
|
setAnnotation(&volume.ObjectMeta, annDynamicallyProvisioned, plugin.GetPluginName())
|
||||||
|
|
||||||
// Try to create the PV object several times
|
// Try to create the PV object several times
|
||||||
for i := 0; i < ctrl.createProvisionedPVRetryCount; i++ {
|
for i := 0; i < ctrl.createProvisionedPVRetryCount; i++ {
|
||||||
|
|
|
@ -35,7 +35,7 @@ import (
|
||||||
"k8s.io/kubernetes/pkg/util/mount"
|
"k8s.io/kubernetes/pkg/util/mount"
|
||||||
"k8s.io/kubernetes/pkg/util/runtime"
|
"k8s.io/kubernetes/pkg/util/runtime"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
"k8s.io/kubernetes/pkg/volume/util/attachdetach"
|
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -205,7 +205,7 @@ func (adc *attachDetachController) nodeAdd(obj interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeName := node.Name
|
nodeName := node.Name
|
||||||
if _, exists := node.Annotations[attachdetach.ControllerManagedAnnotation]; exists {
|
if _, exists := node.Annotations[volumehelper.ControllerManagedAnnotation]; exists {
|
||||||
// Node specifies annotation indicating it should be managed by attach
|
// Node specifies annotation indicating it should be managed by attach
|
||||||
// detach controller. Add it to desired state of world.
|
// detach controller. Add it to desired state of world.
|
||||||
adc.desiredStateOfWorld.AddNode(nodeName)
|
adc.desiredStateOfWorld.AddNode(nodeName)
|
||||||
|
@ -284,10 +284,11 @@ func (adc *attachDetachController) processPodVolumes(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uniquePodName := getUniquePodName(pod)
|
||||||
if addVolumes {
|
if addVolumes {
|
||||||
// Add volume to desired state of world
|
// Add volume to desired state of world
|
||||||
_, err := adc.desiredStateOfWorld.AddPod(
|
_, err := adc.desiredStateOfWorld.AddPod(
|
||||||
getUniquePodName(pod), volumeSpec, pod.Spec.NodeName)
|
uniquePodName, volumeSpec, pod.Spec.NodeName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(10).Infof(
|
glog.V(10).Infof(
|
||||||
"Failed to add volume %q for pod %q/%q to desiredStateOfWorld. %v",
|
"Failed to add volume %q for pod %q/%q to desiredStateOfWorld. %v",
|
||||||
|
@ -299,11 +300,11 @@ func (adc *attachDetachController) processPodVolumes(
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Remove volume from desired state of world
|
// Remove volume from desired state of world
|
||||||
uniqueVolumeName, err := attachdetach.GetUniqueDeviceNameFromSpec(
|
uniqueVolumeName, err := volumehelper.GetUniqueVolumeNameFromSpec(
|
||||||
attachableVolumePlugin, volumeSpec)
|
attachableVolumePlugin, volumeSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(10).Infof(
|
glog.V(10).Infof(
|
||||||
"Failed to delete volume %q for pod %q/%q from desiredStateOfWorld. GenerateUniqueDeviceName failed with %v",
|
"Failed to delete volume %q for pod %q/%q from desiredStateOfWorld. GenerateUniqueVolumeName failed with %v",
|
||||||
podVolume.Name,
|
podVolume.Name,
|
||||||
pod.Namespace,
|
pod.Namespace,
|
||||||
pod.Name,
|
pod.Name,
|
||||||
|
@ -311,7 +312,7 @@ func (adc *attachDetachController) processPodVolumes(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
adc.desiredStateOfWorld.DeletePod(
|
adc.desiredStateOfWorld.DeletePod(
|
||||||
getUniquePodName(pod), uniqueVolumeName, pod.Spec.NodeName)
|
uniquePodName, uniqueVolumeName, pod.Spec.NodeName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,7 +483,7 @@ func (adc *attachDetachController) getPVSpecFromCache(
|
||||||
// corresponding volume in the actual state of the world to indicate that it is
|
// corresponding volume in the actual state of the world to indicate that it is
|
||||||
// mounted.
|
// mounted.
|
||||||
func (adc *attachDetachController) processVolumesInUse(
|
func (adc *attachDetachController) processVolumesInUse(
|
||||||
nodeName string, volumesInUse []api.UniqueDeviceName) {
|
nodeName string, volumesInUse []api.UniqueVolumeName) {
|
||||||
for _, attachedVolume := range adc.actualStateOfWorld.GetAttachedVolumesForNode(nodeName) {
|
for _, attachedVolume := range adc.actualStateOfWorld.GetAttachedVolumesForNode(nodeName) {
|
||||||
mounted := false
|
mounted := false
|
||||||
for _, volumeInUse := range volumesInUse {
|
for _, volumeInUse := range volumesInUse {
|
||||||
|
@ -502,8 +503,8 @@ func (adc *attachDetachController) processVolumesInUse(
|
||||||
}
|
}
|
||||||
|
|
||||||
// getUniquePodName returns a unique name to reference pod by in memory caches
|
// getUniquePodName returns a unique name to reference pod by in memory caches
|
||||||
func getUniquePodName(pod *api.Pod) string {
|
func getUniquePodName(pod *api.Pod) types.UniquePodName {
|
||||||
return types.NamespacedName{Namespace: pod.Namespace, Name: pod.Name}.String()
|
return types.NamespacedName{Namespace: pod.Namespace, Name: pod.Name}.UniquePodName()
|
||||||
}
|
}
|
||||||
|
|
||||||
// VolumeHost implementation
|
// VolumeHost implementation
|
||||||
|
|
|
@ -155,7 +155,7 @@ func (ad *attacherDetacher) generateDetachVolumeFunc(
|
||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceName, err := attachableVolumePlugin.GetDeviceName(volumeToDetach.VolumeSpec)
|
deviceName, err := attachableVolumePlugin.GetVolumeName(volumeToDetach.VolumeSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf(
|
return nil, fmt.Errorf(
|
||||||
"failed to GetDeviceName from AttachablePlugin for volumeSpec %q err=%v",
|
"failed to GetDeviceName from AttachablePlugin for volumeSpec %q err=%v",
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
"k8s.io/kubernetes/pkg/volume/util/attachdetach"
|
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ActualStateOfWorld defines a set of thread-safe operations supported on
|
// ActualStateOfWorld defines a set of thread-safe operations supported on
|
||||||
|
@ -47,7 +47,7 @@ type ActualStateOfWorld interface {
|
||||||
// added.
|
// added.
|
||||||
// If no node with the name nodeName exists in list of attached nodes for
|
// If no node with the name nodeName exists in list of attached nodes for
|
||||||
// the specified volume, the node is added.
|
// the specified volume, the node is added.
|
||||||
AddVolumeNode(volumeSpec *volume.Spec, nodeName string) (api.UniqueDeviceName, error)
|
AddVolumeNode(volumeSpec *volume.Spec, nodeName string) (api.UniqueVolumeName, error)
|
||||||
|
|
||||||
// SetVolumeMountedByNode sets the MountedByNode value for the given volume
|
// SetVolumeMountedByNode sets the MountedByNode value for the given volume
|
||||||
// and node. When set to true this value indicates the volume is mounted by
|
// and node. When set to true this value indicates the volume is mounted by
|
||||||
|
@ -56,7 +56,7 @@ type ActualStateOfWorld interface {
|
||||||
// returned.
|
// returned.
|
||||||
// If no node with the name nodeName exists in list of attached nodes for
|
// If no node with the name nodeName exists in list of attached nodes for
|
||||||
// the specified volume, an error is returned.
|
// the specified volume, an error is returned.
|
||||||
SetVolumeMountedByNode(volumeName api.UniqueDeviceName, nodeName string, mounted bool) error
|
SetVolumeMountedByNode(volumeName api.UniqueVolumeName, nodeName string, mounted bool) error
|
||||||
|
|
||||||
// MarkDesireToDetach returns the difference between the current time and
|
// MarkDesireToDetach returns the difference between the current time and
|
||||||
// the DetachRequestedTime for the given volume/node combo. If the
|
// the DetachRequestedTime for the given volume/node combo. If the
|
||||||
|
@ -65,7 +65,7 @@ type ActualStateOfWorld interface {
|
||||||
// returned.
|
// returned.
|
||||||
// If no node with the name nodeName exists in list of attached nodes for
|
// If no node with the name nodeName exists in list of attached nodes for
|
||||||
// the specified volume, an error is returned.
|
// the specified volume, an error is returned.
|
||||||
MarkDesireToDetach(volumeName api.UniqueDeviceName, nodeName string) (time.Duration, error)
|
MarkDesireToDetach(volumeName api.UniqueVolumeName, nodeName string) (time.Duration, error)
|
||||||
|
|
||||||
// DeleteVolumeNode removes the given volume and node from the underlying
|
// DeleteVolumeNode removes the given volume and node from the underlying
|
||||||
// store indicating the specified volume is no longer attached to the
|
// store indicating the specified volume is no longer attached to the
|
||||||
|
@ -73,12 +73,12 @@ type ActualStateOfWorld interface {
|
||||||
// If the volume/node combo does not exist, this is a no-op.
|
// If the volume/node combo does not exist, this is a no-op.
|
||||||
// If after deleting the node, the specified volume contains no other child
|
// If after deleting the node, the specified volume contains no other child
|
||||||
// nodes, the volume is also deleted.
|
// nodes, the volume is also deleted.
|
||||||
DeleteVolumeNode(volumeName api.UniqueDeviceName, nodeName string)
|
DeleteVolumeNode(volumeName api.UniqueVolumeName, nodeName string)
|
||||||
|
|
||||||
// VolumeNodeExists returns true if the specified volume/node combo exists
|
// VolumeNodeExists returns true if the specified volume/node combo exists
|
||||||
// in the underlying store indicating the specified volume is attached to
|
// in the underlying store indicating the specified volume is attached to
|
||||||
// the specified node.
|
// the specified node.
|
||||||
VolumeNodeExists(volumeName api.UniqueDeviceName, nodeName string) bool
|
VolumeNodeExists(volumeName api.UniqueVolumeName, nodeName string) bool
|
||||||
|
|
||||||
// GetAttachedVolumes generates and returns a list of volumes/node pairs
|
// GetAttachedVolumes generates and returns a list of volumes/node pairs
|
||||||
// reflecting which volumes are attached to which nodes based on the
|
// reflecting which volumes are attached to which nodes based on the
|
||||||
|
@ -94,7 +94,7 @@ type ActualStateOfWorld interface {
|
||||||
// AttachedVolume represents a volume that is attached to a node.
|
// AttachedVolume represents a volume that is attached to a node.
|
||||||
type AttachedVolume struct {
|
type AttachedVolume struct {
|
||||||
// VolumeName is the unique identifier for the volume that is attached.
|
// VolumeName is the unique identifier for the volume that is attached.
|
||||||
VolumeName api.UniqueDeviceName
|
VolumeName api.UniqueVolumeName
|
||||||
|
|
||||||
// VolumeSpec is the volume spec containing the specification for the
|
// VolumeSpec is the volume spec containing the specification for the
|
||||||
// volume that is attached.
|
// volume that is attached.
|
||||||
|
@ -119,7 +119,7 @@ type AttachedVolume struct {
|
||||||
// NewActualStateOfWorld returns a new instance of ActualStateOfWorld.
|
// NewActualStateOfWorld returns a new instance of ActualStateOfWorld.
|
||||||
func NewActualStateOfWorld(volumePluginMgr *volume.VolumePluginMgr) ActualStateOfWorld {
|
func NewActualStateOfWorld(volumePluginMgr *volume.VolumePluginMgr) ActualStateOfWorld {
|
||||||
return &actualStateOfWorld{
|
return &actualStateOfWorld{
|
||||||
attachedVolumes: make(map[api.UniqueDeviceName]attachedVolume),
|
attachedVolumes: make(map[api.UniqueVolumeName]attachedVolume),
|
||||||
volumePluginMgr: volumePluginMgr,
|
volumePluginMgr: volumePluginMgr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ type actualStateOfWorld struct {
|
||||||
// controller believes to be successfully attached to the nodes it is
|
// controller believes to be successfully attached to the nodes it is
|
||||||
// managing. The key in this map is the name of the volume and the value is
|
// managing. The key in this map is the name of the volume and the value is
|
||||||
// an object containing more information about the attached volume.
|
// an object containing more information about the attached volume.
|
||||||
attachedVolumes map[api.UniqueDeviceName]attachedVolume
|
attachedVolumes map[api.UniqueVolumeName]attachedVolume
|
||||||
// volumePluginMgr is the volume plugin manager used to create volume
|
// volumePluginMgr is the volume plugin manager used to create volume
|
||||||
// plugin objects.
|
// plugin objects.
|
||||||
volumePluginMgr *volume.VolumePluginMgr
|
volumePluginMgr *volume.VolumePluginMgr
|
||||||
|
@ -140,7 +140,7 @@ type actualStateOfWorld struct {
|
||||||
// believes to be succesfully attached to a node it is managing.
|
// believes to be succesfully attached to a node it is managing.
|
||||||
type attachedVolume struct {
|
type attachedVolume struct {
|
||||||
// volumeName contains the unique identifier for this volume.
|
// volumeName contains the unique identifier for this volume.
|
||||||
volumeName api.UniqueDeviceName
|
volumeName api.UniqueVolumeName
|
||||||
|
|
||||||
// spec is the volume spec containing the specification for this volume.
|
// spec is the volume spec containing the specification for this volume.
|
||||||
// Used to generate the volume plugin object, and passed to attach/detach
|
// Used to generate the volume plugin object, and passed to attach/detach
|
||||||
|
@ -174,7 +174,7 @@ type nodeAttachedTo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (asw *actualStateOfWorld) AddVolumeNode(
|
func (asw *actualStateOfWorld) AddVolumeNode(
|
||||||
volumeSpec *volume.Spec, nodeName string) (api.UniqueDeviceName, error) {
|
volumeSpec *volume.Spec, nodeName string) (api.UniqueVolumeName, error) {
|
||||||
asw.Lock()
|
asw.Lock()
|
||||||
defer asw.Unlock()
|
defer asw.Unlock()
|
||||||
|
|
||||||
|
@ -186,11 +186,11 @@ func (asw *actualStateOfWorld) AddVolumeNode(
|
||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
|
||||||
volumeName, err := attachdetach.GetUniqueDeviceNameFromSpec(
|
volumeName, err := volumehelper.GetUniqueVolumeNameFromSpec(
|
||||||
attachableVolumePlugin, volumeSpec)
|
attachableVolumePlugin, volumeSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf(
|
return "", fmt.Errorf(
|
||||||
"failed to GetUniqueDeviceNameFromSpec for volumeSpec %q err=%v",
|
"failed to GetUniqueVolumeNameFromSpec for volumeSpec %q err=%v",
|
||||||
volumeSpec.Name(),
|
volumeSpec.Name(),
|
||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ func (asw *actualStateOfWorld) AddVolumeNode(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (asw *actualStateOfWorld) SetVolumeMountedByNode(
|
func (asw *actualStateOfWorld) SetVolumeMountedByNode(
|
||||||
volumeName api.UniqueDeviceName, nodeName string, mounted bool) error {
|
volumeName api.UniqueVolumeName, nodeName string, mounted bool) error {
|
||||||
asw.Lock()
|
asw.Lock()
|
||||||
defer asw.Unlock()
|
defer asw.Unlock()
|
||||||
volumeObj, volumeExists := asw.attachedVolumes[volumeName]
|
volumeObj, volumeExists := asw.attachedVolumes[volumeName]
|
||||||
|
@ -262,7 +262,7 @@ func (asw *actualStateOfWorld) SetVolumeMountedByNode(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (asw *actualStateOfWorld) MarkDesireToDetach(
|
func (asw *actualStateOfWorld) MarkDesireToDetach(
|
||||||
volumeName api.UniqueDeviceName, nodeName string) (time.Duration, error) {
|
volumeName api.UniqueVolumeName, nodeName string) (time.Duration, error) {
|
||||||
asw.Lock()
|
asw.Lock()
|
||||||
defer asw.Unlock()
|
defer asw.Unlock()
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ func (asw *actualStateOfWorld) MarkDesireToDetach(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (asw *actualStateOfWorld) DeleteVolumeNode(
|
func (asw *actualStateOfWorld) DeleteVolumeNode(
|
||||||
volumeName api.UniqueDeviceName, nodeName string) {
|
volumeName api.UniqueVolumeName, nodeName string) {
|
||||||
asw.Lock()
|
asw.Lock()
|
||||||
defer asw.Unlock()
|
defer asw.Unlock()
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ func (asw *actualStateOfWorld) DeleteVolumeNode(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (asw *actualStateOfWorld) VolumeNodeExists(
|
func (asw *actualStateOfWorld) VolumeNodeExists(
|
||||||
volumeName api.UniqueDeviceName, nodeName string) bool {
|
volumeName api.UniqueVolumeName, nodeName string) bool {
|
||||||
asw.RLock()
|
asw.RLock()
|
||||||
defer asw.RUnlock()
|
defer asw.RUnlock()
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ func Test_AddVolumeNode_Positive_NewVolumeNewNode(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
|
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
|
@ -61,7 +61,7 @@ func Test_AddVolumeNode_Positive_ExistingVolumeNewNode(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
node1Name := "node1-name"
|
node1Name := "node1-name"
|
||||||
node2Name := "node2-name"
|
node2Name := "node2-name"
|
||||||
|
@ -110,7 +110,7 @@ func Test_AddVolumeNode_Positive_ExistingVolumeExistingNode(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ func Test_DeleteVolumeNode_Positive_VolumeExistsNodeExists(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -182,7 +182,7 @@ func Test_DeleteVolumeNode_Positive_VolumeDoesntExistNodeDoesntExist(t *testing.
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
@ -208,7 +208,7 @@ func Test_DeleteVolumeNode_Positive_TwoNodesOneDeleted(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
node1Name := "node1-name"
|
node1Name := "node1-name"
|
||||||
node2Name := "node2-name"
|
node2Name := "node2-name"
|
||||||
|
@ -256,7 +256,7 @@ func Test_VolumeNodeExists_Positive_VolumeExistsNodeExists(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -287,7 +287,7 @@ func Test_VolumeNodeExists_Positive_VolumeExistsNodeDoesntExist(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
node1Name := "node1-name"
|
node1Name := "node1-name"
|
||||||
node2Name := "node2-name"
|
node2Name := "node2-name"
|
||||||
|
@ -318,7 +318,7 @@ func Test_VolumeNodeExists_Positive_VolumeAndNodeDontExist(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
@ -358,7 +358,7 @@ func Test_GetAttachedVolumes_Positive_OneVolumeOneNode(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -384,14 +384,14 @@ func Test_GetAttachedVolumes_Positive_TwoVolumeTwoNodes(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volume1Name := api.UniqueDeviceName("volume1-name")
|
volume1Name := api.UniqueVolumeName("volume1-name")
|
||||||
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
||||||
node1Name := "node1-name"
|
node1Name := "node1-name"
|
||||||
generatedVolumeName1, add1Err := asw.AddVolumeNode(volume1Spec, node1Name)
|
generatedVolumeName1, add1Err := asw.AddVolumeNode(volume1Spec, node1Name)
|
||||||
if add1Err != nil {
|
if add1Err != nil {
|
||||||
t.Fatalf("AddVolumeNode failed. Expected: <no error> Actual: <%v>", add1Err)
|
t.Fatalf("AddVolumeNode failed. Expected: <no error> Actual: <%v>", add1Err)
|
||||||
}
|
}
|
||||||
volume2Name := api.UniqueDeviceName("volume2-name")
|
volume2Name := api.UniqueVolumeName("volume2-name")
|
||||||
volume2Spec := controllervolumetesting.GetTestVolumeSpec(string(volume2Name), volume2Name)
|
volume2Spec := controllervolumetesting.GetTestVolumeSpec(string(volume2Name), volume2Name)
|
||||||
node2Name := "node2-name"
|
node2Name := "node2-name"
|
||||||
generatedVolumeName2, add2Err := asw.AddVolumeNode(volume2Spec, node2Name)
|
generatedVolumeName2, add2Err := asw.AddVolumeNode(volume2Spec, node2Name)
|
||||||
|
@ -418,7 +418,7 @@ func Test_GetAttachedVolumes_Positive_OneVolumeTwoNodes(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
node1Name := "node1-name"
|
node1Name := "node1-name"
|
||||||
generatedVolumeName1, add1Err := asw.AddVolumeNode(volumeSpec, node1Name)
|
generatedVolumeName1, add1Err := asw.AddVolumeNode(volumeSpec, node1Name)
|
||||||
|
@ -456,7 +456,7 @@ func Test_SetVolumeMountedByNode_Positive_Set(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -482,7 +482,7 @@ func Test_SetVolumeMountedByNode_Positive_UnsetWithInitialSet(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -517,7 +517,7 @@ func Test_SetVolumeMountedByNode_Positive_UnsetWithoutInitialSet(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -549,7 +549,7 @@ func Test_SetVolumeMountedByNode_Positive_UnsetWithInitialSetAddVolumeNodeNotRes
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -589,7 +589,7 @@ func Test_SetVolumeMountedByNode_Positive_UnsetWithInitialSetVerifyDetachRequest
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -631,7 +631,7 @@ func Test_MarkDesireToDetach_Positive_Set(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -657,7 +657,7 @@ func Test_MarkDesireToDetach_Positive_Marked(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -690,7 +690,7 @@ func Test_MarkDesireToDetach_Positive_MarkedAddVolumeNodeReset(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -727,7 +727,7 @@ func Test_MarkDesireToDetach_Positive_UnsetWithInitialSetVolumeMountedByNodePres
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
asw := NewActualStateOfWorld(volumePluginMgr)
|
asw := NewActualStateOfWorld(volumePluginMgr)
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
generatedVolumeName, addErr := asw.AddVolumeNode(volumeSpec, nodeName)
|
||||||
|
@ -763,7 +763,7 @@ func Test_MarkDesireToDetach_Positive_UnsetWithInitialSetVolumeMountedByNodePres
|
||||||
func verifyAttachedVolume(
|
func verifyAttachedVolume(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
attachedVolumes []AttachedVolume,
|
attachedVolumes []AttachedVolume,
|
||||||
expectedVolumeName api.UniqueDeviceName,
|
expectedVolumeName api.UniqueVolumeName,
|
||||||
expectedVolumeSpecName string,
|
expectedVolumeSpecName string,
|
||||||
expectedNodeName string,
|
expectedNodeName string,
|
||||||
expectedMountedByNode,
|
expectedMountedByNode,
|
||||||
|
|
|
@ -26,8 +26,9 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
"k8s.io/kubernetes/pkg/types"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
"k8s.io/kubernetes/pkg/volume/util/attachdetach"
|
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DesiredStateOfWorld defines a set of thread-safe operations supported on
|
// DesiredStateOfWorld defines a set of thread-safe operations supported on
|
||||||
|
@ -52,7 +53,7 @@ type DesiredStateOfWorld interface {
|
||||||
// should be attached to the specified node, the volume is implicitly added.
|
// should be attached to the specified node, the volume is implicitly added.
|
||||||
// If no node with the name nodeName exists in list of nodes managed by the
|
// If no node with the name nodeName exists in list of nodes managed by the
|
||||||
// attach/detach attached controller, an error is returned.
|
// attach/detach attached controller, an error is returned.
|
||||||
AddPod(podName string, volumeSpec *volume.Spec, nodeName string) (api.UniqueDeviceName, error)
|
AddPod(podName types.UniquePodName, volumeSpec *volume.Spec, nodeName string) (api.UniqueVolumeName, error)
|
||||||
|
|
||||||
// DeleteNode removes the given node from the list of nodes managed by the
|
// DeleteNode removes the given node from the list of nodes managed by the
|
||||||
// attach/detach controller.
|
// attach/detach controller.
|
||||||
|
@ -70,7 +71,7 @@ type DesiredStateOfWorld interface {
|
||||||
// volumes under the specified node, this is a no-op.
|
// volumes under the specified node, this is a no-op.
|
||||||
// If after deleting the pod, the specified volume contains no other child
|
// If after deleting the pod, the specified volume contains no other child
|
||||||
// pods, the volume is also deleted.
|
// pods, the volume is also deleted.
|
||||||
DeletePod(podName string, volumeName api.UniqueDeviceName, nodeName string)
|
DeletePod(podName types.UniquePodName, volumeName api.UniqueVolumeName, nodeName string)
|
||||||
|
|
||||||
// NodeExists returns true if the node with the specified name exists in
|
// NodeExists returns true if the node with the specified name exists in
|
||||||
// the list of nodes managed by the attach/detach controller.
|
// the list of nodes managed by the attach/detach controller.
|
||||||
|
@ -79,7 +80,7 @@ type DesiredStateOfWorld interface {
|
||||||
// VolumeExists returns true if the volume with the specified name exists
|
// VolumeExists returns true if the volume with the specified name exists
|
||||||
// in the list of volumes that should be attached to the specified node by
|
// in the list of volumes that should be attached to the specified node by
|
||||||
// the attach detach controller.
|
// the attach detach controller.
|
||||||
VolumeExists(volumeName api.UniqueDeviceName, nodeName string) bool
|
VolumeExists(volumeName api.UniqueVolumeName, nodeName string) bool
|
||||||
|
|
||||||
// GetVolumesToAttach generates and returns a list of volumes to attach
|
// GetVolumesToAttach generates and returns a list of volumes to attach
|
||||||
// and the nodes they should be attached to based on the current desired
|
// and the nodes they should be attached to based on the current desired
|
||||||
|
@ -91,7 +92,7 @@ type DesiredStateOfWorld interface {
|
||||||
type VolumeToAttach struct {
|
type VolumeToAttach struct {
|
||||||
// VolumeName is the unique identifier for the volume that should be
|
// VolumeName is the unique identifier for the volume that should be
|
||||||
// attached.
|
// attached.
|
||||||
VolumeName api.UniqueDeviceName
|
VolumeName api.UniqueVolumeName
|
||||||
|
|
||||||
// VolumeSpec is a volume spec containing the specification for the volume
|
// VolumeSpec is a volume spec containing the specification for the volume
|
||||||
// that should be attached.
|
// that should be attached.
|
||||||
|
@ -130,13 +131,13 @@ type nodeManaged struct {
|
||||||
// volumesToAttach is a map containing the set of volumes that should be
|
// volumesToAttach is a map containing the set of volumes that should be
|
||||||
// attached to this node. The key in the map is the name of the volume and
|
// attached to this node. The key in the map is the name of the volume and
|
||||||
// the value is a pod object containing more information about the volume.
|
// the value is a pod object containing more information about the volume.
|
||||||
volumesToAttach map[api.UniqueDeviceName]volumeToAttach
|
volumesToAttach map[api.UniqueVolumeName]volumeToAttach
|
||||||
}
|
}
|
||||||
|
|
||||||
// The volume object represents a volume that should be attached to a node.
|
// The volume object represents a volume that should be attached to a node.
|
||||||
type volumeToAttach struct {
|
type volumeToAttach struct {
|
||||||
// volumeName contains the unique identifier for this volume.
|
// volumeName contains the unique identifier for this volume.
|
||||||
volumeName api.UniqueDeviceName
|
volumeName api.UniqueVolumeName
|
||||||
|
|
||||||
// spec is the volume spec containing the specification for this volume.
|
// spec is the volume spec containing the specification for this volume.
|
||||||
// Used to generate the volume plugin object, and passed to attach/detach
|
// Used to generate the volume plugin object, and passed to attach/detach
|
||||||
|
@ -147,14 +148,14 @@ type volumeToAttach struct {
|
||||||
// volume and are scheduled to the underlying node. The key in the map is
|
// volume and are scheduled to the underlying node. The key in the map is
|
||||||
// the name of the pod and the value is a pod object containing more
|
// the name of the pod and the value is a pod object containing more
|
||||||
// information about the pod.
|
// information about the pod.
|
||||||
scheduledPods map[string]pod
|
scheduledPods map[types.UniquePodName]pod
|
||||||
}
|
}
|
||||||
|
|
||||||
// The pod object represents a pod that references the underlying volume and is
|
// The pod object represents a pod that references the underlying volume and is
|
||||||
// scheduled to the underlying node.
|
// scheduled to the underlying node.
|
||||||
type pod struct {
|
type pod struct {
|
||||||
// podName contains the name of this pod.
|
// podName contains the name of this pod.
|
||||||
podName string
|
podName types.UniquePodName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dsw *desiredStateOfWorld) AddNode(nodeName string) {
|
func (dsw *desiredStateOfWorld) AddNode(nodeName string) {
|
||||||
|
@ -164,15 +165,15 @@ func (dsw *desiredStateOfWorld) AddNode(nodeName string) {
|
||||||
if _, nodeExists := dsw.nodesManaged[nodeName]; !nodeExists {
|
if _, nodeExists := dsw.nodesManaged[nodeName]; !nodeExists {
|
||||||
dsw.nodesManaged[nodeName] = nodeManaged{
|
dsw.nodesManaged[nodeName] = nodeManaged{
|
||||||
nodeName: nodeName,
|
nodeName: nodeName,
|
||||||
volumesToAttach: make(map[api.UniqueDeviceName]volumeToAttach),
|
volumesToAttach: make(map[api.UniqueVolumeName]volumeToAttach),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dsw *desiredStateOfWorld) AddPod(
|
func (dsw *desiredStateOfWorld) AddPod(
|
||||||
podName string,
|
podName types.UniquePodName,
|
||||||
volumeSpec *volume.Spec,
|
volumeSpec *volume.Spec,
|
||||||
nodeName string) (api.UniqueDeviceName, error) {
|
nodeName string) (api.UniqueVolumeName, error) {
|
||||||
dsw.Lock()
|
dsw.Lock()
|
||||||
defer dsw.Unlock()
|
defer dsw.Unlock()
|
||||||
|
|
||||||
|
@ -191,11 +192,11 @@ func (dsw *desiredStateOfWorld) AddPod(
|
||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
|
||||||
volumeName, err := attachdetach.GetUniqueDeviceNameFromSpec(
|
volumeName, err := volumehelper.GetUniqueVolumeNameFromSpec(
|
||||||
attachableVolumePlugin, volumeSpec)
|
attachableVolumePlugin, volumeSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf(
|
return "", fmt.Errorf(
|
||||||
"failed to GenerateUniqueDeviceName for volumeSpec %q err=%v",
|
"failed to GenerateUniqueVolumeName for volumeSpec %q err=%v",
|
||||||
volumeSpec.Name(),
|
volumeSpec.Name(),
|
||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
@ -205,7 +206,7 @@ func (dsw *desiredStateOfWorld) AddPod(
|
||||||
volumeObj = volumeToAttach{
|
volumeObj = volumeToAttach{
|
||||||
volumeName: volumeName,
|
volumeName: volumeName,
|
||||||
spec: volumeSpec,
|
spec: volumeSpec,
|
||||||
scheduledPods: make(map[string]pod),
|
scheduledPods: make(map[types.UniquePodName]pod),
|
||||||
}
|
}
|
||||||
dsw.nodesManaged[nodeName].volumesToAttach[volumeName] = volumeObj
|
dsw.nodesManaged[nodeName].volumesToAttach[volumeName] = volumeObj
|
||||||
}
|
}
|
||||||
|
@ -243,8 +244,8 @@ func (dsw *desiredStateOfWorld) DeleteNode(nodeName string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dsw *desiredStateOfWorld) DeletePod(
|
func (dsw *desiredStateOfWorld) DeletePod(
|
||||||
podName string,
|
podName types.UniquePodName,
|
||||||
volumeName api.UniqueDeviceName,
|
volumeName api.UniqueVolumeName,
|
||||||
nodeName string) {
|
nodeName string) {
|
||||||
dsw.Lock()
|
dsw.Lock()
|
||||||
defer dsw.Unlock()
|
defer dsw.Unlock()
|
||||||
|
@ -282,7 +283,7 @@ func (dsw *desiredStateOfWorld) NodeExists(nodeName string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dsw *desiredStateOfWorld) VolumeExists(
|
func (dsw *desiredStateOfWorld) VolumeExists(
|
||||||
volumeName api.UniqueDeviceName, nodeName string) bool {
|
volumeName api.UniqueVolumeName, nodeName string) bool {
|
||||||
dsw.RLock()
|
dsw.RLock()
|
||||||
defer dsw.RUnlock()
|
defer dsw.RUnlock()
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
controllervolumetesting "k8s.io/kubernetes/pkg/controller/volume/testing"
|
controllervolumetesting "k8s.io/kubernetes/pkg/controller/volume/testing"
|
||||||
|
"k8s.io/kubernetes/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Calls AddNode() once.
|
// Calls AddNode() once.
|
||||||
|
@ -87,8 +88,8 @@ func Test_AddPod_Positive_NewPodNodeExistsVolumeDoesntExist(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
|
@ -134,9 +135,9 @@ func Test_AddPod_Positive_NewPodNodeExistsVolumeExists(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
pod1Name := "pod1-name"
|
pod1Name := types.UniquePodName("pod1-name")
|
||||||
pod2Name := "pod2-name"
|
pod2Name := types.UniquePodName("pod2-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
|
@ -204,8 +205,8 @@ func Test_AddPod_Positive_PodExistsNodeExistsVolumeExists(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
|
@ -270,8 +271,8 @@ func Test_AddPod_Negative_NewPodNodeDoesntExistVolumeDoesntExist(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
volumeExists := dsw.VolumeExists(volumeName, nodeName)
|
volumeExists := dsw.VolumeExists(volumeName, nodeName)
|
||||||
|
@ -369,8 +370,8 @@ func Test_DeleteNode_Negative_NodeExistsHasChildVolumes(t *testing.T) {
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
generatedVolumeName, podAddErr := dsw.AddPod(podName, volumeSpec, nodeName)
|
generatedVolumeName, podAddErr := dsw.AddPod(podName, volumeSpec, nodeName)
|
||||||
if podAddErr != nil {
|
if podAddErr != nil {
|
||||||
|
@ -408,8 +409,8 @@ func Test_DeletePod_Positive_PodExistsNodeExistsVolumeExists(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
|
@ -455,9 +456,9 @@ func Test_DeletePod_Positive_2PodsExistNodeExistsVolumesExist(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
pod1Name := "pod1-name"
|
pod1Name := types.UniquePodName("pod1-name")
|
||||||
pod2Name := "pod2-name"
|
pod2Name := types.UniquePodName("pod2-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
|
@ -516,9 +517,9 @@ func Test_DeletePod_Positive_PodDoesNotExist(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
pod1Name := "pod1-name"
|
pod1Name := types.UniquePodName("pod1-name")
|
||||||
pod2Name := "pod2-name"
|
pod2Name := types.UniquePodName("pod2-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
|
@ -565,8 +566,8 @@ func Test_DeletePod_Positive_NodeDoesNotExist(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
node1Name := "node1-name"
|
node1Name := "node1-name"
|
||||||
dsw.AddNode(node1Name)
|
dsw.AddNode(node1Name)
|
||||||
|
@ -620,8 +621,8 @@ func Test_DeletePod_Positive_VolumeDoesNotExist(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volume1Name := api.UniqueDeviceName("volume1-name")
|
volume1Name := api.UniqueVolumeName("volume1-name")
|
||||||
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
|
@ -640,7 +641,7 @@ func Test_DeletePod_Positive_VolumeDoesNotExist(t *testing.T) {
|
||||||
generatedVolume1Name,
|
generatedVolume1Name,
|
||||||
nodeName)
|
nodeName)
|
||||||
}
|
}
|
||||||
volume2Name := api.UniqueDeviceName("volume2-name")
|
volume2Name := api.UniqueVolumeName("volume2-name")
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
dsw.DeletePod(podName, volume2Name, nodeName)
|
dsw.DeletePod(podName, volume2Name, nodeName)
|
||||||
|
@ -723,8 +724,8 @@ func Test_VolumeExists_Positive_VolumeExistsNodeExists(t *testing.T) {
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
generatedVolumeName, _ := dsw.AddPod(podName, volumeSpec, nodeName)
|
generatedVolumeName, _ := dsw.AddPod(podName, volumeSpec, nodeName)
|
||||||
|
|
||||||
|
@ -753,8 +754,8 @@ func Test_VolumeExists_Positive_VolumeDoesntExistNodeExists(t *testing.T) {
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volume1Name := api.UniqueDeviceName("volume1-name")
|
volume1Name := api.UniqueVolumeName("volume1-name")
|
||||||
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
||||||
generatedVolume1Name, podAddErr := dsw.AddPod(podName, volume1Spec, nodeName)
|
generatedVolume1Name, podAddErr := dsw.AddPod(podName, volume1Spec, nodeName)
|
||||||
if podAddErr != nil {
|
if podAddErr != nil {
|
||||||
|
@ -763,7 +764,7 @@ func Test_VolumeExists_Positive_VolumeDoesntExistNodeExists(t *testing.T) {
|
||||||
podName,
|
podName,
|
||||||
podAddErr)
|
podAddErr)
|
||||||
}
|
}
|
||||||
volume2Name := api.UniqueDeviceName("volume2-name")
|
volume2Name := api.UniqueVolumeName("volume2-name")
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
volumeExists := dsw.VolumeExists(volume2Name, nodeName)
|
volumeExists := dsw.VolumeExists(volume2Name, nodeName)
|
||||||
|
@ -788,7 +789,7 @@ func Test_VolumeExists_Positive_VolumeDoesntExistNodeDoesntExists(t *testing.T)
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
volumeExists := dsw.VolumeExists(volumeName, nodeName)
|
volumeExists := dsw.VolumeExists(volumeName, nodeName)
|
||||||
|
@ -849,8 +850,8 @@ func Test_GetVolumesToAttach_Positive_TwoNodesOneVolumeEach(t *testing.T) {
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
node1Name := "node1-name"
|
node1Name := "node1-name"
|
||||||
pod1Name := "pod1-name"
|
pod1Name := types.UniquePodName("pod1-name")
|
||||||
volume1Name := api.UniqueDeviceName("volume1-name")
|
volume1Name := api.UniqueVolumeName("volume1-name")
|
||||||
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
||||||
dsw.AddNode(node1Name)
|
dsw.AddNode(node1Name)
|
||||||
generatedVolume1Name, podAddErr := dsw.AddPod(pod1Name, volume1Spec, node1Name)
|
generatedVolume1Name, podAddErr := dsw.AddPod(pod1Name, volume1Spec, node1Name)
|
||||||
|
@ -861,8 +862,8 @@ func Test_GetVolumesToAttach_Positive_TwoNodesOneVolumeEach(t *testing.T) {
|
||||||
podAddErr)
|
podAddErr)
|
||||||
}
|
}
|
||||||
node2Name := "node2-name"
|
node2Name := "node2-name"
|
||||||
pod2Name := "pod2-name"
|
pod2Name := types.UniquePodName("pod2-name")
|
||||||
volume2Name := api.UniqueDeviceName("volume2-name")
|
volume2Name := api.UniqueVolumeName("volume2-name")
|
||||||
volume2Spec := controllervolumetesting.GetTestVolumeSpec(string(volume2Name), volume2Name)
|
volume2Spec := controllervolumetesting.GetTestVolumeSpec(string(volume2Name), volume2Name)
|
||||||
dsw.AddNode(node2Name)
|
dsw.AddNode(node2Name)
|
||||||
generatedVolume2Name, podAddErr := dsw.AddPod(pod2Name, volume2Spec, node2Name)
|
generatedVolume2Name, podAddErr := dsw.AddPod(pod2Name, volume2Spec, node2Name)
|
||||||
|
@ -894,8 +895,8 @@ func Test_GetVolumesToAttach_Positive_TwoNodesOneVolumeEachExtraPod(t *testing.T
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
node1Name := "node1-name"
|
node1Name := "node1-name"
|
||||||
pod1Name := "pod1-name"
|
pod1Name := types.UniquePodName("pod1-name")
|
||||||
volume1Name := api.UniqueDeviceName("volume1-name")
|
volume1Name := api.UniqueVolumeName("volume1-name")
|
||||||
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
||||||
dsw.AddNode(node1Name)
|
dsw.AddNode(node1Name)
|
||||||
generatedVolume1Name, podAddErr := dsw.AddPod(pod1Name, volume1Spec, node1Name)
|
generatedVolume1Name, podAddErr := dsw.AddPod(pod1Name, volume1Spec, node1Name)
|
||||||
|
@ -906,8 +907,8 @@ func Test_GetVolumesToAttach_Positive_TwoNodesOneVolumeEachExtraPod(t *testing.T
|
||||||
podAddErr)
|
podAddErr)
|
||||||
}
|
}
|
||||||
node2Name := "node2-name"
|
node2Name := "node2-name"
|
||||||
pod2Name := "pod2-name"
|
pod2Name := types.UniquePodName("pod2-name")
|
||||||
volume2Name := api.UniqueDeviceName("volume2-name")
|
volume2Name := api.UniqueVolumeName("volume2-name")
|
||||||
volume2Spec := controllervolumetesting.GetTestVolumeSpec(string(volume2Name), volume2Name)
|
volume2Spec := controllervolumetesting.GetTestVolumeSpec(string(volume2Name), volume2Name)
|
||||||
dsw.AddNode(node2Name)
|
dsw.AddNode(node2Name)
|
||||||
generatedVolume2Name, podAddErr := dsw.AddPod(pod2Name, volume2Spec, node2Name)
|
generatedVolume2Name, podAddErr := dsw.AddPod(pod2Name, volume2Spec, node2Name)
|
||||||
|
@ -917,7 +918,7 @@ func Test_GetVolumesToAttach_Positive_TwoNodesOneVolumeEachExtraPod(t *testing.T
|
||||||
pod2Name,
|
pod2Name,
|
||||||
podAddErr)
|
podAddErr)
|
||||||
}
|
}
|
||||||
pod3Name := "pod3-name"
|
pod3Name := types.UniquePodName("pod3-name")
|
||||||
dsw.AddPod(pod3Name, volume2Spec, node2Name)
|
dsw.AddPod(pod3Name, volume2Spec, node2Name)
|
||||||
_, podAddErr = dsw.AddPod(pod3Name, volume2Spec, node2Name)
|
_, podAddErr = dsw.AddPod(pod3Name, volume2Spec, node2Name)
|
||||||
if podAddErr != nil {
|
if podAddErr != nil {
|
||||||
|
@ -948,8 +949,8 @@ func Test_GetVolumesToAttach_Positive_TwoNodesThreeVolumes(t *testing.T) {
|
||||||
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
volumePluginMgr, _ := controllervolumetesting.GetTestVolumePluginMgr((t))
|
||||||
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
dsw := NewDesiredStateOfWorld(volumePluginMgr)
|
||||||
node1Name := "node1-name"
|
node1Name := "node1-name"
|
||||||
pod1Name := "pod1-name"
|
pod1Name := types.UniquePodName("pod1-name")
|
||||||
volume1Name := api.UniqueDeviceName("volume1-name")
|
volume1Name := api.UniqueVolumeName("volume1-name")
|
||||||
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
volume1Spec := controllervolumetesting.GetTestVolumeSpec(string(volume1Name), volume1Name)
|
||||||
dsw.AddNode(node1Name)
|
dsw.AddNode(node1Name)
|
||||||
generatedVolume1Name, podAddErr := dsw.AddPod(pod1Name, volume1Spec, node1Name)
|
generatedVolume1Name, podAddErr := dsw.AddPod(pod1Name, volume1Spec, node1Name)
|
||||||
|
@ -960,8 +961,8 @@ func Test_GetVolumesToAttach_Positive_TwoNodesThreeVolumes(t *testing.T) {
|
||||||
podAddErr)
|
podAddErr)
|
||||||
}
|
}
|
||||||
node2Name := "node2-name"
|
node2Name := "node2-name"
|
||||||
pod2aName := "pod2a-name"
|
pod2aName := types.UniquePodName("pod2a-name")
|
||||||
volume2Name := api.UniqueDeviceName("volume2-name")
|
volume2Name := api.UniqueVolumeName("volume2-name")
|
||||||
volume2Spec := controllervolumetesting.GetTestVolumeSpec(string(volume2Name), volume2Name)
|
volume2Spec := controllervolumetesting.GetTestVolumeSpec(string(volume2Name), volume2Name)
|
||||||
dsw.AddNode(node2Name)
|
dsw.AddNode(node2Name)
|
||||||
generatedVolume2Name1, podAddErr := dsw.AddPod(pod2aName, volume2Spec, node2Name)
|
generatedVolume2Name1, podAddErr := dsw.AddPod(pod2aName, volume2Spec, node2Name)
|
||||||
|
@ -971,7 +972,7 @@ func Test_GetVolumesToAttach_Positive_TwoNodesThreeVolumes(t *testing.T) {
|
||||||
pod2aName,
|
pod2aName,
|
||||||
podAddErr)
|
podAddErr)
|
||||||
}
|
}
|
||||||
pod2bName := "pod2b-name"
|
pod2bName := types.UniquePodName("pod2b-name")
|
||||||
generatedVolume2Name2, podAddErr := dsw.AddPod(pod2bName, volume2Spec, node2Name)
|
generatedVolume2Name2, podAddErr := dsw.AddPod(pod2bName, volume2Spec, node2Name)
|
||||||
if podAddErr != nil {
|
if podAddErr != nil {
|
||||||
t.Fatalf(
|
t.Fatalf(
|
||||||
|
@ -985,8 +986,8 @@ func Test_GetVolumesToAttach_Positive_TwoNodesThreeVolumes(t *testing.T) {
|
||||||
generatedVolume2Name1,
|
generatedVolume2Name1,
|
||||||
generatedVolume2Name2)
|
generatedVolume2Name2)
|
||||||
}
|
}
|
||||||
pod3Name := "pod3-name"
|
pod3Name := types.UniquePodName("pod3-name")
|
||||||
volume3Name := api.UniqueDeviceName("volume3-name")
|
volume3Name := api.UniqueVolumeName("volume3-name")
|
||||||
volume3Spec := controllervolumetesting.GetTestVolumeSpec(string(volume3Name), volume3Name)
|
volume3Spec := controllervolumetesting.GetTestVolumeSpec(string(volume3Name), volume3Name)
|
||||||
generatedVolume3Name, podAddErr := dsw.AddPod(pod3Name, volume3Spec, node1Name)
|
generatedVolume3Name, podAddErr := dsw.AddPod(pod3Name, volume3Spec, node1Name)
|
||||||
if podAddErr != nil {
|
if podAddErr != nil {
|
||||||
|
@ -1013,7 +1014,7 @@ func verifyVolumeToAttach(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
volumesToAttach []VolumeToAttach,
|
volumesToAttach []VolumeToAttach,
|
||||||
expectedNodeName string,
|
expectedNodeName string,
|
||||||
expectedVolumeName api.UniqueDeviceName,
|
expectedVolumeName api.UniqueVolumeName,
|
||||||
expectedVolumeSpecName string) {
|
expectedVolumeSpecName string) {
|
||||||
for _, volumeToAttach := range volumesToAttach {
|
for _, volumeToAttach := range volumesToAttach {
|
||||||
if volumeToAttach.NodeName == expectedNodeName &&
|
if volumeToAttach.NodeName == expectedNodeName &&
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"k8s.io/kubernetes/pkg/controller/volume/attacherdetacher"
|
"k8s.io/kubernetes/pkg/controller/volume/attacherdetacher"
|
||||||
"k8s.io/kubernetes/pkg/controller/volume/cache"
|
"k8s.io/kubernetes/pkg/controller/volume/cache"
|
||||||
controllervolumetesting "k8s.io/kubernetes/pkg/controller/volume/testing"
|
controllervolumetesting "k8s.io/kubernetes/pkg/controller/volume/testing"
|
||||||
|
"k8s.io/kubernetes/pkg/types"
|
||||||
"k8s.io/kubernetes/pkg/util/wait"
|
"k8s.io/kubernetes/pkg/util/wait"
|
||||||
volumetesting "k8s.io/kubernetes/pkg/volume/testing"
|
volumetesting "k8s.io/kubernetes/pkg/volume/testing"
|
||||||
)
|
)
|
||||||
|
@ -66,8 +67,8 @@ func Test_Run_Positive_OneDesiredVolumeAttach(t *testing.T) {
|
||||||
ad := attacherdetacher.NewAttacherDetacher(volumePluginMgr)
|
ad := attacherdetacher.NewAttacherDetacher(volumePluginMgr)
|
||||||
reconciler := NewReconciler(
|
reconciler := NewReconciler(
|
||||||
reconcilerLoopPeriod, maxWaitForUnmountDuration, dsw, asw, ad)
|
reconcilerLoopPeriod, maxWaitForUnmountDuration, dsw, asw, ad)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
|
@ -107,8 +108,8 @@ func Test_Run_Positive_OneDesiredVolumeAttachThenDetachWithUnmountedVolume(t *te
|
||||||
ad := attacherdetacher.NewAttacherDetacher(volumePluginMgr)
|
ad := attacherdetacher.NewAttacherDetacher(volumePluginMgr)
|
||||||
reconciler := NewReconciler(
|
reconciler := NewReconciler(
|
||||||
reconcilerLoopPeriod, maxWaitForUnmountDuration, dsw, asw, ad)
|
reconcilerLoopPeriod, maxWaitForUnmountDuration, dsw, asw, ad)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
|
@ -169,8 +170,8 @@ func Test_Run_Positive_OneDesiredVolumeAttachThenDetachWithMountedVolume(t *test
|
||||||
ad := attacherdetacher.NewAttacherDetacher(volumePluginMgr)
|
ad := attacherdetacher.NewAttacherDetacher(volumePluginMgr)
|
||||||
reconciler := NewReconciler(
|
reconciler := NewReconciler(
|
||||||
reconcilerLoopPeriod, maxWaitForUnmountDuration, dsw, asw, ad)
|
reconcilerLoopPeriod, maxWaitForUnmountDuration, dsw, asw, ad)
|
||||||
podName := "pod-name"
|
podName := types.UniquePodName("pod-name")
|
||||||
volumeName := api.UniqueDeviceName("volume-name")
|
volumeName := api.UniqueVolumeName("volume-name")
|
||||||
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
|
||||||
nodeName := "node-name"
|
nodeName := "node-name"
|
||||||
dsw.AddNode(nodeName)
|
dsw.AddNode(nodeName)
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetTestVolumeSpec returns a test volume spec
|
// GetTestVolumeSpec returns a test volume spec
|
||||||
func GetTestVolumeSpec(volumeName string, diskName api.UniqueDeviceName) *volume.Spec {
|
func GetTestVolumeSpec(volumeName string, diskName api.UniqueVolumeName) *volume.Spec {
|
||||||
return &volume.Spec{
|
return &volume.Spec{
|
||||||
Volume: &api.Volume{
|
Volume: &api.Volume{
|
||||||
Name: volumeName,
|
Name: volumeName,
|
||||||
|
|
|
@ -92,7 +92,7 @@ import (
|
||||||
"k8s.io/kubernetes/pkg/util/wait"
|
"k8s.io/kubernetes/pkg/util/wait"
|
||||||
"k8s.io/kubernetes/pkg/version"
|
"k8s.io/kubernetes/pkg/version"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
attachdetachutil "k8s.io/kubernetes/pkg/volume/util/attachdetach"
|
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
|
||||||
"k8s.io/kubernetes/pkg/watch"
|
"k8s.io/kubernetes/pkg/watch"
|
||||||
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
|
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
|
||||||
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
|
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
|
||||||
|
@ -1043,7 +1043,7 @@ func (kl *Kubelet) initialNodeStatus() (*api.Node, error) {
|
||||||
node.Annotations = make(map[string]string)
|
node.Annotations = make(map[string]string)
|
||||||
}
|
}
|
||||||
|
|
||||||
node.Annotations[attachdetachutil.ControllerManagedAnnotation] = "true"
|
node.Annotations[volumehelper.ControllerManagedAnnotation] = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
// @question: should this be place after the call to the cloud provider? which also applies labels
|
// @question: should this be place after the call to the cloud provider? which also applies labels
|
||||||
|
@ -2145,10 +2145,10 @@ func (kl *Kubelet) cleanupOrphanedVolumes(pods []*api.Pod, runningPods []*kubeco
|
||||||
if kl.enableControllerAttachDetach {
|
if kl.enableControllerAttachDetach {
|
||||||
// Attach/Detach controller is enabled and this volume type
|
// Attach/Detach controller is enabled and this volume type
|
||||||
// implments a detacher
|
// implments a detacher
|
||||||
uniqueDeviceName := attachdetachutil.GetUniqueDeviceName(
|
uniqueDeviceName := volumehelper.GetUniqueVolumeName(
|
||||||
cleaner.PluginName, pdName)
|
cleaner.PluginName, pdName)
|
||||||
kl.volumeManager.RemoveVolumeInUse(
|
kl.volumeManager.RemoveVolumeInUse(
|
||||||
api.UniqueDeviceName(uniqueDeviceName))
|
api.UniqueVolumeName(uniqueDeviceName))
|
||||||
} else {
|
} else {
|
||||||
// Attach/Detach controller is disabled
|
// Attach/Detach controller is disabled
|
||||||
err = detacher.Detach(pdName, kl.hostname)
|
err = detacher.Detach(pdName, kl.hostname)
|
||||||
|
|
|
@ -32,13 +32,13 @@ import (
|
||||||
type volumeManager struct {
|
type volumeManager struct {
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
volumeMaps map[types.UID]kubecontainer.VolumeMap
|
volumeMaps map[types.UID]kubecontainer.VolumeMap
|
||||||
volumesInUse []api.UniqueDeviceName
|
volumesInUse []api.UniqueVolumeName
|
||||||
}
|
}
|
||||||
|
|
||||||
func newVolumeManager() *volumeManager {
|
func newVolumeManager() *volumeManager {
|
||||||
vm := &volumeManager{
|
vm := &volumeManager{
|
||||||
volumeMaps: make(map[types.UID]kubecontainer.VolumeMap),
|
volumeMaps: make(map[types.UID]kubecontainer.VolumeMap),
|
||||||
volumesInUse: []api.UniqueDeviceName{},
|
volumesInUse: []api.UniqueVolumeName{},
|
||||||
}
|
}
|
||||||
return vm
|
return vm
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ func (vm *volumeManager) DeleteVolumes(podUID types.UID) {
|
||||||
|
|
||||||
// AddVolumeInUse adds specified volume to volumesInUse list, if it doesn't
|
// AddVolumeInUse adds specified volume to volumesInUse list, if it doesn't
|
||||||
// already exist
|
// already exist
|
||||||
func (vm *volumeManager) AddVolumeInUse(uniqueDeviceName api.UniqueDeviceName) {
|
func (vm *volumeManager) AddVolumeInUse(uniqueDeviceName api.UniqueVolumeName) {
|
||||||
vm.lock.Lock()
|
vm.lock.Lock()
|
||||||
defer vm.lock.Unlock()
|
defer vm.lock.Unlock()
|
||||||
for _, volume := range vm.volumesInUse {
|
for _, volume := range vm.volumesInUse {
|
||||||
|
@ -84,7 +84,7 @@ func (vm *volumeManager) AddVolumeInUse(uniqueDeviceName api.UniqueDeviceName) {
|
||||||
|
|
||||||
// RemoveVolumeInUse removes the specified volume from volumesInUse list, if it
|
// RemoveVolumeInUse removes the specified volume from volumesInUse list, if it
|
||||||
// exists
|
// exists
|
||||||
func (vm *volumeManager) RemoveVolumeInUse(uniqueDeviceName api.UniqueDeviceName) {
|
func (vm *volumeManager) RemoveVolumeInUse(uniqueDeviceName api.UniqueVolumeName) {
|
||||||
vm.lock.Lock()
|
vm.lock.Lock()
|
||||||
defer vm.lock.Unlock()
|
defer vm.lock.Unlock()
|
||||||
for i := len(vm.volumesInUse) - 1; i >= 0; i-- {
|
for i := len(vm.volumesInUse) - 1; i >= 0; i-- {
|
||||||
|
@ -96,7 +96,7 @@ func (vm *volumeManager) RemoveVolumeInUse(uniqueDeviceName api.UniqueDeviceName
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetVolumesInUse returns the volumesInUse list
|
// GetVolumesInUse returns the volumesInUse list
|
||||||
func (vm *volumeManager) GetVolumesInUse() []api.UniqueDeviceName {
|
func (vm *volumeManager) GetVolumesInUse() []api.UniqueVolumeName {
|
||||||
vm.lock.RLock()
|
vm.lock.RLock()
|
||||||
defer vm.lock.RUnlock()
|
defer vm.lock.RUnlock()
|
||||||
return vm.volumesInUse
|
return vm.volumesInUse
|
||||||
|
|
|
@ -34,7 +34,7 @@ import (
|
||||||
"k8s.io/kubernetes/pkg/util/mount"
|
"k8s.io/kubernetes/pkg/util/mount"
|
||||||
"k8s.io/kubernetes/pkg/util/strings"
|
"k8s.io/kubernetes/pkg/util/strings"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
"k8s.io/kubernetes/pkg/volume/util/attachdetach"
|
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -185,13 +185,13 @@ func (kl *Kubelet) mountExternalVolumes(pod *api.Pod) (kubecontainer.VolumeMap,
|
||||||
if kl.enableControllerAttachDetach {
|
if kl.enableControllerAttachDetach {
|
||||||
// Attach/Detach controller is enabled and this volume type
|
// Attach/Detach controller is enabled and this volume type
|
||||||
// implements an attacher
|
// implements an attacher
|
||||||
uniqueDeviceName, err := attachdetach.GetUniqueDeviceNameFromSpec(
|
uniqueDeviceName, err := volumehelper.GetUniqueVolumeNameFromSpec(
|
||||||
attachablePlugin, volSpec)
|
attachablePlugin, volSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
kl.volumeManager.AddVolumeInUse(
|
kl.volumeManager.AddVolumeInUse(
|
||||||
api.UniqueDeviceName(uniqueDeviceName))
|
api.UniqueVolumeName(uniqueDeviceName))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = attacher.MountDevice(volSpec, devicePath, deviceMountPath, kl.mounter); err != nil {
|
if err = attacher.MountDevice(volSpec, devicePath, deviceMountPath, kl.mounter); err != nil {
|
||||||
|
@ -373,9 +373,9 @@ func (kl *Kubelet) newVolumeMounterFromPlugins(spec *volume.Spec, pod *api.Pod,
|
||||||
}
|
}
|
||||||
physicalMounter, err := plugin.NewMounter(spec, pod, opts)
|
physicalMounter, err := plugin.NewMounter(spec, pod, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to instantiate mounter for volume: %s using plugin: %s with a root cause: %v", spec.Name(), plugin.Name(), err)
|
return nil, fmt.Errorf("failed to instantiate mounter for volume: %s using plugin: %s with a root cause: %v", spec.Name(), plugin.GetPluginName(), err)
|
||||||
}
|
}
|
||||||
glog.V(10).Infof("Using volume plugin %q to mount %s", plugin.Name(), spec.Name())
|
glog.V(10).Infof("Using volume plugin %q to mount %s", plugin.GetPluginName(), spec.Name())
|
||||||
return physicalMounter, nil
|
return physicalMounter, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ func (kl *Kubelet) newVolumeAttacherFromPlugins(spec *volume.Spec, pod *api.Pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to instantiate volume attacher for %s: %v", spec.Name(), err)
|
return nil, nil, fmt.Errorf("failed to instantiate volume attacher for %s: %v", spec.Name(), err)
|
||||||
}
|
}
|
||||||
glog.V(3).Infof("Using volume plugin %q to attach %s/%s", plugin.Name(), spec.Name())
|
glog.V(3).Infof("Using volume plugin %q to attach %s/%s", plugin.GetPluginName(), spec.Name())
|
||||||
return attacher, plugin, nil
|
return attacher, plugin, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,8 +419,8 @@ func (kl *Kubelet) newVolumeUnmounterFromPlugins(kind string, name string, podUI
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", fmt.Errorf("failed to instantiate volume plugin for %s/%s: %v", podUID, kind, err)
|
return nil, "", fmt.Errorf("failed to instantiate volume plugin for %s/%s: %v", podUID, kind, err)
|
||||||
}
|
}
|
||||||
glog.V(5).Infof("Using volume plugin %q to unmount %s/%s", plugin.Name(), podUID, kind)
|
glog.V(5).Infof("Using volume plugin %q to unmount %s/%s", plugin.GetPluginName(), podUID, kind)
|
||||||
return unmounter, plugin.Name(), nil
|
return unmounter, plugin.GetPluginName(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// newVolumeDetacherFromPlugins attempts to find a plugin by a name and then
|
// newVolumeDetacherFromPlugins attempts to find a plugin by a name and then
|
||||||
|
|
|
@ -16,6 +16,10 @@ limitations under the License.
|
||||||
|
|
||||||
package types
|
package types
|
||||||
|
|
||||||
|
// UniquePodName is an identifier that can be used to uniquely identify a pod
|
||||||
|
// within the cluster.
|
||||||
|
type UniquePodName string
|
||||||
|
|
||||||
// NamespacedName comprises a resource name, with a mandatory namespace,
|
// NamespacedName comprises a resource name, with a mandatory namespace,
|
||||||
// rendered as "<namespace>/<name>". Being a type captures intent and
|
// rendered as "<namespace>/<name>". Being a type captures intent and
|
||||||
// helps make sure that UIDs, namespaced names and non-namespaced names
|
// helps make sure that UIDs, namespaced names and non-namespaced names
|
||||||
|
@ -33,3 +37,8 @@ type NamespacedName struct {
|
||||||
func (n NamespacedName) String() string {
|
func (n NamespacedName) String() string {
|
||||||
return n.Namespace + "/" + n.Name
|
return n.Namespace + "/" + n.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UniquePodName returns the UniquePodName object representation
|
||||||
|
func (n NamespacedName) UniquePodName() UniquePodName {
|
||||||
|
return UniquePodName(n.String())
|
||||||
|
}
|
||||||
|
|
|
@ -61,10 +61,19 @@ func (plugin *awsElasticBlockStorePlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *awsElasticBlockStorePlugin) Name() string {
|
func (plugin *awsElasticBlockStorePlugin) GetPluginName() string {
|
||||||
return awsElasticBlockStorePluginName
|
return awsElasticBlockStorePluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *awsElasticBlockStorePlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference an AWS EBS volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource.VolumeID, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *awsElasticBlockStorePlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *awsElasticBlockStorePlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.AWSElasticBlockStore != nil) ||
|
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.AWSElasticBlockStore != nil) ||
|
||||||
(spec.Volume != nil && spec.Volume.AWSElasticBlockStore != nil)
|
(spec.Volume != nil && spec.Volume.AWSElasticBlockStore != nil)
|
||||||
|
@ -167,6 +176,21 @@ func (plugin *awsElasticBlockStorePlugin) newProvisionerInternal(options volume.
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.AWSElasticBlockStoreVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.AWSElasticBlockStoreVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.AWSElasticBlockStore != nil {
|
||||||
|
volumeSource = spec.Volume.AWSElasticBlockStore
|
||||||
|
readOnly = volumeSource.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.AWSElasticBlockStore
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
||||||
// Abstract interface to PD operations.
|
// Abstract interface to PD operations.
|
||||||
type ebsManager interface {
|
type ebsManager interface {
|
||||||
CreateVolume(provisioner *awsElasticBlockStoreProvisioner) (volumeID string, volumeSizeGB int, labels map[string]string, err error)
|
CreateVolume(provisioner *awsElasticBlockStoreProvisioner) (volumeID string, volumeSizeGB int, labels map[string]string, err error)
|
||||||
|
|
|
@ -54,10 +54,19 @@ func (plugin *azureFilePlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *azureFilePlugin) Name() string {
|
func (plugin *azureFilePlugin) GetPluginName() string {
|
||||||
return azureFilePluginName
|
return azureFilePluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *azureFilePlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference an AzureFile volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource.ShareName, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *azureFilePlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *azureFilePlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
//TODO: check if mount.cifs is there
|
//TODO: check if mount.cifs is there
|
||||||
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.AzureFile != nil) ||
|
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.AzureFile != nil) ||
|
||||||
|
@ -237,3 +246,18 @@ func (c *azureFileUnmounter) TearDownAt(dir string) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.AzureFileVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.AzureFileVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.AzureFile != nil {
|
||||||
|
volumeSource = spec.Volume.AzureFile
|
||||||
|
readOnly = volumeSource.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.AzureFile
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -49,10 +49,19 @@ func (plugin *cephfsPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *cephfsPlugin) Name() string {
|
func (plugin *cephfsPlugin) GetPluginName() string {
|
||||||
return cephfsPluginName
|
return cephfsPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *cephfsPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a CephFS volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%v", volumeSource.Monitors), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *cephfsPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *cephfsPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return (spec.Volume != nil && spec.Volume.CephFS != nil) || (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.CephFS != nil)
|
return (spec.Volume != nil && spec.Volume.CephFS != nil) || (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.CephFS != nil)
|
||||||
}
|
}
|
||||||
|
@ -279,3 +288,18 @@ func (cephfsVolume *cephfs) execMount(mountpoint string) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.CephFSVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.CephFSVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.CephFS != nil {
|
||||||
|
volumeSource = spec.Volume.CephFS
|
||||||
|
readOnly = volumeSource.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.CephFS
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -74,10 +74,19 @@ func (plugin *cinderPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *cinderPlugin) Name() string {
|
func (plugin *cinderPlugin) GetPluginName() string {
|
||||||
return cinderVolumePluginName
|
return cinderVolumePluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *cinderPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a Cinder volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource.VolumeID, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *cinderPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *cinderPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return (spec.Volume != nil && spec.Volume.Cinder != nil) || (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.Cinder != nil)
|
return (spec.Volume != nil && spec.Volume.Cinder != nil) || (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.Cinder != nil)
|
||||||
}
|
}
|
||||||
|
@ -458,3 +467,18 @@ func (c *cinderVolumeProvisioner) Provision() (*api.PersistentVolume, error) {
|
||||||
}
|
}
|
||||||
return pv, nil
|
return pv, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.CinderVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.CinderVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.Cinder != nil {
|
||||||
|
volumeSource = spec.Volume.Cinder
|
||||||
|
readOnly = volumeSource.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.Cinder
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -50,10 +50,19 @@ func (plugin *configMapPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *configMapPlugin) Name() string {
|
func (plugin *configMapPlugin) GetPluginName() string {
|
||||||
return configMapPluginName
|
return configMapPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *configMapPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a ConfigMap volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource.Name, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *configMapPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *configMapPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return spec.Volume != nil && spec.Volume.ConfigMap != nil
|
return spec.Volume != nil && spec.Volume.ConfigMap != nil
|
||||||
}
|
}
|
||||||
|
@ -226,3 +235,15 @@ func (c *configMapVolumeUnmounter) TearDownAt(dir string) error {
|
||||||
}
|
}
|
||||||
return wrapped.TearDownAt(dir)
|
return wrapped.TearDownAt(dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.ConfigMapVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.ConfigMapVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.ConfigMap != nil {
|
||||||
|
volumeSource = spec.Volume.ConfigMap
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -58,10 +58,20 @@ func (plugin *downwardAPIPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *downwardAPIPlugin) Name() string {
|
func (plugin *downwardAPIPlugin) GetPluginName() string {
|
||||||
return downwardAPIPluginName
|
return downwardAPIPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *downwardAPIPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a DownwardAPI volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return user defined volume name, since this is an ephemeral volume type
|
||||||
|
return spec.Name(), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *downwardAPIPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *downwardAPIPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return spec.Volume != nil && spec.Volume.DownwardAPI != nil
|
return spec.Volume != nil && spec.Volume.DownwardAPI != nil
|
||||||
}
|
}
|
||||||
|
@ -229,3 +239,15 @@ func (c *downwardAPIVolumeUnmounter) TearDownAt(dir string) error {
|
||||||
func (b *downwardAPIVolumeMounter) getMetaDir() string {
|
func (b *downwardAPIVolumeMounter) getMetaDir() string {
|
||||||
return path.Join(b.plugin.host.GetPodPluginDir(b.podUID, utilstrings.EscapeQualifiedNameForDisk(downwardAPIPluginName)), b.volName)
|
return path.Join(b.plugin.host.GetPodPluginDir(b.podUID, utilstrings.EscapeQualifiedNameForDisk(downwardAPIPluginName)), b.volName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.DownwardAPIVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.DownwardAPIVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.DownwardAPI != nil {
|
||||||
|
volumeSource = spec.Volume.DownwardAPI
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -64,10 +64,20 @@ func (plugin *emptyDirPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *emptyDirPlugin) Name() string {
|
func (plugin *emptyDirPlugin) GetPluginName() string {
|
||||||
return emptyDirPluginName
|
return emptyDirPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *emptyDirPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference an EmptyDir volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return user defined volume name, since this is an ephemeral volume type
|
||||||
|
return spec.Name(), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *emptyDirPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *emptyDirPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
if spec.Volume != nil && spec.Volume.EmptyDir != nil {
|
if spec.Volume != nil && spec.Volume.EmptyDir != nil {
|
||||||
return true
|
return true
|
||||||
|
@ -326,3 +336,15 @@ func (ed *emptyDir) teardownTmpfs(dir string) error {
|
||||||
func (ed *emptyDir) getMetaDir() string {
|
func (ed *emptyDir) getMetaDir() string {
|
||||||
return path.Join(ed.plugin.host.GetPodPluginDir(ed.pod.UID, strings.EscapeQualifiedNameForDisk(emptyDirPluginName)), ed.volName)
|
return path.Join(ed.plugin.host.GetPodPluginDir(ed.pod.UID, strings.EscapeQualifiedNameForDisk(emptyDirPluginName)), ed.volName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.EmptyDirVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.EmptyDirVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.EmptyDir != nil {
|
||||||
|
volumeSource = spec.Volume.EmptyDir
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -51,10 +51,19 @@ func (plugin *fcPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *fcPlugin) Name() string {
|
func (plugin *fcPlugin) GetPluginName() string {
|
||||||
return fcPluginName
|
return fcPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *fcPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a FibreChannel volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%v", volumeSource.TargetWWNs), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *fcPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *fcPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
if (spec.Volume != nil && spec.Volume.FC == nil) || (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.FC == nil) {
|
if (spec.Volume != nil && spec.Volume.FC == nil) || (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.FC == nil) {
|
||||||
return false
|
return false
|
||||||
|
@ -197,3 +206,18 @@ func (c *fcDiskUnmounter) TearDown() error {
|
||||||
func (c *fcDiskUnmounter) TearDownAt(dir string) error {
|
func (c *fcDiskUnmounter) TearDownAt(dir string) error {
|
||||||
return diskTearDown(c.manager, *c, dir, c.mounter)
|
return diskTearDown(c.manager, *c, dir, c.mounter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.FCVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.FCVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.FC != nil {
|
||||||
|
volumeSource = spec.Volume.FC
|
||||||
|
readOnly = volumeSource.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.FC
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -73,10 +73,19 @@ func (plugin *flexVolumePlugin) getExecutable() string {
|
||||||
return path.Join(plugin.execPath, execName)
|
return path.Join(plugin.execPath, execName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *flexVolumePlugin) Name() string {
|
func (plugin *flexVolumePlugin) GetPluginName() string {
|
||||||
return plugin.driverName
|
return plugin.driverName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *flexVolumePlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a Flex volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource.Driver, nil
|
||||||
|
}
|
||||||
|
|
||||||
// CanSupport checks whether the plugin can support the input volume spec.
|
// CanSupport checks whether the plugin can support the input volume spec.
|
||||||
func (plugin *flexVolumePlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *flexVolumePlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
source := plugin.getVolumeSource(spec)
|
source := plugin.getVolumeSource(spec)
|
||||||
|
@ -386,3 +395,18 @@ func (f *flexVolumeUnmounter) TearDownAt(dir string) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.FlexVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.FlexVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.FlexVolume != nil {
|
||||||
|
volumeSource = spec.Volume.FlexVolume
|
||||||
|
readOnly = volumeSource.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.FlexVolume
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -66,11 +66,20 @@ func (p *flockerPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p flockerPlugin) Name() string {
|
func (p *flockerPlugin) GetPluginName() string {
|
||||||
return flockerPluginName
|
return flockerPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p flockerPlugin) CanSupport(spec *volume.Spec) bool {
|
func (p *flockerPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a Flocker volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource.DatasetName, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *flockerPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.Flocker != nil) ||
|
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.Flocker != nil) ||
|
||||||
(spec.Volume != nil && spec.Volume.Flocker != nil)
|
(spec.Volume != nil && spec.Volume.Flocker != nil)
|
||||||
}
|
}
|
||||||
|
@ -241,3 +250,18 @@ func (b flockerMounter) updateDatasetPrimary(datasetID, primaryUUID string) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.FlockerVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.FlockerVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.Flocker != nil {
|
||||||
|
volumeSource = spec.Volume.Flocker
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.Flocker
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -53,15 +53,6 @@ func (plugin *gcePersistentDiskPlugin) NewAttacher() (volume.Attacher, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *gcePersistentDiskPlugin) GetDeviceName(spec *volume.Spec) (string, error) {
|
|
||||||
volumeSource, _ := getVolumeSource(spec)
|
|
||||||
if volumeSource == nil {
|
|
||||||
return "", fmt.Errorf("Spec does not reference a GCE volume type")
|
|
||||||
}
|
|
||||||
|
|
||||||
return volumeSource.PDName, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach checks with the GCE cloud provider if the specified volume is already
|
// Attach checks with the GCE cloud provider if the specified volume is already
|
||||||
// attached to the specified node. If the volume is attached, it succeeds
|
// attached to the specified node. If the volume is attached, it succeeds
|
||||||
// (returns nil). If it is not, Attach issues a call to the GCE cloud provider
|
// (returns nil). If it is not, Attach issues a call to the GCE cloud provider
|
||||||
|
|
|
@ -58,10 +58,19 @@ func (plugin *gcePersistentDiskPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *gcePersistentDiskPlugin) Name() string {
|
func (plugin *gcePersistentDiskPlugin) GetPluginName() string {
|
||||||
return gcePersistentDiskPluginName
|
return gcePersistentDiskPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *gcePersistentDiskPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a GCE volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource.PDName, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *gcePersistentDiskPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *gcePersistentDiskPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.GCEPersistentDisk != nil) ||
|
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.GCEPersistentDisk != nil) ||
|
||||||
(spec.Volume != nil && spec.Volume.GCEPersistentDisk != nil)
|
(spec.Volume != nil && spec.Volume.GCEPersistentDisk != nil)
|
||||||
|
|
|
@ -54,10 +54,23 @@ func (plugin *gitRepoPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *gitRepoPlugin) Name() string {
|
func (plugin *gitRepoPlugin) GetPluginName() string {
|
||||||
return gitRepoPluginName
|
return gitRepoPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *gitRepoPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a GCE volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"%v:%v:%v",
|
||||||
|
volumeSource.Repository,
|
||||||
|
volumeSource.Revision,
|
||||||
|
volumeSource.Directory), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *gitRepoPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *gitRepoPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return spec.Volume != nil && spec.Volume.GitRepo != nil
|
return spec.Volume != nil && spec.Volume.GitRepo != nil
|
||||||
}
|
}
|
||||||
|
@ -226,3 +239,15 @@ func (c *gitRepoVolumeUnmounter) TearDownAt(dir string) error {
|
||||||
}
|
}
|
||||||
return wrapped.TearDownAt(dir)
|
return wrapped.TearDownAt(dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.GitRepoVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.GitRepoVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.GitRepo != nil {
|
||||||
|
volumeSource = spec.Volume.GitRepo
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -52,10 +52,22 @@ func (plugin *glusterfsPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *glusterfsPlugin) Name() string {
|
func (plugin *glusterfsPlugin) GetPluginName() string {
|
||||||
return glusterfsPluginName
|
return glusterfsPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *glusterfsPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a Gluster volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"%v:%v",
|
||||||
|
volumeSource.EndpointsName,
|
||||||
|
volumeSource.Path), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *glusterfsPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *glusterfsPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
if (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.Glusterfs == nil) ||
|
if (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.Glusterfs == nil) ||
|
||||||
(spec.Volume != nil && spec.Volume.Glusterfs == nil) {
|
(spec.Volume != nil && spec.Volume.Glusterfs == nil) {
|
||||||
|
@ -275,3 +287,18 @@ func (b *glusterfsMounter) setUpAtInternal(dir string) error {
|
||||||
}
|
}
|
||||||
return fmt.Errorf("glusterfs: mount failed: %v", errs)
|
return fmt.Errorf("glusterfs: mount failed: %v", errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.GlusterfsVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.GlusterfsVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.Glusterfs != nil {
|
||||||
|
volumeSource = spec.Volume.Glusterfs
|
||||||
|
readOnly = volumeSource.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.Glusterfs
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -78,10 +78,19 @@ func (plugin *hostPathPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *hostPathPlugin) Name() string {
|
func (plugin *hostPathPlugin) GetPluginName() string {
|
||||||
return hostPathPluginName
|
return hostPathPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *hostPathPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference an HostPath volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource.Path, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *hostPathPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *hostPathPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.HostPath != nil) ||
|
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.HostPath != nil) ||
|
||||||
(spec.Volume != nil && spec.Volume.HostPath != nil)
|
(spec.Volume != nil && spec.Volume.HostPath != nil)
|
||||||
|
@ -303,3 +312,18 @@ func (r *hostPathDeleter) Delete() error {
|
||||||
}
|
}
|
||||||
return os.RemoveAll(r.GetPath())
|
return os.RemoveAll(r.GetPath())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.HostPathVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.HostPathVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.HostPath != nil {
|
||||||
|
volumeSource = spec.Volume.HostPath
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.HostPath
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package iscsi
|
package iscsi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -52,10 +53,23 @@ func (plugin *iscsiPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *iscsiPlugin) Name() string {
|
func (plugin *iscsiPlugin) GetPluginName() string {
|
||||||
return iscsiPluginName
|
return iscsiPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *iscsiPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a ISCSI volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"%v:%v:%v",
|
||||||
|
volumeSource.TargetPortal,
|
||||||
|
volumeSource.IQN,
|
||||||
|
volumeSource.Lun), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *iscsiPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *iscsiPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
if (spec.Volume != nil && spec.Volume.ISCSI == nil) || (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.ISCSI == nil) {
|
if (spec.Volume != nil && spec.Volume.ISCSI == nil) || (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.ISCSI == nil) {
|
||||||
return false
|
return false
|
||||||
|
@ -206,3 +220,18 @@ func portalMounter(portal string) string {
|
||||||
}
|
}
|
||||||
return portal
|
return portal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.ISCSIVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.ISCSIVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.ISCSI != nil {
|
||||||
|
volumeSource = spec.Volume.ISCSI
|
||||||
|
readOnly = volumeSource.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.ISCSI
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -63,10 +63,22 @@ func (plugin *nfsPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *nfsPlugin) Name() string {
|
func (plugin *nfsPlugin) GetPluginName() string {
|
||||||
return nfsPluginName
|
return nfsPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *nfsPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a NFS volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"%v/%v",
|
||||||
|
volumeSource.Server,
|
||||||
|
volumeSource.Path), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *nfsPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *nfsPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.NFS != nil) ||
|
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.NFS != nil) ||
|
||||||
(spec.Volume != nil && spec.Volume.NFS != nil)
|
(spec.Volume != nil && spec.Volume.NFS != nil)
|
||||||
|
@ -296,3 +308,18 @@ func (r *nfsRecycler) Recycle() error {
|
||||||
}
|
}
|
||||||
return volume.RecycleVolumeByWatchingPodUntilCompletion(r.pvName, pod, r.host.GetKubeClient())
|
return volume.RecycleVolumeByWatchingPodUntilCompletion(r.pvName, pod, r.host.GetKubeClient())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.NFSVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.NFSVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.NFS != nil {
|
||||||
|
volumeSource = spec.Volume.NFS
|
||||||
|
readOnly = volumeSource.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.NFS
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -71,7 +71,15 @@ type VolumePlugin interface {
|
||||||
// Name returns the plugin's name. Plugins should use namespaced names
|
// Name returns the plugin's name. Plugins should use namespaced names
|
||||||
// such as "example.com/volume". The "kubernetes.io" namespace is
|
// such as "example.com/volume". The "kubernetes.io" namespace is
|
||||||
// reserved for plugins which are bundled with kubernetes.
|
// reserved for plugins which are bundled with kubernetes.
|
||||||
Name() string
|
GetPluginName() string
|
||||||
|
|
||||||
|
// GetVolumeName returns the name/ID to uniquely identifying the actual
|
||||||
|
// backing device, directory, path, etc. referenced by the specified volume
|
||||||
|
// spec.
|
||||||
|
// For Attachable volumes, this value must be able to be passed back to
|
||||||
|
// volume Detach methods to identify the device to act on.
|
||||||
|
// If the plugin does not support the given spec, this returns an error.
|
||||||
|
GetVolumeName(spec *Spec) (string, error)
|
||||||
|
|
||||||
// CanSupport tests whether the plugin supports a given volume
|
// CanSupport tests whether the plugin supports a given volume
|
||||||
// specification from the API. The spec pointer should be considered
|
// specification from the API. The spec pointer should be considered
|
||||||
|
@ -141,11 +149,6 @@ type AttachableVolumePlugin interface {
|
||||||
VolumePlugin
|
VolumePlugin
|
||||||
NewAttacher() (Attacher, error)
|
NewAttacher() (Attacher, error)
|
||||||
NewDetacher() (Detacher, error)
|
NewDetacher() (Detacher, error)
|
||||||
|
|
||||||
// GetDeviceName returns the name or ID of the device referenced in the
|
|
||||||
// specified volume spec. This is passed by callers to the Deatch method.
|
|
||||||
// If the plugin does not support the given spec, this returns an error.
|
|
||||||
GetDeviceName(spec *Spec) (string, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// VolumeHost is an interface that plugins can use to access the kubelet.
|
// VolumeHost is an interface that plugins can use to access the kubelet.
|
||||||
|
@ -299,7 +302,7 @@ func (pm *VolumePluginMgr) InitPlugins(plugins []VolumePlugin, host VolumeHost)
|
||||||
|
|
||||||
allErrs := []error{}
|
allErrs := []error{}
|
||||||
for _, plugin := range plugins {
|
for _, plugin := range plugins {
|
||||||
name := plugin.Name()
|
name := plugin.GetPluginName()
|
||||||
if errs := validation.IsQualifiedName(name); len(errs) != 0 {
|
if errs := validation.IsQualifiedName(name); len(errs) != 0 {
|
||||||
allErrs = append(allErrs, fmt.Errorf("volume plugin has invalid name: %q: %s", name, strings.Join(errs, ";")))
|
allErrs = append(allErrs, fmt.Errorf("volume plugin has invalid name: %q: %s", name, strings.Join(errs, ";")))
|
||||||
continue
|
continue
|
||||||
|
@ -352,7 +355,7 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
|
||||||
// Once we can get rid of legacy names we can reduce this to a map lookup.
|
// Once we can get rid of legacy names we can reduce this to a map lookup.
|
||||||
matches := []string{}
|
matches := []string{}
|
||||||
for k, v := range pm.plugins {
|
for k, v := range pm.plugins {
|
||||||
if v.Name() == name {
|
if v.GetPluginName() == name {
|
||||||
matches = append(matches, k)
|
matches = append(matches, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,22 @@ func (plugin *rbdPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *rbdPlugin) Name() string {
|
func (plugin *rbdPlugin) GetPluginName() string {
|
||||||
return rbdPluginName
|
return rbdPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *rbdPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a RBD volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"%v:%v",
|
||||||
|
volumeSource.CephMonitors,
|
||||||
|
volumeSource.RBDImage), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *rbdPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *rbdPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
if (spec.Volume != nil && spec.Volume.RBD == nil) || (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.RBD == nil) {
|
if (spec.Volume != nil && spec.Volume.RBD == nil) || (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.RBD == nil) {
|
||||||
return false
|
return false
|
||||||
|
@ -221,3 +233,18 @@ func (plugin *rbdPlugin) execCommand(command string, args []string) ([]byte, err
|
||||||
cmd := plugin.exe.Command(command, args...)
|
cmd := plugin.exe.Command(command, args...)
|
||||||
return cmd.CombinedOutput()
|
return cmd.CombinedOutput()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.RBDVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.RBDVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.RBD != nil {
|
||||||
|
volumeSource = spec.Volume.RBD
|
||||||
|
readOnly = volumeSource.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.RBD
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -58,10 +58,19 @@ func (plugin *secretPlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *secretPlugin) Name() string {
|
func (plugin *secretPlugin) GetPluginName() string {
|
||||||
return secretPluginName
|
return secretPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *secretPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a Secret volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource.SecretName, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *secretPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *secretPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return spec.Volume != nil && spec.Volume.Secret != nil
|
return spec.Volume != nil && spec.Volume.Secret != nil
|
||||||
}
|
}
|
||||||
|
@ -242,3 +251,15 @@ func (c *secretVolumeUnmounter) TearDownAt(dir string) error {
|
||||||
}
|
}
|
||||||
return wrapped.TearDownAt(dir)
|
return wrapped.TearDownAt(dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.SecretVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.SecretVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.Secret != nil {
|
||||||
|
volumeSource = spec.Volume.Secret
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
|
@ -166,12 +166,16 @@ func (plugin *FakeVolumePlugin) Init(host VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *FakeVolumePlugin) Name() string {
|
func (plugin *FakeVolumePlugin) GetPluginName() string {
|
||||||
plugin.RLock()
|
plugin.RLock()
|
||||||
defer plugin.RUnlock()
|
defer plugin.RUnlock()
|
||||||
return plugin.PluginName
|
return plugin.PluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *FakeVolumePlugin) GetVolumeName(spec *Spec) (string, error) {
|
||||||
|
return spec.Name(), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *FakeVolumePlugin) CanSupport(spec *Spec) bool {
|
func (plugin *FakeVolumePlugin) CanSupport(spec *Spec) bool {
|
||||||
// TODO: maybe pattern-match on spec.Name() to decide?
|
// TODO: maybe pattern-match on spec.Name() to decide?
|
||||||
return true
|
return true
|
||||||
|
@ -237,10 +241,6 @@ func (plugin *FakeVolumePlugin) GetNewDetacherCallCount() int {
|
||||||
return plugin.NewDetacherCallCount
|
return plugin.NewDetacherCallCount
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *FakeVolumePlugin) GetDeviceName(spec *Spec) (string, error) {
|
|
||||||
return spec.Name(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (plugin *FakeVolumePlugin) NewRecycler(pvName string, spec *Spec) (Recycler, error) {
|
func (plugin *FakeVolumePlugin) NewRecycler(pvName string, spec *Spec) (Recycler, error) {
|
||||||
return &fakeRecycler{"/attributesTransferredFromSpec", MetricsNil{}}, nil
|
return &fakeRecycler{"/attributesTransferredFromSpec", MetricsNil{}}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||||
|
|
||||||
|
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 volumehelper contains consts and helper methods used by various
|
||||||
|
// volume components (attach/detach controller, kubelet, etc.).
|
||||||
|
package volumehelper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ControllerManagedAnnotation is the key of the annotation on Node objects
|
||||||
|
// that indicates attach/detach operations for the node should be managed
|
||||||
|
// by the attach/detach controller
|
||||||
|
ControllerManagedAnnotation string = "volumes.kubernetes.io/controller-managed-attach-detach"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetUniqueVolumeName returns a unique name representing the volume/plugin.
|
||||||
|
// Caller should ensure that volumeName is a name/ID uniquely identifying the
|
||||||
|
// actual backing device, directory, path, etc. for a particular volume.
|
||||||
|
// The returned name can be used to uniquely reference the volume, for example,
|
||||||
|
// to prevent operations (attach/detach or mount/unmount) from being triggered
|
||||||
|
// on the same volume.
|
||||||
|
func GetUniqueVolumeName(
|
||||||
|
pluginName string, volumeName string) api.UniqueVolumeName {
|
||||||
|
return api.UniqueVolumeName(fmt.Sprintf("%s/%s", pluginName, volumeName))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUniqueVolumeNameFromSpec uses the given VolumePlugin to generate a unique
|
||||||
|
// name representing the volume defined in the specified volume spec.
|
||||||
|
// This returned name can be used to uniquely reference the actual backing
|
||||||
|
// device, directory, path, etc. referenced by the given volumeSpec.
|
||||||
|
// If the given plugin does not support the volume spec, this returns an error.
|
||||||
|
func GetUniqueVolumeNameFromSpec(
|
||||||
|
volumePlugin volume.VolumePlugin,
|
||||||
|
volumeSpec *volume.Spec) (api.UniqueVolumeName, error) {
|
||||||
|
if volumePlugin == nil {
|
||||||
|
return "", fmt.Errorf(
|
||||||
|
"volumePlugin should not be nil. volumeSpec.Name=%q",
|
||||||
|
volumeSpec.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
volumeName, err := volumePlugin.GetVolumeName(volumeSpec)
|
||||||
|
if err != nil || volumeName == "" {
|
||||||
|
return "", fmt.Errorf(
|
||||||
|
"failed to GetVolumeName from volumePlugin for volumeSpec %q err=%v",
|
||||||
|
volumeSpec.Name(),
|
||||||
|
err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetUniqueVolumeName(
|
||||||
|
volumePlugin.GetPluginName(),
|
||||||
|
volumeName),
|
||||||
|
nil
|
||||||
|
}
|
|
@ -57,10 +57,19 @@ func (plugin *vsphereVolumePlugin) Init(host volume.VolumeHost) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *vsphereVolumePlugin) Name() string {
|
func (plugin *vsphereVolumePlugin) GetPluginName() string {
|
||||||
return vsphereVolumePluginName
|
return vsphereVolumePluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *vsphereVolumePlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||||
|
volumeSource, _ := getVolumeSource(spec)
|
||||||
|
if volumeSource == nil {
|
||||||
|
return "", fmt.Errorf("Spec does not reference a VSphere volume type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource.VolumePath, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *vsphereVolumePlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *vsphereVolumePlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.VsphereVolume != nil) ||
|
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.VsphereVolume != nil) ||
|
||||||
(spec.Volume != nil && spec.Volume.VsphereVolume != nil)
|
(spec.Volume != nil && spec.Volume.VsphereVolume != nil)
|
||||||
|
@ -417,3 +426,18 @@ func (v *vsphereVolumeProvisioner) Provision() (*api.PersistentVolume, error) {
|
||||||
}
|
}
|
||||||
return pv, nil
|
return pv, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeSource(spec *volume.Spec) (*api.VsphereVirtualDiskVolumeSource, bool) {
|
||||||
|
var readOnly bool
|
||||||
|
var volumeSource *api.VsphereVirtualDiskVolumeSource
|
||||||
|
|
||||||
|
if spec.Volume != nil && spec.Volume.VsphereVolume != nil {
|
||||||
|
volumeSource = spec.Volume.VsphereVolume
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
} else {
|
||||||
|
volumeSource = spec.PersistentVolume.Spec.VsphereVolume
|
||||||
|
readOnly = spec.ReadOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeSource, readOnly
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue