Skip to content

Commit 711b310

Browse files
authored
Merge pull request kubernetes#74606 from andrewsykim/cleanup-volumeattachment
replace usage of v1beta1 VolumeAttachments with v1
2 parents 02b8056 + 01933b0 commit 711b310

File tree

16 files changed

+50
-53
lines changed

16 files changed

+50
-53
lines changed

pkg/kubeapiserver/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ go_library(
2121
"//pkg/apis/extensions:go_default_library",
2222
"//pkg/apis/networking:go_default_library",
2323
"//pkg/apis/policy:go_default_library",
24-
"//pkg/apis/storage:go_default_library",
2524
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
2625
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
2726
"//staging/src/k8s.io/apiserver/pkg/server/options:go_default_library",

pkg/kubeapiserver/authorizer/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (config Config) New() (authorizer.Authorizer, authorizer.RuleResolver, erro
7676
config.VersionedInformerFactory.Core().V1().Nodes(),
7777
config.VersionedInformerFactory.Core().V1().Pods(),
7878
config.VersionedInformerFactory.Core().V1().PersistentVolumes(),
79-
config.VersionedInformerFactory.Storage().V1beta1().VolumeAttachments(),
79+
config.VersionedInformerFactory.Storage().V1().VolumeAttachments(),
8080
)
8181
nodeAuthorizer := node.NewAuthorizer(graph, nodeidentifier.NewDefaultNodeIdentifier(), bootstrappolicy.NodeRules())
8282
authorizers = append(authorizers, nodeAuthorizer)

pkg/kubeapiserver/default_storage_factory_builder.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
"k8s.io/kubernetes/pkg/apis/extensions"
3535
"k8s.io/kubernetes/pkg/apis/networking"
3636
"k8s.io/kubernetes/pkg/apis/policy"
37-
apisstorage "k8s.io/kubernetes/pkg/apis/storage"
3837
)
3938

4039
// SpecialDefaultResourcePrefixes are prefixes compiled into Kubernetes.
@@ -54,7 +53,6 @@ func NewStorageFactoryConfig() *StorageFactoryConfig {
5453
DefaultResourceEncoding: serverstorage.NewDefaultResourceEncodingConfig(legacyscheme.Scheme),
5554
ResourceEncodingOverrides: []schema.GroupVersionResource{
5655
batch.Resource("cronjobs").WithVersion("v1beta1"),
57-
apisstorage.Resource("volumeattachments").WithVersion("v1beta1"),
5856
},
5957
}
6058
}

pkg/volume/csi/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ go_library(
2020
"//pkg/volume/csi/nodeinfomanager:go_default_library",
2121
"//pkg/volume/util:go_default_library",
2222
"//staging/src/k8s.io/api/core/v1:go_default_library",
23-
"//staging/src/k8s.io/api/storage/v1beta1:go_default_library",
23+
"//staging/src/k8s.io/api/storage/v1:go_default_library",
2424
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
2525
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
2626
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
@@ -57,7 +57,7 @@ go_test(
5757
"//pkg/volume/testing:go_default_library",
5858
"//pkg/volume/util:go_default_library",
5959
"//staging/src/k8s.io/api/core/v1:go_default_library",
60-
"//staging/src/k8s.io/api/storage/v1beta1:go_default_library",
60+
"//staging/src/k8s.io/api/storage/v1:go_default_library",
6161
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
6262
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
6363
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",

pkg/volume/csi/csi_attacher.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"k8s.io/klog"
3131

3232
"k8s.io/api/core/v1"
33-
storage "k8s.io/api/storage/v1beta1"
33+
storage "k8s.io/api/storage/v1"
3434
apierrs "k8s.io/apimachinery/pkg/api/errors"
3535
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3636
"k8s.io/apimachinery/pkg/types"
@@ -86,7 +86,7 @@ func (c *csiAttacher) Attach(spec *volume.Spec, nodeName types.NodeName) (string
8686
},
8787
}
8888

89-
_, err = c.k8s.StorageV1beta1().VolumeAttachments().Create(attachment)
89+
_, err = c.k8s.StorageV1().VolumeAttachments().Create(attachment)
9090
alreadyExist := false
9191
if err != nil {
9292
if !apierrs.IsAlreadyExists(err) {
@@ -135,7 +135,7 @@ func (c *csiAttacher) waitForVolumeAttachment(volumeHandle, attachID string, tim
135135

136136
func (c *csiAttacher) waitForVolumeAttachmentInternal(volumeHandle, attachID string, timer *time.Timer, timeout time.Duration) (string, error) {
137137
klog.V(4).Info(log("probing VolumeAttachment [id=%v]", attachID))
138-
attach, err := c.k8s.StorageV1beta1().VolumeAttachments().Get(attachID, meta.GetOptions{})
138+
attach, err := c.k8s.StorageV1().VolumeAttachments().Get(attachID, meta.GetOptions{})
139139
if err != nil {
140140
klog.Error(log("attacher.WaitForAttach failed for volume [%s] (will continue to try): %v", volumeHandle, err))
141141
return "", fmt.Errorf("volume %v has GET error for volume attachment %v: %v", volumeHandle, attachID, err)
@@ -148,7 +148,7 @@ func (c *csiAttacher) waitForVolumeAttachmentInternal(volumeHandle, attachID str
148148
return attachID, nil
149149
}
150150

151-
watcher, err := c.k8s.StorageV1beta1().VolumeAttachments().Watch(meta.SingleObject(meta.ObjectMeta{Name: attachID, ResourceVersion: attach.ResourceVersion}))
151+
watcher, err := c.k8s.StorageV1().VolumeAttachments().Watch(meta.SingleObject(meta.ObjectMeta{Name: attachID, ResourceVersion: attach.ResourceVersion}))
152152
if err != nil {
153153
return "", fmt.Errorf("watch error:%v for volume %v", err, volumeHandle)
154154
}
@@ -238,7 +238,7 @@ func (c *csiAttacher) VolumesAreAttached(specs []*volume.Spec, nodeName types.No
238238

239239
attachID := getAttachmentName(source.VolumeHandle, source.Driver, string(nodeName))
240240
klog.V(4).Info(log("probing attachment status for VolumeAttachment %v", attachID))
241-
attach, err := c.k8s.StorageV1beta1().VolumeAttachments().Get(attachID, meta.GetOptions{})
241+
attach, err := c.k8s.StorageV1().VolumeAttachments().Get(attachID, meta.GetOptions{})
242242
if err != nil {
243243
attached[spec] = false
244244
klog.Error(log("attacher.VolumesAreAttached failed for attach.ID=%v: %v", attachID, err))
@@ -417,7 +417,7 @@ func (c *csiAttacher) Detach(volumeName string, nodeName types.NodeName) error {
417417
attachID = getAttachmentName(volID, driverName, string(nodeName))
418418
}
419419

420-
if err := c.k8s.StorageV1beta1().VolumeAttachments().Delete(attachID, nil); err != nil {
420+
if err := c.k8s.StorageV1().VolumeAttachments().Delete(attachID, nil); err != nil {
421421
if apierrs.IsNotFound(err) {
422422
// object deleted or never existed, done
423423
klog.V(4).Info(log("VolumeAttachment object [%v] for volume [%v] not found, object deleted", attachID, volID))
@@ -443,7 +443,7 @@ func (c *csiAttacher) waitForVolumeDetachment(volumeHandle, attachID string) err
443443

444444
func (c *csiAttacher) waitForVolumeDetachmentInternal(volumeHandle, attachID string, timer *time.Timer, timeout time.Duration) error {
445445
klog.V(4).Info(log("probing VolumeAttachment [id=%v]", attachID))
446-
attach, err := c.k8s.StorageV1beta1().VolumeAttachments().Get(attachID, meta.GetOptions{})
446+
attach, err := c.k8s.StorageV1().VolumeAttachments().Get(attachID, meta.GetOptions{})
447447
if err != nil {
448448
if apierrs.IsNotFound(err) {
449449
//object deleted or never existed, done
@@ -460,7 +460,7 @@ func (c *csiAttacher) waitForVolumeDetachmentInternal(volumeHandle, attachID str
460460
return errors.New(detachErr.Message)
461461
}
462462

463-
watcher, err := c.k8s.StorageV1beta1().VolumeAttachments().Watch(meta.SingleObject(meta.ObjectMeta{Name: attachID, ResourceVersion: attach.ResourceVersion}))
463+
watcher, err := c.k8s.StorageV1().VolumeAttachments().Watch(meta.SingleObject(meta.ObjectMeta{Name: attachID, ResourceVersion: attach.ResourceVersion}))
464464
if err != nil {
465465
return fmt.Errorf("watch error:%v for volume %v", err, volumeHandle)
466466
}

pkg/volume/csi/csi_attacher_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"testing"
2525
"time"
2626

27-
storage "k8s.io/api/storage/v1beta1"
27+
storage "k8s.io/api/storage/v1"
2828
apierrs "k8s.io/apimachinery/pkg/api/errors"
2929
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
"k8s.io/apimachinery/pkg/runtime"
@@ -76,7 +76,7 @@ func markVolumeAttached(t *testing.T, client clientset.Interface, watch *watch.R
7676
defer ticker.Stop()
7777
// wait for attachment to be saved
7878
for i := 0; i < 100; i++ {
79-
attach, err = client.StorageV1beta1().VolumeAttachments().Get(attachID, meta.GetOptions{})
79+
attach, err = client.StorageV1().VolumeAttachments().Get(attachID, meta.GetOptions{})
8080
if err != nil {
8181
if apierrs.IsNotFound(err) {
8282
<-ticker.C
@@ -95,7 +95,7 @@ func markVolumeAttached(t *testing.T, client clientset.Interface, watch *watch.R
9595
t.Logf("attachment not found for id:%v", attachID)
9696
} else {
9797
attach.Status = status
98-
_, err := client.StorageV1beta1().VolumeAttachments().Update(attach)
98+
_, err := client.StorageV1().VolumeAttachments().Update(attach)
9999
if err != nil {
100100
t.Error(err)
101101
}
@@ -392,11 +392,11 @@ func TestAttacherWaitForAttach(t *testing.T) {
392392

393393
if test.makeAttachment != nil {
394394
attachment := test.makeAttachment()
395-
_, err = csiAttacher.k8s.StorageV1beta1().VolumeAttachments().Create(attachment)
395+
_, err = csiAttacher.k8s.StorageV1().VolumeAttachments().Create(attachment)
396396
if err != nil {
397397
t.Fatalf("failed to create VolumeAttachment: %v", err)
398398
}
399-
gotAttachment, err := csiAttacher.k8s.StorageV1beta1().VolumeAttachments().Get(attachment.Name, meta.GetOptions{})
399+
gotAttachment, err := csiAttacher.k8s.StorageV1().VolumeAttachments().Get(attachment.Name, meta.GetOptions{})
400400
if err != nil {
401401
t.Fatalf("failed to get created VolumeAttachment: %v", err)
402402
}
@@ -484,7 +484,7 @@ func TestAttacherWaitForVolumeAttachment(t *testing.T) {
484484
attachment := makeTestAttachment(attachID, nodeName, pvName)
485485
attachment.Status.Attached = tc.initAttached
486486
attachment.Status.AttachError = tc.initAttachErr
487-
_, err = csiAttacher.k8s.StorageV1beta1().VolumeAttachments().Create(attachment)
487+
_, err = csiAttacher.k8s.StorageV1().VolumeAttachments().Create(attachment)
488488
if err != nil {
489489
t.Fatalf("failed to attach: %v", err)
490490
}
@@ -548,7 +548,7 @@ func TestAttacherVolumesAreAttached(t *testing.T) {
548548
attachID := getAttachmentName(volName, testDriver, nodeName)
549549
attachment := makeTestAttachment(attachID, nodeName, pv.GetName())
550550
attachment.Status.Attached = stat
551-
_, err := csiAttacher.k8s.StorageV1beta1().VolumeAttachments().Create(attachment)
551+
_, err := csiAttacher.k8s.StorageV1().VolumeAttachments().Create(attachment)
552552
if err != nil {
553553
t.Fatalf("failed to attach: %v", err)
554554
}
@@ -621,7 +621,7 @@ func TestAttacherDetach(t *testing.T) {
621621
pv := makeTestPV("test-pv", 10, testDriver, tc.volID)
622622
spec := volume.NewSpecFromPersistentVolume(pv, pv.Spec.PersistentVolumeSource.CSI.ReadOnly)
623623
attachment := makeTestAttachment(tc.attachID, nodeName, "test-pv")
624-
_, err := csiAttacher.k8s.StorageV1beta1().VolumeAttachments().Create(attachment)
624+
_, err := csiAttacher.k8s.StorageV1().VolumeAttachments().Create(attachment)
625625
if err != nil {
626626
t.Fatalf("failed to attach: %v", err)
627627
}
@@ -639,7 +639,7 @@ func TestAttacherDetach(t *testing.T) {
639639
if !tc.shouldFail && err != nil {
640640
t.Fatalf("unexpected err: %v", err)
641641
}
642-
attach, err := csiAttacher.k8s.StorageV1beta1().VolumeAttachments().Get(tc.attachID, meta.GetOptions{})
642+
attach, err := csiAttacher.k8s.StorageV1().VolumeAttachments().Get(tc.attachID, meta.GetOptions{})
643643
if err != nil {
644644
if !apierrs.IsNotFound(err) {
645645
t.Fatalf("unexpected err: %v", err)
@@ -787,7 +787,7 @@ func TestAttacherMountDevice(t *testing.T) {
787787

788788
// Set up volume attachment
789789
attachment := makeTestAttachment(attachID, nodeName, pvName)
790-
_, err := csiAttacher.k8s.StorageV1beta1().VolumeAttachments().Create(attachment)
790+
_, err := csiAttacher.k8s.StorageV1().VolumeAttachments().Create(attachment)
791791
if err != nil {
792792
t.Fatalf("failed to attach: %v", err)
793793
}

pkg/volume/csi/csi_block.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"k8s.io/klog"
2828

2929
"k8s.io/api/core/v1"
30-
storage "k8s.io/api/storage/v1beta1"
30+
storage "k8s.io/api/storage/v1"
3131
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
"k8s.io/apimachinery/pkg/types"
3333
"k8s.io/client-go/kubernetes"
@@ -227,7 +227,7 @@ func (m *csiBlockMapper) SetUpDevice() (string, error) {
227227
// Search for attachment by VolumeAttachment.Spec.Source.PersistentVolumeName
228228
nodeName := string(m.plugin.host.GetNodeName())
229229
attachID := getAttachmentName(csiSource.VolumeHandle, csiSource.Driver, nodeName)
230-
attachment, err := m.k8s.StorageV1beta1().VolumeAttachments().Get(attachID, meta.GetOptions{})
230+
attachment, err := m.k8s.StorageV1().VolumeAttachments().Get(attachID, meta.GetOptions{})
231231
if err != nil {
232232
klog.Error(log("blockMapper.SetupDevice failed to get volume attachment [id=%v]: %v", attachID, err))
233233
return "", err

pkg/volume/csi/csi_block_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func TestBlockMapperSetupDevice(t *testing.T) {
233233
attachID := getAttachmentName(csiMapper.volumeID, string(csiMapper.driverName), string(nodeName))
234234
attachment := makeTestAttachment(attachID, nodeName, pvName)
235235
attachment.Status.Attached = true
236-
_, err = csiMapper.k8s.StorageV1beta1().VolumeAttachments().Create(attachment)
236+
_, err = csiMapper.k8s.StorageV1().VolumeAttachments().Create(attachment)
237237
if err != nil {
238238
t.Fatalf("failed to setup VolumeAttachment: %v", err)
239239
}
@@ -300,7 +300,7 @@ func TestBlockMapperMapDevice(t *testing.T) {
300300
attachID := getAttachmentName(csiMapper.volumeID, string(csiMapper.driverName), string(nodeName))
301301
attachment := makeTestAttachment(attachID, nodeName, pvName)
302302
attachment.Status.Attached = true
303-
_, err = csiMapper.k8s.StorageV1beta1().VolumeAttachments().Create(attachment)
303+
_, err = csiMapper.k8s.StorageV1().VolumeAttachments().Create(attachment)
304304
if err != nil {
305305
t.Fatalf("failed to setup VolumeAttachment: %v", err)
306306
}

pkg/volume/csi/csi_mounter_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"reflect"
2929

3030
api "k8s.io/api/core/v1"
31-
storage "k8s.io/api/storage/v1beta1"
31+
storage "k8s.io/api/storage/v1"
3232
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3333
"k8s.io/apimachinery/pkg/types"
3434
"k8s.io/apimachinery/pkg/util/wait"
@@ -208,7 +208,7 @@ func MounterSetUpTests(t *testing.T, podInfoEnabled bool) {
208208
DetachError: nil,
209209
},
210210
}
211-
_, err = csiMounter.k8s.StorageV1beta1().VolumeAttachments().Create(attachment)
211+
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(attachment)
212212
if err != nil {
213213
t.Fatalf("failed to setup VolumeAttachment: %v", err)
214214
}
@@ -363,7 +363,7 @@ func TestMounterSetUpWithFSGroup(t *testing.T) {
363363
attachID := getAttachmentName(csiMounter.volumeID, string(csiMounter.driverName), string(plug.host.GetNodeName()))
364364
attachment := makeTestAttachment(attachID, "test-node", pvName)
365365

366-
_, err = csiMounter.k8s.StorageV1beta1().VolumeAttachments().Create(attachment)
366+
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(attachment)
367367
if err != nil {
368368
t.Errorf("failed to setup VolumeAttachment: %v", err)
369369
continue

pkg/volume/csi/csi_plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ func (p *csiPlugin) getPublishContext(client clientset.Interface, handle, driver
638638
attachID := getAttachmentName(handle, driver, nodeName)
639639

640640
// search for attachment by VolumeAttachment.Spec.Source.PersistentVolumeName
641-
attachment, err := client.StorageV1beta1().VolumeAttachments().Get(attachID, meta.GetOptions{})
641+
attachment, err := client.StorageV1().VolumeAttachments().Get(attachID, meta.GetOptions{})
642642
if err != nil {
643643
return nil, err // This err already has enough context ("VolumeAttachment xyz not found")
644644
}

0 commit comments

Comments
 (0)