Merge pull request #114528 from mpatlasov/fix-specModified-check

Fix installDriverToCSINode(): do not skip CSINode update if Allocatable.Count changed
This commit is contained in:
Kubernetes Prow Robot 2023-01-02 10:25:30 -08:00 committed by GitHub
commit 7759fdb940
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -505,6 +505,15 @@ func setMigrationAnnotation(migratedPlugins map[string](func() bool), nodeInfo *
return true return true
} }
// Returns true if and only if new maxAttachLimit doesn't require CSINode update
func keepAllocatableCount(driverInfoSpec storagev1.CSINodeDriver, maxAttachLimit int64) bool {
if maxAttachLimit == 0 {
return driverInfoSpec.Allocatable == nil || driverInfoSpec.Allocatable.Count == nil
}
return driverInfoSpec.Allocatable != nil && driverInfoSpec.Allocatable.Count != nil && int64(*driverInfoSpec.Allocatable.Count) == maxAttachLimit
}
func (nim *nodeInfoManager) installDriverToCSINode( func (nim *nodeInfoManager) installDriverToCSINode(
nodeInfo *storagev1.CSINode, nodeInfo *storagev1.CSINode,
driverName string, driverName string,
@ -528,7 +537,8 @@ func (nim *nodeInfoManager) installDriverToCSINode(
for _, driverInfoSpec := range nodeInfo.Spec.Drivers { for _, driverInfoSpec := range nodeInfo.Spec.Drivers {
if driverInfoSpec.Name == driverName { if driverInfoSpec.Name == driverName {
if driverInfoSpec.NodeID == driverNodeID && if driverInfoSpec.NodeID == driverNodeID &&
sets.NewString(driverInfoSpec.TopologyKeys...).Equal(topologyKeys) { sets.NewString(driverInfoSpec.TopologyKeys...).Equal(topologyKeys) &&
keepAllocatableCount(driverInfoSpec, maxAttachLimit) {
specModified = false specModified = false
} }
} else { } else {

View File

@ -593,7 +593,7 @@ func TestInstallCSIDriver(t *testing.T) {
Name: "com.example.csi.driver1", Name: "com.example.csi.driver1",
NodeID: "com.example.csi/csi-node1", NodeID: "com.example.csi/csi-node1",
TopologyKeys: nil, TopologyKeys: nil,
Allocatable: generateVolumeLimits(10), Allocatable: generateVolumeLimits(20),
}, },
}, },
}, },