Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
20b9fc69
Commit
20b9fc69
authored
Nov 03, 2016
by
Miao Luo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Photon Controller support: Address github code review comments.
parent
496d2292
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
27 deletions
+22
-27
definitions.html
docs/api-reference/apps/v1beta1/definitions.html
+3
-2
definitions.html
docs/api-reference/v1/definitions.html
+1
-1
photon.go
pkg/cloudprovider/providers/photon/photon.go
+0
-0
BUILD
pkg/volume/photon_pd/BUILD
+0
-1
attacher.go
pkg/volume/photon_pd/attacher.go
+0
-10
photon_util.go
pkg/volume/photon_pd/photon_util.go
+18
-13
No files found.
docs/api-reference/apps/v1beta1/definitions.html
View file @
20b9fc69
...
@@ -4444,8 +4444,8 @@ The StatefulSet guarantees that a given network identity will always map to the
...
@@ -4444,8 +4444,8 @@ The StatefulSet guarantees that a given network identity will always map to the
</div>
</div>
<div
id=
"footer"
>
<div
id=
"footer"
>
<div
id=
"footer-text"
>
<div
id=
"footer-text"
>
Last updated 2016-11-06 03:
38:42
UTC
Last updated 2016-11-06 03:
50:37
UTC
</div>
</div>
</div>
</div>
</body>
</body>
</html>
</html>
\ No newline at end of file
docs/api-reference/v1/definitions.html
View file @
20b9fc69
...
@@ -8613,7 +8613,7 @@ The resulting set of endpoints can be viewed as:<br>
...
@@ -8613,7 +8613,7 @@ The resulting set of endpoints can be viewed as:<br>
</div>
</div>
<div
id=
"footer"
>
<div
id=
"footer"
>
<div
id=
"footer-text"
>
<div
id=
"footer-text"
>
Last updated 2016-11-06 03:
38:36
UTC
Last updated 2016-11-06 03:
50:31
UTC
</div>
</div>
</div>
</div>
</body>
</body>
...
...
pkg/cloudprovider/providers/photon/photon.go
View file @
20b9fc69
This diff is collapsed.
Click to expand it.
pkg/volume/photon_pd/BUILD
View file @
20b9fc69
...
@@ -25,7 +25,6 @@ go_library(
...
@@ -25,7 +25,6 @@ go_library(
"//pkg/cloudprovider/providers/photon:go_default_library",
"//pkg/cloudprovider/providers/photon:go_default_library",
"//pkg/types:go_default_library",
"//pkg/types:go_default_library",
"//pkg/util/exec:go_default_library",
"//pkg/util/exec:go_default_library",
"//pkg/util/keymutex:go_default_library",
"//pkg/util/mount:go_default_library",
"//pkg/util/mount:go_default_library",
"//pkg/util/strings:go_default_library",
"//pkg/util/strings:go_default_library",
"//pkg/volume:go_default_library",
"//pkg/volume:go_default_library",
...
...
pkg/volume/photon_pd/attacher.go
View file @
20b9fc69
...
@@ -28,7 +28,6 @@ import (
...
@@ -28,7 +28,6 @@ import (
"k8s.io/kubernetes/pkg/cloudprovider/providers/photon"
"k8s.io/kubernetes/pkg/cloudprovider/providers/photon"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/keymutex"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
...
@@ -42,9 +41,6 @@ type photonPersistentDiskAttacher struct {
...
@@ -42,9 +41,6 @@ type photonPersistentDiskAttacher struct {
var
_
volume
.
Attacher
=
&
photonPersistentDiskAttacher
{}
var
_
volume
.
Attacher
=
&
photonPersistentDiskAttacher
{}
var
_
volume
.
AttachableVolumePlugin
=
&
photonPersistentDiskPlugin
{}
var
_
volume
.
AttachableVolumePlugin
=
&
photonPersistentDiskPlugin
{}
// Singleton key mutex for keeping attach operations for the same host atomic
var
attachdetachMutex
=
keymutex
.
NewKeyMutex
()
func
(
plugin
*
photonPersistentDiskPlugin
)
NewAttacher
()
(
volume
.
Attacher
,
error
)
{
func
(
plugin
*
photonPersistentDiskPlugin
)
NewAttacher
()
(
volume
.
Attacher
,
error
)
{
photonCloud
,
err
:=
getCloudProvider
(
plugin
.
host
.
GetCloudProvider
())
photonCloud
,
err
:=
getCloudProvider
(
plugin
.
host
.
GetCloudProvider
())
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -74,10 +70,6 @@ func (attacher *photonPersistentDiskAttacher) Attach(spec *volume.Spec, nodeName
...
@@ -74,10 +70,6 @@ func (attacher *photonPersistentDiskAttacher) Attach(spec *volume.Spec, nodeName
glog
.
V
(
4
)
.
Infof
(
"Photon Controller: Attach disk called for host %s"
,
hostName
)
glog
.
V
(
4
)
.
Infof
(
"Photon Controller: Attach disk called for host %s"
,
hostName
)
// Keeps concurrent attach operations to same host atomic
attachdetachMutex
.
LockKey
(
hostName
)
defer
attachdetachMutex
.
UnlockKey
(
hostName
)
// TODO: if disk is already attached?
// TODO: if disk is already attached?
err
=
attacher
.
photonDisks
.
AttachDisk
(
volumeSource
.
PdID
,
nodeName
)
err
=
attacher
.
photonDisks
.
AttachDisk
(
volumeSource
.
PdID
,
nodeName
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -260,8 +252,6 @@ func (detacher *photonPersistentDiskDetacher) Detach(deviceMountPath string, nod
...
@@ -260,8 +252,6 @@ func (detacher *photonPersistentDiskDetacher) Detach(deviceMountPath string, nod
return
nil
return
nil
}
}
attachdetachMutex
.
LockKey
(
hostName
)
defer
attachdetachMutex
.
UnlockKey
(
hostName
)
if
err
:=
detacher
.
photonDisks
.
DetachDisk
(
pdID
,
nodeName
);
err
!=
nil
{
if
err
:=
detacher
.
photonDisks
.
DetachDisk
(
pdID
,
nodeName
);
err
!=
nil
{
glog
.
Errorf
(
"Error detaching volume %q: %v"
,
pdID
,
err
)
glog
.
Errorf
(
"Error detaching volume %q: %v"
,
pdID
,
err
)
return
err
return
err
...
...
pkg/volume/photon_pd/photon_util.go
View file @
20b9fc69
...
@@ -39,16 +39,14 @@ const (
...
@@ -39,16 +39,14 @@ const (
)
)
var
ErrProbeVolume
=
errors
.
New
(
"Error scanning attached volumes"
)
var
ErrProbeVolume
=
errors
.
New
(
"Error scanning attached volumes"
)
// volNameToDeviceName is a mapping between spec.Name from detacher
// and the device name inside scsi path. Once pvscsi controller is
// supported, this won't be needed.
var
volNameToDeviceName
=
make
(
map
[
string
]
string
)
var
volNameToDeviceName
=
make
(
map
[
string
]
string
)
type
PhotonDiskUtil
struct
{}
type
PhotonDiskUtil
struct
{}
func
logError
(
msg
string
,
err
error
)
error
{
s
:=
"Photon Controller utility: "
+
msg
+
". Error ["
+
err
.
Error
()
+
"]"
glog
.
Errorf
(
s
)
return
fmt
.
Errorf
(
s
)
}
func
removeFromScsiSubsystem
(
volName
string
)
{
func
removeFromScsiSubsystem
(
volName
string
)
{
// TODO: if using pvscsi controller, this won't be needed
// TODO: if using pvscsi controller, this won't be needed
deviceName
:=
volNameToDeviceName
[
volName
]
deviceName
:=
volNameToDeviceName
[
volName
]
...
@@ -85,7 +83,8 @@ func verifyDevicePath(path string) (string, error) {
...
@@ -85,7 +83,8 @@ func verifyDevicePath(path string) (string, error) {
func
(
util
*
PhotonDiskUtil
)
CreateVolume
(
p
*
photonPersistentDiskProvisioner
)
(
pdID
string
,
capacityGB
int
,
err
error
)
{
func
(
util
*
PhotonDiskUtil
)
CreateVolume
(
p
*
photonPersistentDiskProvisioner
)
(
pdID
string
,
capacityGB
int
,
err
error
)
{
cloud
,
err
:=
getCloudProvider
(
p
.
plugin
.
host
.
GetCloudProvider
())
cloud
,
err
:=
getCloudProvider
(
p
.
plugin
.
host
.
GetCloudProvider
())
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
0
,
logError
(
"CreateVolume failed to get cloud provider"
,
err
)
glog
.
Errorf
(
"Photon Controller Util: CreateVolume failed to get cloud provider. Error [%v]"
,
err
)
return
""
,
0
,
err
}
}
capacity
:=
p
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
api
.
ResourceName
(
api
.
ResourceStorage
)]
capacity
:=
p
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
api
.
ResourceName
(
api
.
ResourceStorage
)]
...
@@ -104,13 +103,15 @@ func (util *PhotonDiskUtil) CreateVolume(p *photonPersistentDiskProvisioner) (pd
...
@@ -104,13 +103,15 @@ func (util *PhotonDiskUtil) CreateVolume(p *photonPersistentDiskProvisioner) (pd
case
"flavor"
:
case
"flavor"
:
volumeOptions
.
Flavor
=
value
volumeOptions
.
Flavor
=
value
default
:
default
:
return
""
,
0
,
logError
(
"invalid option "
+
parameter
+
" for volume plugin "
+
p
.
plugin
.
GetPluginName
(),
err
)
glog
.
Errorf
(
"Photon Controller Util: invalid option %s for volume plugin %s."
,
parameter
,
p
.
plugin
.
GetPluginName
())
return
""
,
0
,
fmt
.
Errorf
(
"Photon Controller Util: invalid option %s for volume plugin %s."
,
parameter
,
p
.
plugin
.
GetPluginName
())
}
}
}
}
pdID
,
err
=
cloud
.
CreateDisk
(
volumeOptions
)
pdID
,
err
=
cloud
.
CreateDisk
(
volumeOptions
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
0
,
logError
(
"failed to CreateDisk"
,
err
)
glog
.
Errorf
(
"Photon Controller Util: failed to CreateDisk. Error [%v]"
,
err
)
return
""
,
0
,
err
}
}
glog
.
V
(
4
)
.
Infof
(
"Successfully created Photon Controller persistent disk %s"
,
name
)
glog
.
V
(
4
)
.
Infof
(
"Successfully created Photon Controller persistent disk %s"
,
name
)
...
@@ -121,11 +122,13 @@ func (util *PhotonDiskUtil) CreateVolume(p *photonPersistentDiskProvisioner) (pd
...
@@ -121,11 +122,13 @@ func (util *PhotonDiskUtil) CreateVolume(p *photonPersistentDiskProvisioner) (pd
func
(
util
*
PhotonDiskUtil
)
DeleteVolume
(
pd
*
photonPersistentDiskDeleter
)
error
{
func
(
util
*
PhotonDiskUtil
)
DeleteVolume
(
pd
*
photonPersistentDiskDeleter
)
error
{
cloud
,
err
:=
getCloudProvider
(
pd
.
plugin
.
host
.
GetCloudProvider
())
cloud
,
err
:=
getCloudProvider
(
pd
.
plugin
.
host
.
GetCloudProvider
())
if
err
!=
nil
{
if
err
!=
nil
{
return
logError
(
"DeleteVolume failed to get cloud provider"
,
err
)
glog
.
Errorf
(
"Photon Controller Util: DeleteVolume failed to get cloud provider. Error [%v]"
,
err
)
return
err
}
}
if
err
=
cloud
.
DeleteDisk
(
pd
.
pdID
);
err
!=
nil
{
if
err
=
cloud
.
DeleteDisk
(
pd
.
pdID
);
err
!=
nil
{
return
logError
(
"failed to DeleteDisk for pdID "
+
pd
.
pdID
,
err
)
glog
.
Errorf
(
"Photon Controller Util: failed to DeleteDisk for pdID %s. Error [%v]"
,
pd
.
pdID
,
err
)
return
err
}
}
glog
.
V
(
4
)
.
Infof
(
"Successfully deleted PhotonController persistent disk %s"
,
pd
.
pdID
)
glog
.
V
(
4
)
.
Infof
(
"Successfully deleted PhotonController persistent disk %s"
,
pd
.
pdID
)
...
@@ -134,12 +137,14 @@ func (util *PhotonDiskUtil) DeleteVolume(pd *photonPersistentDiskDeleter) error
...
@@ -134,12 +137,14 @@ func (util *PhotonDiskUtil) DeleteVolume(pd *photonPersistentDiskDeleter) error
func
getCloudProvider
(
cloud
cloudprovider
.
Interface
)
(
*
photon
.
PCCloud
,
error
)
{
func
getCloudProvider
(
cloud
cloudprovider
.
Interface
)
(
*
photon
.
PCCloud
,
error
)
{
if
cloud
==
nil
{
if
cloud
==
nil
{
return
nil
,
logError
(
"Cloud provider not initialized properly"
,
nil
)
glog
.
Errorf
(
"Photon Controller Util: Cloud provider not initialized properly"
)
return
nil
,
fmt
.
Errorf
(
"Photon Controller Util: Cloud provider not initialized properly"
)
}
}
pcc
:=
cloud
.
(
*
photon
.
PCCloud
)
pcc
:=
cloud
.
(
*
photon
.
PCCloud
)
if
pcc
==
nil
{
if
pcc
==
nil
{
return
nil
,
logError
(
"Invalid cloud provider: expected Photon Controller"
,
nil
)
glog
.
Errorf
(
"Invalid cloud provider: expected Photon Controller"
)
return
nil
,
fmt
.
Errorf
(
"Invalid cloud provider: expected Photon Controller"
)
}
}
return
pcc
,
nil
return
pcc
,
nil
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment