-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: remove single vm from the cache instead of removing all vms of a… #3507
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
"fmt" | ||
"net/http" | ||
"strings" | ||
"sync" | ||
"testing" | ||
|
||
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-03-01/compute" | ||
|
@@ -121,6 +122,20 @@ func TestVMSSVMCache(t *testing.T) { | |
err = ss.DeleteCacheForNode(vmName) | ||
assert.NoError(t, err) | ||
|
||
// ensure only one vm is removed from the cache | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks adding a test for this scenario! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would you add this test into master branch @nilo19 I think master branch does not have this issue, but still needs a ut, thanks. |
||
cacheKey, timedcache, _ := ss.getVMSSVMCache("rg", "vmss") | ||
entry, _, _ := timedcache.Store.GetByKey(cacheKey) | ||
cached := entry.(*azcache.AzureCacheEntry).Data | ||
virtualMachines := cached.(*sync.Map) | ||
length := 0 | ||
virtualMachines.Range(func(key, value interface{}) bool { | ||
length++ | ||
assert.NotEqual(t, vmName, key) | ||
fmt.Println(key) | ||
return true | ||
}) | ||
assert.Equal(t, 2, length) | ||
|
||
// the VM should be back after another cache refresh. | ||
ssName, instanceID, realVM, err := ss.getVmssVM(vmName, azcache.CacheReadTypeDefault) | ||
assert.NoError(t, err) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see master branch does not have such issue, so this is a specific fix on 1.23?
cloud-provider-azure/pkg/provider/azure_vmss_cache.go
Line 273 in 631b3a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs cherry-pick to 1.23-1.25.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.23-1.25