mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Update tests to use v1.CSINode
This commit is contained in:
parent
d27fa9d890
commit
2d467ed9d8
@ -27,7 +27,6 @@ import (
|
|||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
storagev1 "k8s.io/api/storage/v1"
|
storagev1 "k8s.io/api/storage/v1"
|
||||||
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -276,7 +275,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
|
|||||||
handle := getVolumeHandle(m.cs, claim)
|
handle := getVolumeHandle(m.cs, claim)
|
||||||
attachmentHash := sha256.Sum256([]byte(fmt.Sprintf("%s%s%s", handle, m.provisioner, m.config.ClientNodeName)))
|
attachmentHash := sha256.Sum256([]byte(fmt.Sprintf("%s%s%s", handle, m.provisioner, m.config.ClientNodeName)))
|
||||||
attachmentName := fmt.Sprintf("csi-%x", attachmentHash)
|
attachmentName := fmt.Sprintf("csi-%x", attachmentHash)
|
||||||
_, err = m.cs.StorageV1beta1().VolumeAttachments().Get(attachmentName, metav1.GetOptions{})
|
_, err = m.cs.StorageV1().VolumeAttachments().Get(attachmentName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.IsNotFound(err) {
|
if errors.IsNotFound(err) {
|
||||||
if !test.disableAttach {
|
if !test.disableAttach {
|
||||||
@ -616,7 +615,7 @@ func checkCSINodeForLimits(nodeName string, driverName string, cs clientset.Inte
|
|||||||
var attachLimit int32
|
var attachLimit int32
|
||||||
|
|
||||||
waitErr := wait.PollImmediate(10*time.Second, csiNodeLimitUpdateTimeout, func() (bool, error) {
|
waitErr := wait.PollImmediate(10*time.Second, csiNodeLimitUpdateTimeout, func() (bool, error) {
|
||||||
csiNode, err := cs.StorageV1beta1().CSINodes().Get(nodeName, metav1.GetOptions{})
|
csiNode, err := cs.StorageV1().CSINodes().Get(nodeName, metav1.GetOptions{})
|
||||||
if err != nil && !errors.IsNotFound(err) {
|
if err != nil && !errors.IsNotFound(err) {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@ -841,7 +840,7 @@ func getVolumeHandle(cs clientset.Interface, claim *v1.PersistentVolumeClaim) st
|
|||||||
return pv.Spec.CSI.VolumeHandle
|
return pv.Spec.CSI.VolumeHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVolumeLimitFromCSINode(csiNode *storagev1beta1.CSINode, driverName string) int32 {
|
func getVolumeLimitFromCSINode(csiNode *storagev1.CSINode, driverName string) int32 {
|
||||||
for _, d := range csiNode.Spec.Drivers {
|
for _, d := range csiNode.Spec.Drivers {
|
||||||
if d.Name != driverName {
|
if d.Name != driverName {
|
||||||
continue
|
continue
|
||||||
|
@ -493,7 +493,7 @@ func waitForCSIDriverRegistrationOnNode(nodeName string, driverName string, cs c
|
|||||||
const csiNodeRegisterTimeout = 1 * time.Minute
|
const csiNodeRegisterTimeout = 1 * time.Minute
|
||||||
|
|
||||||
return wait.PollImmediate(10*time.Second, csiNodeRegisterTimeout, func() (bool, error) {
|
return wait.PollImmediate(10*time.Second, csiNodeRegisterTimeout, func() (bool, error) {
|
||||||
csiNode, err := cs.StorageV1beta1().CSINodes().Get(nodeName, metav1.GetOptions{})
|
csiNode, err := cs.StorageV1().CSINodes().Get(nodeName, metav1.GetOptions{})
|
||||||
if err != nil && !errors.IsNotFound(err) {
|
if err != nil && !errors.IsNotFound(err) {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ go_library(
|
|||||||
"//pkg/volume/util:go_default_library",
|
"//pkg/volume/util:go_default_library",
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/storage/v1:go_default_library",
|
"//staging/src/k8s.io/api/storage/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/storage/v1beta1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
storagev1 "k8s.io/api/storage/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
@ -319,12 +319,12 @@ func getCSINodeLimits(cs clientset.Interface, nodeName string, driverInfo *Drive
|
|||||||
// Wait in a loop, the driver might just have been installed and kubelet takes a while to publish everything.
|
// Wait in a loop, the driver might just have been installed and kubelet takes a while to publish everything.
|
||||||
var limit int
|
var limit int
|
||||||
err := wait.PollImmediate(2*time.Second, csiNodeInfoTimeout, func() (bool, error) {
|
err := wait.PollImmediate(2*time.Second, csiNodeInfoTimeout, func() (bool, error) {
|
||||||
csiNode, err := cs.StorageV1beta1().CSINodes().Get(nodeName, metav1.GetOptions{})
|
csiNode, err := cs.StorageV1().CSINodes().Get(nodeName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("%s", err)
|
framework.Logf("%s", err)
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
var csiDriver *storagev1beta1.CSINodeDriver
|
var csiDriver *storagev1.CSINodeDriver
|
||||||
for _, c := range csiNode.Spec.Drivers {
|
for _, c := range csiNode.Spec.Drivers {
|
||||||
if c.Name == driverInfo.Name {
|
if c.Name == driverInfo.Name {
|
||||||
csiDriver = &c
|
csiDriver = &c
|
||||||
|
@ -54,7 +54,6 @@ go_test(
|
|||||||
"//staging/src/k8s.io/api/policy/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/policy/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/rbac/v1:go_default_library",
|
"//staging/src/k8s.io/api/rbac/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/storage/v1:go_default_library",
|
"//staging/src/k8s.io/api/storage/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/storage/v1beta1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library",
|
"//staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset:go_default_library",
|
"//staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||||
|
@ -27,7 +27,6 @@ import (
|
|||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
policy "k8s.io/api/policy/v1beta1"
|
policy "k8s.io/api/policy/v1beta1"
|
||||||
storagev1 "k8s.io/api/storage/v1"
|
storagev1 "k8s.io/api/storage/v1"
|
||||||
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
|
||||||
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
|
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
@ -399,18 +398,18 @@ func TestNodeAuthorizer(t *testing.T) {
|
|||||||
|
|
||||||
getNode1CSINode := func(client clientset.Interface) func() error {
|
getNode1CSINode := func(client clientset.Interface) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
_, err := client.StorageV1beta1().CSINodes().Get("node1", metav1.GetOptions{})
|
_, err := client.StorageV1().CSINodes().Get("node1", metav1.GetOptions{})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createNode1CSINode := func(client clientset.Interface) func() error {
|
createNode1CSINode := func(client clientset.Interface) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
nodeInfo := &storagev1beta1.CSINode{
|
nodeInfo := &storagev1.CSINode{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "node1",
|
Name: "node1",
|
||||||
},
|
},
|
||||||
Spec: storagev1beta1.CSINodeSpec{
|
Spec: storagev1.CSINodeSpec{
|
||||||
Drivers: []storagev1beta1.CSINodeDriver{
|
Drivers: []storagev1.CSINodeDriver{
|
||||||
{
|
{
|
||||||
Name: "com.example.csi.driver1",
|
Name: "com.example.csi.driver1",
|
||||||
NodeID: "com.example.csi/node1",
|
NodeID: "com.example.csi/node1",
|
||||||
@ -419,24 +418,24 @@ func TestNodeAuthorizer(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err := client.StorageV1beta1().CSINodes().Create(nodeInfo)
|
_, err := client.StorageV1().CSINodes().Create(nodeInfo)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateNode1CSINode := func(client clientset.Interface) func() error {
|
updateNode1CSINode := func(client clientset.Interface) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
nodeInfo, err := client.StorageV1beta1().CSINodes().Get("node1", metav1.GetOptions{})
|
nodeInfo, err := client.StorageV1().CSINodes().Get("node1", metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
nodeInfo.Spec.Drivers = []storagev1beta1.CSINodeDriver{
|
nodeInfo.Spec.Drivers = []storagev1.CSINodeDriver{
|
||||||
{
|
{
|
||||||
Name: "com.example.csi.driver2",
|
Name: "com.example.csi.driver2",
|
||||||
NodeID: "com.example.csi/node1",
|
NodeID: "com.example.csi/node1",
|
||||||
TopologyKeys: []string{"com.example.csi/rack"},
|
TopologyKeys: []string{"com.example.csi/rack"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err = client.StorageV1beta1().CSINodes().Update(nodeInfo)
|
_, err = client.StorageV1().CSINodes().Update(nodeInfo)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -444,13 +443,13 @@ func TestNodeAuthorizer(t *testing.T) {
|
|||||||
return func() error {
|
return func() error {
|
||||||
bs := []byte(fmt.Sprintf(`{"csiDrivers": [ { "driver": "net.example.storage.driver2", "nodeID": "net.example.storage/node1", "topologyKeys": [ "net.example.storage/region" ] } ] }`))
|
bs := []byte(fmt.Sprintf(`{"csiDrivers": [ { "driver": "net.example.storage.driver2", "nodeID": "net.example.storage/node1", "topologyKeys": [ "net.example.storage/region" ] } ] }`))
|
||||||
// StrategicMergePatch is unsupported by CRs. Falling back to MergePatch
|
// StrategicMergePatch is unsupported by CRs. Falling back to MergePatch
|
||||||
_, err := client.StorageV1beta1().CSINodes().Patch("node1", types.MergePatchType, bs)
|
_, err := client.StorageV1().CSINodes().Patch("node1", types.MergePatchType, bs)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteNode1CSINode := func(client clientset.Interface) func() error {
|
deleteNode1CSINode := func(client clientset.Interface) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
return client.StorageV1beta1().CSINodes().Delete("node1", &metav1.DeleteOptions{})
|
return client.StorageV1().CSINodes().Delete("node1", &metav1.DeleteOptions{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user