Skip to content

Commit 3d58fe5

Browse files
authored
Merge pull request kubernetes#123970 from carlory/rm-volumelimit-interface
remove VolumePluginWithAttachLimits interface
2 parents f39ece2 + 0c5a710 commit 3d58fe5

File tree

5 files changed

+0
-151
lines changed

5 files changed

+0
-151
lines changed

pkg/kubelet/kubelet_node_status.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,6 @@ func (kl *Kubelet) defaultNodeStatusFuncs() []func(context.Context, *v1.Node) er
738738
nodestatus.GoRuntime(),
739739
nodestatus.RuntimeHandlers(kl.runtimeState.runtimeHandlers),
740740
)
741-
// Volume limits
742-
setters = append(setters, nodestatus.VolumeLimits(kl.volumePluginMgr.ListVolumePluginWithLimits))
743741

744742
setters = append(setters,
745743
nodestatus.MemoryPressureCondition(kl.clock.Now, kl.evictionManager.IsUnderMemoryPressure, kl.recordNodeStatusEvent),

pkg/kubelet/nodestatus/setters.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import (
4343
"k8s.io/kubernetes/pkg/kubelet/cm"
4444
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
4545
"k8s.io/kubernetes/pkg/kubelet/events"
46-
"k8s.io/kubernetes/pkg/volume"
4746
netutils "k8s.io/utils/net"
4847

4948
"k8s.io/klog/v2"
@@ -779,30 +778,3 @@ func VolumesInUse(syncedFunc func() bool, // typically Kubelet.volumeManager.Rec
779778
return nil
780779
}
781780
}
782-
783-
// VolumeLimits returns a Setter that updates the volume limits on the node.
784-
func VolumeLimits(volumePluginListFunc func() []volume.VolumePluginWithAttachLimits, // typically Kubelet.volumePluginMgr.ListVolumePluginWithLimits
785-
) Setter {
786-
return func(ctx context.Context, node *v1.Node) error {
787-
if node.Status.Capacity == nil {
788-
node.Status.Capacity = v1.ResourceList{}
789-
}
790-
if node.Status.Allocatable == nil {
791-
node.Status.Allocatable = v1.ResourceList{}
792-
}
793-
794-
pluginWithLimits := volumePluginListFunc()
795-
for _, volumePlugin := range pluginWithLimits {
796-
attachLimits, err := volumePlugin.GetVolumeLimits()
797-
if err != nil {
798-
klog.V(4).InfoS("Skipping volume limits for volume plugin", "plugin", volumePlugin.GetPluginName())
799-
continue
800-
}
801-
for limitKey, value := range attachLimits {
802-
node.Status.Capacity[v1.ResourceName(limitKey)] = *resource.NewQuantity(value, resource.DecimalSI)
803-
node.Status.Allocatable[v1.ResourceName(limitKey)] = *resource.NewQuantity(value, resource.DecimalSI)
804-
}
805-
}
806-
return nil
807-
}
808-
}

pkg/kubelet/nodestatus/setters_test.go

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ import (
4848
kubecontainertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
4949
"k8s.io/kubernetes/pkg/kubelet/events"
5050
"k8s.io/kubernetes/pkg/kubelet/util/sliceutils"
51-
"k8s.io/kubernetes/pkg/volume"
52-
volumetest "k8s.io/kubernetes/pkg/volume/testing"
5351
netutils "k8s.io/utils/net"
5452
)
5553

@@ -2076,70 +2074,6 @@ func TestVolumesInUse(t *testing.T) {
20762074
}
20772075
}
20782076

