Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #38 from wongma7/release-1.6
Browse files Browse the repository at this point in the history
Update lib to client-go master, kube 1.6
  • Loading branch information
wongma7 authored Mar 23, 2017
2 parents 8b34e18 + e98e26d commit 2d44c46
Show file tree
Hide file tree
Showing 2,166 changed files with 180,596 additions and 480,706 deletions.
8 changes: 4 additions & 4 deletions aws/efs/cmd/efs-provisioner/efs-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import (
"github.com/docker/docker/pkg/mount"
"github.com/golang/glog"
"github.com/kubernetes-incubator/external-storage/aws/efs/pkg/gidallocator"
"github.com/kubernetes-incubator/external-storage/aws/efs/pkg/util"
"github.com/kubernetes-incubator/external-storage/lib/controller"
"github.com/kubernetes-incubator/external-storage/lib/leaderelection"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/util/wait"
"k8s.io/client-go/rest"
)

Expand Down Expand Up @@ -143,10 +143,10 @@ func (p *efsProvisioner) Provision(options controller.VolumeOptions) (*v1.Persis
}

pv := &v1.PersistentVolume{
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: options.PVName,
Annotations: map[string]string{
util.VolumeGidAnnotationKey: strconv.FormatInt(int64(gid), 10),
gidallocator.VolumeGidAnnotationKey: strconv.FormatInt(int64(gid), 10),
},
},
Spec: v1.PersistentVolumeSpec{
Expand Down
21 changes: 11 additions & 10 deletions aws/efs/pkg/gidallocator/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ import (

"github.com/golang/glog"
"github.com/kubernetes-incubator/external-storage/aws/efs/pkg/allocator"
"github.com/kubernetes-incubator/external-storage/aws/efs/pkg/util"
"github.com/kubernetes-incubator/external-storage/lib/controller"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api/v1"
)

const (
// VolumeGidAnnotationKey is the key of the annotation on the PersistentVolume
// object that specifies a supplemental GID.
VolumeGidAnnotationKey = "pv.beta.kubernetes.io/gid"

defaultGidMin = 2000
defaultGidMax = math.MaxInt32
// absoluteGidMin/Max are currently the same as the
Expand Down Expand Up @@ -61,7 +65,7 @@ func New(client kubernetes.Interface) Allocator {
// AllocateNext allocates the next available GID for the given VolumeOptions
// (claim's options for a volume it wants) from the appropriate GID table.
func (a *Allocator) AllocateNext(options controller.VolumeOptions) (int, error) {
class := util.GetClaimStorageClass(options.PVC)
class := v1.GetPersistentVolumeClaimClass(options.PVC)
gidMin, gidMax, err := parseClassParameters(options.Parameters)
if err != nil {
return 0, err
Expand All @@ -83,10 +87,7 @@ func (a *Allocator) AllocateNext(options controller.VolumeOptions) (int, error)
// Release releases the given volume's allocated GID from the appropriate GID
// table.
func (a *Allocator) Release(volume *v1.PersistentVolume) error {
class, err := util.GetClassForVolume(a.client, volume)
if err != nil {
return err
}
class, err := a.client.Storage().StorageClasses().Get(v1.GetPersistentVolumeClass(volume), metav1.GetOptions{})
gidMin, gidMax, err := parseClassParameters(class.Parameters)
if err != nil {
return err
Expand Down Expand Up @@ -173,20 +174,20 @@ func (a *Allocator) getGidTable(className string, min int, max int) (*allocator.
// in a given storage class, and mark them in the table.
//
func (a *Allocator) collectGids(className string, gidTable *allocator.MinMaxAllocator) error {
pvList, err := a.client.Core().PersistentVolumes().List(v1.ListOptions{})
pvList, err := a.client.Core().PersistentVolumes().List(metav1.ListOptions{})
if err != nil {
glog.Errorf("failed to get existing persistent volumes")
return err
}

for _, pv := range pvList.Items {
if util.GetVolumeStorageClass(&pv) != className {
if v1.GetPersistentVolumeClass(&pv) != className {
continue
}

pvName := pv.ObjectMeta.Name

gidStr, ok := pv.Annotations[util.VolumeGidAnnotationKey]
gidStr, ok := pv.Annotations[VolumeGidAnnotationKey]

if !ok {
glog.Warningf("no gid found in pv '%v'", pvName)
Expand Down Expand Up @@ -252,7 +253,7 @@ func parseClassParameters(params map[string]string) (int, int, error) {
}

func getGid(volume *v1.PersistentVolume) (int, bool, error) {
gidStr, ok := volume.Annotations[util.VolumeGidAnnotationKey]
gidStr, ok := volume.Annotations[VolumeGidAnnotationKey]

if !ok {
return 0, false, nil
Expand Down
86 changes: 0 additions & 86 deletions aws/efs/pkg/util/util.go

This file was deleted.

29 changes: 8 additions & 21 deletions ceph/cephfs/cephfs-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import (

"github.com/golang/glog"
"github.com/kubernetes-incubator/external-storage/lib/controller"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api/v1"
storage "k8s.io/client-go/pkg/apis/storage/v1beta1"
"k8s.io/client-go/pkg/types"
"k8s.io/client-go/pkg/util/uuid"
"k8s.io/client-go/pkg/util/wait"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)
Expand Down Expand Up @@ -108,7 +108,7 @@ func (p *cephFSProvisioner) Provision(options controller.VolumeOptions) (*v1.Per
nameSpace := options.PVC.Namespace
secretName := "ceph-" + user + "-secret"
secret := &v1.Secret{
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Namespace: nameSpace,
Name: secretName,
},
Expand All @@ -129,7 +129,7 @@ func (p *cephFSProvisioner) Provision(options controller.VolumeOptions) (*v1.Per
}

pv := &v1.PersistentVolume{
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: options.PVName,
Annotations: map[string]string{
provisionerIDAnn: string(p.identity),
Expand Down Expand Up @@ -179,7 +179,7 @@ func (p *cephFSProvisioner) Delete(volume *v1.PersistentVolume) error {
return errors.New("ceph share annotation not found on PV")
}
// delete CephFS
class, err := p.getClassForVolume(volume)
class, err := p.client.Storage().StorageClasses().Get(v1.GetPersistentVolumeClass(volume), metav1.GetOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -253,7 +253,7 @@ func (p *cephFSProvisioner) parsePVSecret(namespace, secretName string) (string,
if p.client == nil {
return "", fmt.Errorf("Cannot get kube client")
}
secrets, err := p.client.Core().Secrets(namespace).Get(secretName)
secrets, err := p.client.Core().Secrets(namespace).Get(secretName, metav1.GetOptions{})
if err != nil {
return "", err
}
Expand All @@ -265,19 +265,6 @@ func (p *cephFSProvisioner) parsePVSecret(namespace, secretName string) (string,
return "", fmt.Errorf("no secret found")
}

func (p *cephFSProvisioner) getClassForVolume(pv *v1.PersistentVolume) (*storage.StorageClass, error) {
className, found := pv.Annotations["volume.beta.kubernetes.io/storage-class"]
if !found {
return nil, fmt.Errorf("Volume has no class annotation")
}

class, err := p.client.Storage().StorageClasses().Get(className)
if err != nil {
return nil, err
}
return class, nil
}

var (
master = flag.String("master", "", "Master URL")
kubeconfig = flag.String("kubeconfig", "", "Absolute path to the kubeconfig")
Expand Down
Loading

0 comments on commit 2d44c46

Please sign in to comment.