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

Commit 2d44c46

Browse files
authored
Merge pull request #38 from wongma7/release-1.6
Update lib to client-go master, kube 1.6
2 parents 8b34e18 + e98e26d commit 2d44c46

File tree

2,166 files changed

+180596
-480706
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,166 files changed

+180596
-480706
lines changed

aws/efs/cmd/efs-provisioner/efs-provisioner.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ import (
3232
"github.com/docker/docker/pkg/mount"
3333
"github.com/golang/glog"
3434
"github.com/kubernetes-incubator/external-storage/aws/efs/pkg/gidallocator"
35-
"github.com/kubernetes-incubator/external-storage/aws/efs/pkg/util"
3635
"github.com/kubernetes-incubator/external-storage/lib/controller"
3736
"github.com/kubernetes-incubator/external-storage/lib/leaderelection"
37+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
38+
"k8s.io/apimachinery/pkg/util/wait"
3839
"k8s.io/client-go/kubernetes"
3940
"k8s.io/client-go/pkg/api/v1"
40-
"k8s.io/client-go/pkg/util/wait"
4141
"k8s.io/client-go/rest"
4242
)
4343

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

145145
pv := &v1.PersistentVolume{
146-
ObjectMeta: v1.ObjectMeta{
146+
ObjectMeta: metav1.ObjectMeta{
147147
Name: options.PVName,
148148
Annotations: map[string]string{
149-
util.VolumeGidAnnotationKey: strconv.FormatInt(int64(gid), 10),
149+
gidallocator.VolumeGidAnnotationKey: strconv.FormatInt(int64(gid), 10),
150150
},
151151
},
152152
Spec: v1.PersistentVolumeSpec{

aws/efs/pkg/gidallocator/allocator.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ import (
2525

2626
"github.com/golang/glog"
2727
"github.com/kubernetes-incubator/external-storage/aws/efs/pkg/allocator"
28-
"github.com/kubernetes-incubator/external-storage/aws/efs/pkg/util"
2928
"github.com/kubernetes-incubator/external-storage/lib/controller"
29+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
"k8s.io/client-go/kubernetes"
3131
"k8s.io/client-go/pkg/api/v1"
3232
)
3333

3434
const (
35+
// VolumeGidAnnotationKey is the key of the annotation on the PersistentVolume
36+
// object that specifies a supplemental GID.
37+
VolumeGidAnnotationKey = "pv.beta.kubernetes.io/gid"
38+
3539
defaultGidMin = 2000
3640
defaultGidMax = math.MaxInt32
3741
// absoluteGidMin/Max are currently the same as the
@@ -61,7 +65,7 @@ func New(client kubernetes.Interface) Allocator {
6165
// AllocateNext allocates the next available GID for the given VolumeOptions
6266
// (claim's options for a volume it wants) from the appropriate GID table.
6367
func (a *Allocator) AllocateNext(options controller.VolumeOptions) (int, error) {
64-
class := util.GetClaimStorageClass(options.PVC)
68+
class := v1.GetPersistentVolumeClaimClass(options.PVC)
6569
gidMin, gidMax, err := parseClassParameters(options.Parameters)
6670
if err != nil {
6771
return 0, err
@@ -83,10 +87,7 @@ func (a *Allocator) AllocateNext(options controller.VolumeOptions) (int, error)
8387
// Release releases the given volume's allocated GID from the appropriate GID
8488
// table.
8589
func (a *Allocator) Release(volume *v1.PersistentVolume) error {
86-
class, err := util.GetClassForVolume(a.client, volume)
87-
if err != nil {
88-
return err
89-
}
90+
class, err := a.client.Storage().StorageClasses().Get(v1.GetPersistentVolumeClass(volume), metav1.GetOptions{})
9091
gidMin, gidMax, err := parseClassParameters(class.Parameters)
9192
if err != nil {
9293
return err
@@ -173,20 +174,20 @@ func (a *Allocator) getGidTable(className string, min int, max int) (*allocator.
173174
// in a given storage class, and mark them in the table.
174175
//
175176
func (a *Allocator) collectGids(className string, gidTable *allocator.MinMaxAllocator) error {
176-
pvList, err := a.client.Core().PersistentVolumes().List(v1.ListOptions{})
177+
pvList, err := a.client.Core().PersistentVolumes().List(metav1.ListOptions{})
177178
if err != nil {
178179
glog.Errorf("failed to get existing persistent volumes")
179180
return err
180181
}
181182

182183
for _, pv := range pvList.Items {
183-
if util.GetVolumeStorageClass(&pv) != className {
184+
if v1.GetPersistentVolumeClass(&pv) != className {
184185
continue
185186
}
186187

187188
pvName := pv.ObjectMeta.Name
188189

189-
gidStr, ok := pv.Annotations[util.VolumeGidAnnotationKey]
190+
gidStr, ok := pv.Annotations[VolumeGidAnnotationKey]
190191

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

254255
func getGid(volume *v1.PersistentVolume) (int, bool, error) {
255-
gidStr, ok := volume.Annotations[util.VolumeGidAnnotationKey]
256+
gidStr, ok := volume.Annotations[VolumeGidAnnotationKey]
256257

257258
if !ok {
258259
return 0, false, nil

aws/efs/pkg/util/util.go

Lines changed: 0 additions & 86 deletions
This file was deleted.

ceph/cephfs/cephfs-provisioner.go

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ import (
2727

2828
"github.com/golang/glog"
2929
"github.com/kubernetes-incubator/external-storage/lib/controller"
30+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31+
"k8s.io/apimachinery/pkg/types"
32+
"k8s.io/apimachinery/pkg/util/uuid"
33+
"k8s.io/apimachinery/pkg/util/wait"
3034
"k8s.io/client-go/kubernetes"
3135
"k8s.io/client-go/pkg/api/v1"
32-
storage "k8s.io/client-go/pkg/apis/storage/v1beta1"
33-
"k8s.io/client-go/pkg/types"
34-
"k8s.io/client-go/pkg/util/uuid"
35-
"k8s.io/client-go/pkg/util/wait"
3636
"k8s.io/client-go/rest"
3737
"k8s.io/client-go/tools/clientcmd"
3838
)
@@ -108,7 +108,7 @@ func (p *cephFSProvisioner) Provision(options controller.VolumeOptions) (*v1.Per
108108
nameSpace := options.PVC.Namespace
109109
secretName := "ceph-" + user + "-secret"
110110
secret := &v1.Secret{
111-
ObjectMeta: v1.ObjectMeta{
111+
ObjectMeta: metav1.ObjectMeta{
112112
Namespace: nameSpace,
113113
Name: secretName,
114114
},
@@ -129,7 +129,7 @@ func (p *cephFSProvisioner) Provision(options controller.VolumeOptions) (*v1.Per
129129
}
130130

131131
pv := &v1.PersistentVolume{
132-
ObjectMeta: v1.ObjectMeta{
132+
ObjectMeta: metav1.ObjectMeta{
133133
Name: options.PVName,
134134
Annotations: map[string]string{
135135
provisionerIDAnn: string(p.identity),
@@ -179,7 +179,7 @@ func (p *cephFSProvisioner) Delete(volume *v1.PersistentVolume) error {
179179
return errors.New("ceph share annotation not found on PV")
180180
}
181181
// delete CephFS
182-
class, err := p.getClassForVolume(volume)
182+
class, err := p.client.Storage().StorageClasses().Get(v1.GetPersistentVolumeClass(volume), metav1.GetOptions{})
183183
if err != nil {
184184
return err
185185
}
@@ -253,7 +253,7 @@ func (p *cephFSProvisioner) parsePVSecret(namespace, secretName string) (string,
253253
if p.client == nil {
254254
return "", fmt.Errorf("Cannot get kube client")
255255
}
256-
secrets, err := p.client.Core().Secrets(namespace).Get(secretName)
256+
secrets, err := p.client.Core().Secrets(namespace).Get(secretName, metav1.GetOptions{})
257257
if err != nil {
258258
return "", err
259259
}
@@ -265,19 +265,6 @@ func (p *cephFSProvisioner) parsePVSecret(namespace, secretName string) (string,
265265
return "", fmt.Errorf("no secret found")
266266
}
267267

268-
func (p *cephFSProvisioner) getClassForVolume(pv *v1.PersistentVolume) (*storage.StorageClass, error) {
269-
className, found := pv.Annotations["volume.beta.kubernetes.io/storage-class"]
270-
if !found {
271-
return nil, fmt.Errorf("Volume has no class annotation")
272-
}
273-
274-
class, err := p.client.Storage().StorageClasses().Get(className)
275-
if err != nil {
276-
return nil, err
277-
}
278-
return class, nil
279-
}
280-
281268
var (
282269
master = flag.String("master", "", "Master URL")
283270
kubeconfig = flag.String("kubeconfig", "", "Absolute path to the kubeconfig")

0 commit comments

Comments
 (0)