2079-
func TestVolumeLimits(t *testing.T) {
2080-
const (
2081-
volumeLimitKey = "attachable-volumes-fake-provider"
2082-
volumeLimitVal = 16
2083-
)
2084-
2085-
var cases = []struct {
2086-
desc string
2087-
volumePluginList []volume.VolumePluginWithAttachLimits
2088-
expectNode *v1.Node
2089-
}{
2090-
{
2091-
desc: "translate limits to capacity and allocatable for plugins that return successfully from GetVolumeLimits",
2092-
volumePluginList: []volume.VolumePluginWithAttachLimits{
2093-
&volumetest.FakeVolumePlugin{
2094-
VolumeLimits: map[string]int64{volumeLimitKey: volumeLimitVal},
2095-
},
2096-
},
2097-
expectNode: &v1.Node{
2098-
Status: v1.NodeStatus{
2099-
Capacity: v1.ResourceList{
2100-
volumeLimitKey: *resource.NewQuantity(volumeLimitVal, resource.DecimalSI),
2101-
},
2102-
Allocatable: v1.ResourceList{
2103-
volumeLimitKey: *resource.NewQuantity(volumeLimitVal, resource.DecimalSI),
2104-
},
2105-
},
2106-
},
2107-
},
2108-
{
2109-
desc: "skip plugins that return errors from GetVolumeLimits",
2110-
volumePluginList: []volume.VolumePluginWithAttachLimits{
2111-
&volumetest.FakeVolumePlugin{
2112-
VolumeLimitsError: fmt.Errorf("foo"),
2113-
},
2114-
},
2115-
expectNode: &v1.Node{},
2116-
},
2117-
{
2118-
desc: "no plugins",
2119-
expectNode: &v1.Node{},
2120-
},
2121-
}
2122-
2123-
for _, tc := range cases {
2124-
t.Run(tc.desc, func(t *testing.T) {
2125-
ctx := context.Background()
2126-
volumePluginListFunc := func() []volume.VolumePluginWithAttachLimits {
2127-
return tc.volumePluginList
2128-
}
2129-
// construct setter
2130-
setter := VolumeLimits(volumePluginListFunc)
2131-
// call setter on node
2132-
node := &v1.Node{}
2133-
if err := setter(ctx, node); err != nil {
2134-
t.Fatalf("unexpected error: %v", err)
2135-
}
2136-
// check expected node
2137-
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, node),
2138-
"Diff: %s", cmp.Diff(tc.expectNode, node))
2139-
})
2140-
}
2141-
}
2142-
21432077
func TestDaemonEndpoints(t *testing.T) {
21442078
for _, test := range []struct {
21452079
name string

pkg/volume/plugins.go

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -263,32 +263,6 @@ type NodeExpandableVolumePlugin interface {
263263
NodeExpand(resizeOptions NodeResizeOptions) (bool, error)
264264
}
265265

266-
// VolumePluginWithAttachLimits is an extended interface of VolumePlugin that restricts number of
267-
// volumes that can be attached to a node.
268-
type VolumePluginWithAttachLimits interface {
269-
VolumePlugin
270-
// Return maximum number of volumes that can be attached to a node for this plugin.
271-
// The key must be same as string returned by VolumeLimitKey function. The returned
272-
// map may look like:
273-
// - { "storage-limits-aws-ebs": 39 }
274-
// - { "storage-limits-gce-pd": 10 }
275-
// A volume plugin may return error from this function - if it can not be used on a given node or not
276-
// applicable in given environment (where environment could be cloudprovider or any other dependency)
277-
// For example - calling this function for EBS volume plugin on a GCE node should
278-
// result in error.
279-
// The returned values are stored in node allocatable property and will be used
280-
// by scheduler to determine how many pods with volumes can be scheduled on given node.
281-
GetVolumeLimits() (map[string]int64, error)
282-
// Return volume limit key string to be used in node capacity constraints
283-
// The key must start with prefix storage-limits-. For example:
284-
// - storage-limits-aws-ebs
285-
// - storage-limits-csi-cinder
286-
// The key should respect character limit of ResourceName type
287-
// This function may be called by kubelet or scheduler to identify node allocatable property
288-
// which stores volumes limits.
289-
VolumeLimitKey(spec *Spec) string
290-
}
291-
292266
// BlockVolumePlugin is an extend interface of VolumePlugin and is used for block volumes support.
293267
type BlockVolumePlugin interface {
294268
VolumePlugin
@@ -751,20 +725,6 @@ func (pm *VolumePluginMgr) refreshProbedPlugins() {
751725
}
752726
}
753727

754-
// ListVolumePluginWithLimits returns plugins that have volume limits on nodes
755-
func (pm *VolumePluginMgr) ListVolumePluginWithLimits() []VolumePluginWithAttachLimits {
756-
pm.mutex.RLock()
757-
defer pm.mutex.RUnlock()
758-
759-
matchedPlugins := []VolumePluginWithAttachLimits{}
760-
for _, v := range pm.plugins {
761-
if plugin, ok := v.(VolumePluginWithAttachLimits); ok {
762-
matchedPlugins = append(matchedPlugins, plugin)
763-
}
764-
}
765-
return matchedPlugins
766-
}
767-
768728
// FindPersistentPluginBySpec looks for a persistent volume plugin that can
769729
// support a given volume specification. If no plugin is found, return an
770730
// error
@@ -779,20 +739,6 @@ func (pm *VolumePluginMgr) FindPersistentPluginBySpec(spec *Spec) (PersistentVol
779739
return nil, fmt.Errorf("no persistent volume plugin matched")
780740
}
781741

782-
// FindVolumePluginWithLimitsBySpec returns volume plugin that has a limit on how many
783-
// of them can be attached to a node
784-
func (pm *VolumePluginMgr) FindVolumePluginWithLimitsBySpec(spec *Spec) (VolumePluginWithAttachLimits, error) {
785-
volumePlugin, err := pm.FindPluginBySpec(spec)
786-
if err != nil {
787-
return nil, fmt.Errorf("could not find volume plugin for spec : %#v", spec)
788-
}
789-
790-
if limitedPlugin, ok := volumePlugin.(VolumePluginWithAttachLimits); ok {
791-
return limitedPlugin, nil
792-
}
793-
return nil, fmt.Errorf("no plugin with limits found")
794-
}
795-
796742
// FindPersistentPluginByName fetches a persistent volume plugin by name. If
797743
// no plugin is found, returns error.
798744
func (pm *VolumePluginMgr) FindPersistentPluginByName(name string) (PersistentVolumePlugin, error) {

pkg/volume/testing/testing.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ var _ volume.RecyclableVolumePlugin = &FakeVolumePlugin{}
212212
var _ volume.DeletableVolumePlugin = &FakeVolumePlugin{}
213213
var _ volume.ProvisionableVolumePlugin = &FakeVolumePlugin{}
214214
var _ volume.AttachableVolumePlugin = &FakeVolumePlugin{}
215-
var _ volume.VolumePluginWithAttachLimits = &FakeVolumePlugin{}
216215
var _ volume.DeviceMountableVolumePlugin = &FakeVolumePlugin{}
217216
var _ volume.NodeExpandableVolumePlugin = &FakeVolumePlugin{}
218217

0 commit comments

Comments
 (0)