Repository: kubernetes-sigs/cloud-provider-azure
Pull request #2819 (2022-11-23 18:03:42)

Cleanup: Change the struct of vmssVMCache to use only a timedCache instead of sync.Map
<!--  Thanks for sending a pull request!  Here are some tips for you:

1. If this is your first time, please read our contributor guidelines: https://git.k8s.io/community/contributors/guide/first-contribution.md#your-first-contribution and developer guide https://git.k8s.io/community/contributors/devel/development.md#development-guide
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request. For reference on required PR/issue labels, read here:
https://git.k8s.io/community/contributors/devel/sig-release/release.md#issuepr-kind-label
3. Ensure you have added or ran the appropriate tests for your PR: https://git.k8s.io/community/contributors/devel/sig-testing/testing.md
4. If you want *faster* PR reviews, read how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
5. If the PR is unfinished, see how to mark it: https://git.k8s.io/community/contributors/guide/pull-requests.md#marking-unfinished-pull-requests
-->

#### What type of PR is this?

<!--
Add one of the following kinds:
/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind design

Optionally add one or more of the following kinds if applicable:
/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:

#### Which issue(s) this PR fixes:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
-->
Fixes #

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".

For more information on release notes see: https://git.k8s.io/community/contributors/guide/release-notes.md
-->
```release-note
None
```

#### Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

<!--
This section can be blank if this pull request does not require a release note.

When adding links which point to resources within git repositories, like
KEPs or supporting documentation, please reference a specific commit and avoid
linking directly to the master branch. This ensures that links reference a
specific point in time, rather than a document that may change over time.

See here for guidance on getting permanent links to files: https://help.github.com/en/articles/getting-permanent-links-to-files

Please use the following format for linking documentation:
- [KEP]: <link>
- [Usage]: <link>
- [Other doc]: <link>
-->
```docs

```


k8s-ci-robot: Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with `/test all`
k8s-ci-robot: @mukhoakash: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our [release note process](https://git.k8s.io/community/contributors/guide/release-notes.md) to remove it.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
</details>
netlify[bot]: ### <span aria-hidden="true">👷</span> Deploy Preview for *kubernetes-sigs-cloud-provide-azure* processing.


|  Name | Link |
|---------------------------------|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 0cf1f91f457e32bdba4ea7852074622dc4f75575 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/kubernetes-sigs-cloud-provide-azure/deploys/637e607f0d5b620008d394e8 |
k8s-ci-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/cloud-provider-azure/pull/2819#" title="Author self-approved">mukhoakash</a>*
**Once this PR has been reviewed and has the lgtm label**, please assign feiskyer for approval by writing `/assign @feiskyer` in a comment. For more information see [the Kubernetes Code Review Process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process).

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fcloud-provider-azure).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/kubernetes-sigs/cloud-provider-azure/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["feiskyer"]} -->
mukhoakash: @edreed Fixed the struct of the vmssVMCache to use TimedCache here.
k8s-ci-robot: @mukhoakash: The following test **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-check | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1595478653553086464) | true | `/test pull-cloud-provider-azure-check`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @mukhoakash: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-check | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1595478653553086464) | true | `/test pull-cloud-provider-azure-check`
pull-cloud-provider-azure-unit | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-unit/1595478653892825088) | true | `/test pull-cloud-provider-azure-unit`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @mukhoakash: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-check | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1595478653553086464) | true | `/test pull-cloud-provider-azure-check`
pull-cloud-provider-azure-unit | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-unit/1595478653892825088) | true | `/test pull-cloud-provider-azure-unit`
pull-cloud-provider-azure-e2e-capz | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-capz/1595478653720858624) | true | `/test pull-cloud-provider-azure-e2e-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz/1595478653850882048) | false | `/test pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
coveralls: 
[![Coverage Status](https://coveralls.io/builds/54535215/badge)](https://coveralls.io/builds/54535215)

Coverage increased (+0.03%) to 79.621% when pulling **a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 on mukhoakash:fix_vmssvm_struct** into **e13b0b01787d5b20c7cc8e7493e5cf3bceef002a on kubernetes-sigs:master**.

MartinForReal: /kind cleanup
k8s-ci-robot: @mukhoakash: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-check | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1595478653553086464) | true | `/test pull-cloud-provider-azure-check`
pull-cloud-provider-azure-e2e-capz | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-capz/1595478653720858624) | true | `/test pull-cloud-provider-azure-e2e-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz/1595478653850882048) | false | `/test pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz`
pull-cloud-provider-azure-unit | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-unit/1596025925995073536) | true | `/test pull-cloud-provider-azure-unit`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @mukhoakash: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-check | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1595478653553086464) | true | `/test pull-cloud-provider-azure-check`
pull-cloud-provider-azure-e2e-capz | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-capz/1595478653720858624) | true | `/test pull-cloud-provider-azure-e2e-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz/1595478653850882048) | false | `/test pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz`
pull-cloud-provider-azure-unit | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-unit/1596025925995073536) | true | `/test pull-cloud-provider-azure-unit`
pull-cloud-provider-azure-e2e-ccm-vmssflex-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmssflex-capz/1596025925806329856) | true | `/test pull-cloud-provider-azure-e2e-ccm-vmssflex-capz`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @mukhoakash: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-check | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1595478653553086464) | true | `/test pull-cloud-provider-azure-check`
pull-cloud-provider-azure-e2e-capz | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-capz/1595478653720858624) | true | `/test pull-cloud-provider-azure-e2e-capz`
pull-cloud-provider-azure-unit | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-unit/1596025925995073536) | true | `/test pull-cloud-provider-azure-unit`
pull-cloud-provider-azure-e2e-ccm-vmssflex-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmssflex-capz/1596025925806329856) | true | `/test pull-cloud-provider-azure-e2e-ccm-vmssflex-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz/1596025925953130496) | false | `/test pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @mukhoakash: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-check | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1595478653553086464) | true | `/test pull-cloud-provider-azure-check`
pull-cloud-provider-azure-e2e-capz | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-capz/1595478653720858624) | true | `/test pull-cloud-provider-azure-e2e-capz`
pull-cloud-provider-azure-unit | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-unit/1596025925995073536) | true | `/test pull-cloud-provider-azure-unit`
pull-cloud-provider-azure-e2e-ccm-vmssflex-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmssflex-capz/1596025925806329856) | true | `/test pull-cloud-provider-azure-e2e-ccm-vmssflex-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz/1596025925953130496) | false | `/test pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz`
pull-cloud-provider-azure-e2e-ccm-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-capz/1596025925902798848) | true | `/test pull-cloud-provider-azure-e2e-ccm-capz`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @mukhoakash: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-check | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1595478653553086464) | true | `/test pull-cloud-provider-azure-check`
pull-cloud-provider-azure-e2e-capz | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-capz/1595478653720858624) | true | `/test pull-cloud-provider-azure-e2e-capz`
pull-cloud-provider-azure-unit | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-unit/1596025925995073536) | true | `/test pull-cloud-provider-azure-unit`
pull-cloud-provider-azure-e2e-ccm-vmssflex-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmssflex-capz/1596025925806329856) | true | `/test pull-cloud-provider-azure-e2e-ccm-vmssflex-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz/1596025925953130496) | false | `/test pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz`
pull-cloud-provider-azure-e2e-ccm-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-capz/1596025925902798848) | true | `/test pull-cloud-provider-azure-e2e-ccm-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-capz/1596025925755998208) | true | `/test pull-cloud-provider-azure-e2e-ccm-vmss-capz`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @mukhoakash: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-check | 0cf1f91f457e32bdba4ea7852074622dc4f75575 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1595478653553086464) | true | `/test pull-cloud-provider-azure-check`
pull-cloud-provider-azure-unit | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-unit/1596025925995073536) | true | `/test pull-cloud-provider-azure-unit`
pull-cloud-provider-azure-e2e-ccm-vmssflex-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmssflex-capz/1596025925806329856) | true | `/test pull-cloud-provider-azure-e2e-ccm-vmssflex-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz/1596025925953130496) | false | `/test pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz`
pull-cloud-provider-azure-e2e-ccm-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-capz/1596025925902798848) | true | `/test pull-cloud-provider-azure-e2e-ccm-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-capz/1596025925755998208) | true | `/test pull-cloud-provider-azure-e2e-ccm-vmss-capz`
pull-cloud-provider-azure-e2e-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-capz/1596025925856661504) | true | `/test pull-cloud-provider-azure-e2e-capz`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @mukhoakash: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-unit | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-unit/1596025925995073536) | true | `/test pull-cloud-provider-azure-unit`
pull-cloud-provider-azure-e2e-ccm-vmssflex-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmssflex-capz/1596025925806329856) | true | `/test pull-cloud-provider-azure-e2e-ccm-vmssflex-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz/1596025925953130496) | false | `/test pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz`
pull-cloud-provider-azure-e2e-ccm-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-capz/1596025925902798848) | true | `/test pull-cloud-provider-azure-e2e-ccm-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-capz/1596025925755998208) | true | `/test pull-cloud-provider-azure-e2e-ccm-vmss-capz`
pull-cloud-provider-azure-e2e-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-capz/1596025925856661504) | true | `/test pull-cloud-provider-azure-e2e-capz`
pull-cloud-provider-azure-check | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1596025925701472256) | true | `/test pull-cloud-provider-azure-check`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @mukhoakash: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-e2e-ccm-vmssflex-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmssflex-capz/1596025925806329856) | true | `/test pull-cloud-provider-azure-e2e-ccm-vmssflex-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz/1596025925953130496) | false | `/test pull-cloud-provider-azure-e2e-ccm-vmss-ip-lb-capz`
pull-cloud-provider-azure-e2e-ccm-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-capz/1596025925902798848) | true | `/test pull-cloud-provider-azure-e2e-ccm-capz`
pull-cloud-provider-azure-e2e-ccm-vmss-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-ccm-vmss-capz/1596025925755998208) | true | `/test pull-cloud-provider-azure-e2e-ccm-vmss-capz`
pull-cloud-provider-azure-e2e-capz | a4a2bc05815c89f62387a7dadc9f89dc9b614fe9 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-e2e-capz/1596025925856661504) | true | `/test pull-cloud-provider-azure-e2e-capz`
pull-cloud-provider-azure-check | 652eae85b6b809fe143f0e6afc0ed1f2fd6e0806 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1596057115372294144) | true | `/test pull-cloud-provider-azure-check`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @mukhoakash: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-check | 652eae85b6b809fe143f0e6afc0ed1f2fd6e0806 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-check/1596057115372294144) | true | `/test pull-cloud-provider-azure-check`
pull-cloud-provider-azure-unit | 7fc337d1cf5cae8d060e0accbfe4fb907086c4bd | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-unit/1596399391021731840) | true | `/test pull-cloud-provider-azure-unit`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @mukhoakash: The following test **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-cloud-provider-azure-unit | e572d73edddbc81ec2a852da76f8d2668f9f9452 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cloud-provider-azure/2819/pull-cloud-provider-azure-unit/1596426847002824704) | true | `/test pull-cloud-provider-azure-unit`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=cloud-provider-azure&pr=2819). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Amukhoakash). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/cloud-provider-azure/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->

Patch:
diff --git a/go.mod b/go.mod
index 5c4c3d864..41fcfb123 100644
--- a/go.mod
+++ b/go.mod
@@ -19,7 +19,6 @@ require (
 	github.com/spf13/pflag v1.0.5
 	github.com/stretchr/testify v1.8.1
 	golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
-	golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
 	golang.org/x/sys v0.2.0
 	golang.org/x/text v0.4.0
 	k8s.io/api v0.25.4
@@ -101,6 +100,7 @@ require (
 	go.uber.org/zap v1.19.0 // indirect
 	golang.org/x/net v0.2.0 // indirect
 	golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
+	golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
 	golang.org/x/term v0.2.0 // indirect
 	golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
 	google.golang.org/appengine v1.6.7 // indirect
diff --git a/pkg/provider/azure_utils.go b/pkg/provider/azure_utils.go
index 910abb56f..fe353f708 100644
--- a/pkg/provider/azure_utils.go
+++ b/pkg/provider/azure_utils.go
@@ -298,36 +298,40 @@ func removeDuplicatedSecurityRules(rules []network.SecurityRule) []network.Secur
 	return rules
 }
 
+func getVMSSVMCacheKey(resourceGroup, vmssName string) string {
+	cacheKey := strings.ToLower(fmt.Sprintf("%s/%s", resourceGroup, vmssName))
+	return cacheKey
+}
+
 // isNodeInVMSSVMCache check whether nodeName is in vmssVMCache
-func isNodeInVMSSVMCache(nodeName string, vmssVMCache *sync.Map) bool {
+func isNodeInVMSSVMCache(nodeName string, vmssVMCache *azcache.TimedCache) bool {
 	if vmssVMCache == nil {
 		return false
 	}
+
 	var isInCache bool
-	vmssVMCache.Range(func(_, value interface{}) bool {
-		if value != nil && value.(*azcache.TimedCache).Store != nil {
-			for _, v := range value.(*azcache.TimedCache).Store.List() {
-				if v != nil {
-					data := v.(*azcache.AzureCacheEntry).Data
-					if data != nil {
-						data.(*sync.Map).Range(func(vmName, _ interface{}) bool {
-							if vmName != nil && vmName.(string) == nodeName {
-								isInCache = true
-								return false
-							}
-							return true
-						})
+
+	vmssVMCache.Lock.Lock()
+	defer vmssVMCache.Lock.Unlock()
+
+	for _, entry := range vmssVMCache.Store.List() {
+		if entry != nil {
+			data := entry.(*azcache.AzureCacheEntry).Data
+			if data != nil {
+				data.(*sync.Map).Range(func(vmName, _ interface{}) bool {
+					if vmName != nil && vmName.(string) == nodeName {
+						isInCache = true
+						return false
 					}
-				}
-				if isInCache {
-					return false
-				}
+					return true
+				})
 			}
 		}
+
 		if isInCache {
-			return false
+			break
 		}
-		return true
-	})
+	}
+
 	return isInCache
 }
diff --git a/pkg/provider/azure_vmss.go b/pkg/provider/azure_vmss.go
index cd56e252a..43ce1bf4f 100644
--- a/pkg/provider/azure_vmss.go
+++ b/pkg/provider/azure_vmss.go
@@ -35,7 +35,6 @@ import (
 	"k8s.io/klog/v2"
 	utilnet "k8s.io/utils/net"
 
-	"golang.org/x/sync/singleflight"
 	azcache "sigs.k8s.io/cloud-provider-azure/pkg/cache"
 	"sigs.k8s.io/cloud-provider-azure/pkg/consts"
 	"sigs.k8s.io/cloud-provider-azure/pkg/metrics"
@@ -80,8 +79,12 @@ type ScaleSet struct {
 	// the same cluster.
 	flexScaleSet VMSet
 
-	vmssCache   *azcache.TimedCache
-	vmssVMCache *sync.Map // [resourcegroup/vmssname]*azcache.TimedCache
+	vmssCache *azcache.TimedCache
+
+	// vmssVMCache is timed cache where the Store in the cache is a map of
+	// Key: [resourcegroup/vmssName]
+	// Value: sync.Map of [vmName]*VMSSVirtualMachinesEntry
+	vmssVMCache *azcache.TimedCache
 
 	// nonVmssUniformNodesCache is used to store node names from non uniform vm.
 	// Currently, the nodes can from avset or vmss flex or individual vm.
@@ -92,8 +95,6 @@ type ScaleSet struct {
 
 	// lockMap in cache refresh
 	lockMap *lockMap
-	// group represents a class of work and units of work can be executed with duplicate suppression
-	group singleflight.Group
 }
 
 // newScaleSet creates a new ScaleSet.
@@ -116,7 +117,6 @@ func newScaleSet(az *Cloud) (VMSet, error) {
 		Cloud:           az,
 		availabilitySet: as,
 		flexScaleSet:    fs,
-		vmssVMCache:     &sync.Map{},
 		lockMap:         newLockMap(),
 	}
 
@@ -132,6 +132,11 @@ func newScaleSet(az *Cloud) (VMSet, error) {
 		return nil, err
 	}
 
+	ss.vmssVMCache, err = ss.newVMSSVirtualMachinesCache()
+	if err != nil {
+		return nil, err
+	}
+
 	return ss, nil
 }
 
@@ -174,22 +179,23 @@ func (ss *ScaleSet) getVMSS(vmssName string, crt azcache.AzureCacheReadType) (*c
 // getVmssVMByNodeIdentity find virtualMachineScaleSetVM by nodeIdentity, using node's parent VMSS cache.
 // Returns cloudprovider.InstanceNotFound if the node does not belong to the scale set named in nodeIdentity.
 func (ss *ScaleSet) getVmssVMByNodeIdentity(node *nodeIdentity, crt azcache.AzureCacheReadType) (*virtualmachine.VirtualMachine, error) {
-	cacheKey, cache, err := ss.getVMSSVMCache(node.resourceGroup, node.vmssName)
+	// FIXME(ccc): check only if vmss is uniform.
+	_, err := getScaleSetVMInstanceID(node.nodeName)
 	if err != nil {
 		return nil, err
 	}
 
-	getter := func(nodeName string, crt azcache.AzureCacheReadType) (*virtualmachine.VirtualMachine, bool, error) {
+	getter := func(crt azcache.AzureCacheReadType) (*virtualmachine.VirtualMachine, bool, error) {
 		var found bool
-		cached, err := cache.Get(cacheKey, crt)
+		virtualMachines, err := ss.getVMSSVMsFromCache(node.resourceGroup, node.vmssName, crt)
 		if err != nil {
 			return nil, found, err
 		}
-		virtualMachines := cached.(*sync.Map)
-		if entry, ok := virtualMachines.Load(nodeName); ok {
+
+		if entry, ok := virtualMachines.Load(node.nodeName); ok {
 			result := entry.(*VMSSVirtualMachinesEntry)
 			if result.VirtualMachine == nil {
-				klog.Warningf("VM is nil on Node %q, VM is in deleting state", nodeName)
+				klog.Warningf("VM is nil on Node %q, VM is in deleting state", node.nodeName)
 				return nil, true, nil
 			}
 			found = true
@@ -199,29 +205,24 @@ func (ss *ScaleSet) getVmssVMByNodeIdentity(node *nodeIdentity, crt azcache.Azur
 		return nil, found, nil
 	}
 
-	// FIXME(ccc): check only if vmss is uniform.
-	_, err = getScaleSetVMInstanceID(node.nodeName)
-	if err != nil {
-		return nil, err
-	}
-
-	vm, found, err := getter(node.nodeName, crt)
+	vm, found, err := getter(crt)
 	if err != nil {
 		return nil, err
 	}
 
 	if !found {
+		cacheKey := getVMSSVMCacheKey(node.resourceGroup, node.vmssName)
 		// lock and try find nodeName from cache again, refresh cache if still not found
 		ss.lockMap.LockEntry(cacheKey)
 		defer ss.lockMap.UnlockEntry(cacheKey)
-		vm, found, err = getter(node.nodeName, crt)
+		vm, found, err = getter(crt)
 		if err == nil && found && vm != nil {
 			klog.V(2).Infof("found VMSS VM with nodeName %s after retry", node.nodeName)
 			return vm, nil
 		}
 
 		klog.V(2).Infof("Couldn't find VMSS VM with nodeName %s, refreshing the cache(vmss: %s, rg: %s)", node.nodeName, node.vmssName, node.resourceGroup)
-		vm, found, err = getter(node.nodeName, azcache.CacheReadTypeForceRefresh)
+		vm, found, err = getter(azcache.CacheReadTypeForceRefresh)
 		if err != nil {
 			return nil, err
 		}
@@ -321,18 +322,12 @@ func (ss *ScaleSet) GetProvisioningStateByNodeName(name string) (provisioningSta
 // getCachedVirtualMachineByInstanceID gets scaleSetVMInfo from cache.
 // The node must belong to one of scale sets.
 func (ss *ScaleSet) getVmssVMByInstanceID(resourceGroup, scaleSetName, instanceID string, crt azcache.AzureCacheReadType) (*compute.VirtualMachineScaleSetVM, error) {
-	cacheKey, cache, err := ss.getVMSSVMCache(resourceGroup, scaleSetName)
-	if err != nil {
-		return nil, err
-	}
-
 	getter := func(crt azcache.AzureCacheReadType) (vm *compute.VirtualMachineScaleSetVM, found bool, err error) {
-		cached, err := cache.Get(cacheKey, crt)
+		virtualMachines, err := ss.getVMSSVMsFromCache(resourceGroup, scaleSetName, crt)
 		if err != nil {
 			return nil, false, err
 		}
 
-		virtualMachines := cached.(*sync.Map)
 		virtualMachines.Range(func(key, value interface{}) bool {
 			vmEntry := value.(*VMSSVirtualMachinesEntry)
 			if strings.EqualFold(vmEntry.ResourceGroup, resourceGroup) &&
diff --git a/pkg/provider/azure_vmss_cache.go b/pkg/provider/azure_vmss_cache.go
index 62ec948e9..44ec739fc 100644
--- a/pkg/provider/azure_vmss_cache.go
+++ b/pkg/provider/azure_vmss_cache.go
@@ -104,19 +104,13 @@ func (ss *ScaleSet) newVMSSCache() (*azcache.TimedCache, error) {
 
 		if resourceGroupNotFound {
 			// gc vmss vm cache when there is resource group not found
-			removed := map[string]bool{}
-			ss.vmssVMCache.Range(func(key, value interface{}) bool {
-				cacheKey := key.(string)
-				vlistIdx := cacheKey[strings.LastIndex(cacheKey, "/")+1:]
-				if _, ok := localCache.Load(vlistIdx); !ok {
-					klog.V(2).Infof("remove vmss %s from cache due to rg not found", cacheKey)
-					removed[cacheKey] = true
+			vmssVMKeys := ss.vmssVMCache.Store.ListKeys()
+			for _, cacheKey := range vmssVMKeys {
+				vmssName := cacheKey[strings.LastIndex(cacheKey, "/")+1:]
+				if _, ok := localCache.Load(vmssName); !ok {
+					klog.V(2).Infof("remove vmss %s from vmssVMCache due to rg not found", cacheKey)
+					_ = ss.vmssVMCache.Delete(cacheKey)
 				}
-				return true
-			})
-
-			for key := range removed {
-				ss.vmssVMCache.Delete(key)
 			}
 		}
 		return localCache, nil
@@ -142,25 +136,20 @@ func extractVmssVMName(name string) (string, string, error) {
 	return ssName, instanceID, nil
 }
 
-// getVMSSVMCache returns an *azcache.TimedCache and cache key for a VMSS (creating that cache if new).
-func (ss *ScaleSet) getVMSSVMCache(resourceGroup, vmssName string) (string, *azcache.TimedCache, error) {
-	cacheKey := strings.ToLower(fmt.Sprintf("%s/%s", resourceGroup, vmssName))
-	if entry, ok := ss.vmssVMCache.Load(cacheKey); ok {
-		return cacheKey, entry.(*azcache.TimedCache), nil
+func (ss *ScaleSet) getVMSSVMsFromCache(resourceGroup, vmssName string, crt azcache.AzureCacheReadType) (*sync.Map, error) {
+	cacheKey := getVMSSVMCacheKey(resourceGroup, vmssName)
+	entry, err := ss.vmssVMCache.Get(cacheKey, crt)
+	if err != nil {
+		return nil, err
 	}
 
-	v, err, _ := ss.group.Do(cacheKey, func() (interface{}, error) {
-		cache, err := ss.newVMSSVirtualMachinesCache(resourceGroup, vmssName, cacheKey)
-		if err != nil {
-			return nil, err
-		}
-		ss.vmssVMCache.Store(cacheKey, cache)
-		return cache, nil
-	})
-	if err != nil {
-		return "", nil, err
+	if entry == nil {
+		err = fmt.Errorf("vmssVMCache entry for resourceGroup (%s), vmssName (%s) returned nil data", resourceGroup, vmssName)
+		return nil, err
 	}
-	return cacheKey, v.(*azcache.TimedCache), nil
+
+	virtualMachines := entry.(*sync.Map)
+	return virtualMachines, nil
 }
 
 // gcVMSSVMCache delete stale VMSS VMs caches from deleted VMSSes.
@@ -169,33 +158,37 @@ func (ss *ScaleSet) gcVMSSVMCache() error {
 }
 
 // newVMSSVirtualMachinesCache instantiates a new VMs cache for VMs belonging to the provided VMSS.
-func (ss *ScaleSet) newVMSSVirtualMachinesCache(resourceGroupName, vmssName, cacheKey string) (*azcache.TimedCache, error) {
+func (ss *ScaleSet) newVMSSVirtualMachinesCache() (*azcache.TimedCache, error) {
 	vmssVirtualMachinesCacheTTL := time.Duration(ss.Config.VmssVirtualMachinesCacheTTLInSeconds) * time.Second
 
-	getter := func(key string) (interface{}, error) {
+	getter := func(cacheKey string) (interface{}, error) {
 		localCache := &sync.Map{} // [nodeName]*VMSSVirtualMachinesEntry
 
-		oldCache := make(map[string]VMSSVirtualMachinesEntry)
+		oldCache := make(map[string]*VMSSVirtualMachinesEntry)
 
-		if vmssCache, ok := ss.vmssVMCache.Load(cacheKey); ok {
-			// get old cache before refreshing the cache
-			cache := vmssCache.(*azcache.TimedCache)
-			entry, exists, err := cache.Store.GetByKey(cacheKey)
-			if err != nil {
-				return nil, err
-			}
-			if exists {
-				cached := entry.(*azcache.AzureCacheEntry).Data
-				if cached != nil {
-					virtualMachines := cached.(*sync.Map)
-					virtualMachines.Range(func(key, value interface{}) bool {
-						oldCache[key.(string)] = *value.(*VMSSVirtualMachinesEntry)
-						return true
-					})
-				}
+		entry, exists, err := ss.vmssVMCache.Store.GetByKey(cacheKey)
+		if err != nil {
+			return nil, err
+		}
+		if exists {
+			cached := entry.(*azcache.AzureCacheEntry).Data
+			if cached != nil {
+				virtualMachines := cached.(*sync.Map)
+				virtualMachines.Range(func(key, value interface{}) bool {
+					oldCache[key.(string)] = value.(*VMSSVirtualMachinesEntry)
+					return true
+				})
 			}
 		}
 
+		result := strings.Split(cacheKey, "/")
+		if len(result) < 2 {
+			err = fmt.Errorf("Invalid cacheKey (%s)", cacheKey)
+			return nil, err
+		}
+
+		resourceGroupName, vmssName := result[0], result[1]
+
 		vms, err := ss.listScaleSetVMs(vmssName, resourceGroupName)
 		if err != nil {
 			return nil, err
@@ -287,15 +280,9 @@ func (ss *ScaleSet) DeleteCacheForNode(nodeName string) error {
 		return err
 	}
 
-	cacheKey, timedcache, err := ss.getVMSSVMCache(node.resourceGroup, node.vmssName)
+	err = ss.vmssVMCache.Delete(getVMSSVMCacheKey(node.resourceGroup, node.vmssName))
 	if err != nil {
-		klog.Errorf("DeleteCacheForNode(%s) failed with error: %v", nodeName, err)
-		return err
-	}
-
-	err = timedcache.Delete(cacheKey)
-	if err != nil {
-		klog.Errorf("DeleteCacheForNode(%s) failed with error: %v", nodeName, err)
+		klog.Errorf("DeleteCacheForNode(%s) failed to remove from vmssVMCache with error: %v", nodeName, err)
 		return err
 	}
 
@@ -308,9 +295,9 @@ func (ss *ScaleSet) DeleteCacheForNode(nodeName string) error {
 }
 
 func (ss *ScaleSet) updateCache(nodeName, resourceGroupName, vmssName, instanceID string, updatedVM *compute.VirtualMachineScaleSetVM) error {
-	cacheKey, timedCache, err := ss.getVMSSVMCache(resourceGroupName, vmssName)
+	virtualMachines, err := ss.getVMSSVMsFromCache(resourceGroupName, vmssName, azcache.CacheReadTypeUnsafe)
 	if err != nil {
-		klog.Errorf("updateCache(%s, %s, %s) failed with error: %v", vmssName, resourceGroupName, nodeName, err)
+		err = fmt.Errorf("updateCache(%s, %s, %s) failed getting vmCache with error: %v", vmssName, resourceGroupName, nodeName, err)
 		return err
 	}
 
@@ -326,14 +313,6 @@ func (ss *ScaleSet) updateCache(nodeName, resourceGroupName, vmssName, instanceI
 
 	localCache.Store(nodeName, vmssVMCacheEntry)
 
-	vmCache, err := timedCache.Get(cacheKey, azcache.CacheReadTypeUnsafe)
-	if err != nil {
-		return err
-	}
-	if vmCache == nil {
-		return fmt.Errorf("nil vmCache")
-	}
-	virtualMachines := vmCache.(*sync.Map)
 	virtualMachines.Range(func(key, value interface{}) bool {
 		if key.(string) != nodeName {
 			localCache.Store(key.(string), value.(*VMSSVirtualMachinesEntry))
@@ -341,7 +320,8 @@ func (ss *ScaleSet) updateCache(nodeName, resourceGroupName, vmssName, instanceI
 		return true
 	})
 
-	timedCache.Update(cacheKey, localCache)
+	cacheKey := getVMSSVMCacheKey(resourceGroupName, vmssName)
+	ss.vmssVMCache.Update(cacheKey, localCache)
 	klog.V(4).Infof("updateCache(%s, %s, %s) for cacheKey(%s) updated successfully", vmssName, resourceGroupName, nodeName, cacheKey)
 	return nil
 }


Test patch:
diff --git a/pkg/provider/azure_controller_vmss_test.go b/pkg/provider/azure_controller_vmss_test.go
index d14779067..48b038c5c 100644
--- a/pkg/provider/azure_controller_vmss_test.go
+++ b/pkg/provider/azure_controller_vmss_test.go
@@ -19,6 +19,7 @@ package provider
 import (
 	"fmt"
 	"net/http"
+	"strings"
 	"testing"
 
 	"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-03-01/compute"
@@ -218,7 +219,7 @@ func TestDetachDiskWithVMSS(t *testing.T) {
 	}
 
 	for i, test := range testCases {
-		scaleSetName := string(test.vmssName)
+		scaleSetName := strings.ToLower(string(test.vmssName))
 		ss, err := NewTestScaleSet(ctrl)
 		assert.NoError(t, err, test.desc)
 		testCloud := ss.cloud
@@ -264,7 +265,7 @@ func TestDetachDiskWithVMSS(t *testing.T) {
 		}
 		mockVMSSVMClient := testCloud.VirtualMachineScaleSetVMsClient.(*mockvmssvmclient.MockInterface)
 		mockVMSSVMClient.EXPECT().List(gomock.Any(), testCloud.ResourceGroup, scaleSetName, gomock.Any()).Return(expectedVMSSVMs, nil).AnyTimes()
-		if scaleSetName == string(fakeStatusNotFoundVMSSName) {
+		if scaleSetName == strings.ToLower(string(fakeStatusNotFoundVMSSName)) {
 			mockVMSSVMClient.EXPECT().Update(gomock.Any(), testCloud.ResourceGroup, scaleSetName, gomock.Any(), gomock.Any(), gomock.Any()).Return(updatedVMSSVM, &retry.Error{HTTPStatusCode: http.StatusNotFound, RawError: cloudprovider.InstanceNotFound}).AnyTimes()
 		} else {
 			mockVMSSVMClient.EXPECT().Update(gomock.Any(), testCloud.ResourceGroup, scaleSetName, gomock.Any(), gomock.Any(), gomock.Any()).Return(updatedVMSSVM, nil).AnyTimes()
@@ -348,7 +349,7 @@ func TestUpdateVMWithVMSS(t *testing.T) {
 	}
 
 	for i, test := range testCases {
-		scaleSetName := string(test.vmssName)
+		scaleSetName := strings.ToLower(string(test.vmssName))
 		ss, err := NewTestScaleSet(ctrl)
 		assert.NoError(t, err, test.desc)
 		testCloud := ss.cloud
@@ -385,7 +386,7 @@ func TestUpdateVMWithVMSS(t *testing.T) {
 		}
 		mockVMSSVMClient := testCloud.VirtualMachineScaleSetVMsClient.(*mockvmssvmclient.MockInterface)
 		mockVMSSVMClient.EXPECT().List(gomock.Any(), testCloud.ResourceGroup, scaleSetName, gomock.Any()).Return(expectedVMSSVMs, nil).AnyTimes()
-		if scaleSetName == string(fakeStatusNotFoundVMSSName) {
+		if scaleSetName == strings.ToLower(string(fakeStatusNotFoundVMSSName)) {
 			mockVMSSVMClient.EXPECT().Update(gomock.Any(), testCloud.ResourceGroup, scaleSetName, gomock.Any(), gomock.Any(), gomock.Any()).Return(updatedVMSSVM, &retry.Error{HTTPStatusCode: http.StatusNotFound, RawError: cloudprovider.InstanceNotFound}).AnyTimes()
 		} else {
 			mockVMSSVMClient.EXPECT().Update(gomock.Any(), testCloud.ResourceGroup, scaleSetName, gomock.Any(), gomock.Any(), gomock.Any()).Return(updatedVMSSVM, nil).AnyTimes()
diff --git a/pkg/provider/azure_utils_test.go b/pkg/provider/azure_utils_test.go
index ff1a2c530..7308269cf 100644
--- a/pkg/provider/azure_utils_test.go
+++ b/pkg/provider/azure_utils_test.go
@@ -317,29 +317,62 @@ func TestRemoveDuplicatedSecurityRules(t *testing.T) {
 	}
 }
 
+func TestGetVMSSVMCacheKey(t *testing.T) {
+	tests := []struct {
+		description       string
+		resourceGroupName string
+		vmssName          string
+		cacheKey          string
+	}{
+		{
+			description:       "Resource group and Vmss Name are in lower case",
+			resourceGroupName: "resgrp",
+			vmssName:          "vmss",
+			cacheKey:          "resgrp/vmss",
+		},
+		{
+			description:       "Resource group has upper case and Vmss Name is in lower case",
+			resourceGroupName: "Resgrp",
+			vmssName:          "vmss",
+			cacheKey:          "resgrp/vmss",
+		},
+		{
+			description:       "Resource group is in lower case and Vmss Name has upper case",
+			resourceGroupName: "resgrp",
+			vmssName:          "Vmss",
+			cacheKey:          "resgrp/vmss",
+		},
+		{
+			description:       "Resource group and Vmss Name are both in upper case",
+			resourceGroupName: "Resgrp",
+			vmssName:          "Vmss",
+			cacheKey:          "resgrp/vmss",
+		},
+	}
+
+	for _, test := range tests {
+		result := getVMSSVMCacheKey(test.resourceGroupName, test.vmssName)
+		assert.Equal(t, result, test.cacheKey, test.description)
+	}
+}
+
 func TestIsNodeInVMSSVMCache(t *testing.T) {
-	emptyTimedCacheMap := &sync.Map{}
-	emptyTimedCacheMap.Store("key", &azcache.TimedCache{})
 
 	getter := func(key string) (interface{}, error) {
 		return nil, nil
 	}
 	emptyCacheEntryTimedCache, _ := azcache.NewTimedcache(fakeCacheTTL, getter)
 	emptyCacheEntryTimedCache.Set("key", nil)
-	emptyCacheEntryTimedCacheMap := &sync.Map{}
-	emptyCacheEntryTimedCacheMap.Store("key", emptyCacheEntryTimedCache)
 
 	cacheEntryTimedCache, _ := azcache.NewTimedcache(fakeCacheTTL, getter)
 	syncMap := &sync.Map{}
 	syncMap.Store("node", nil)
 	cacheEntryTimedCache.Set("key", syncMap)
-	cacheEntryTimedCacheMap := &sync.Map{}
-	cacheEntryTimedCacheMap.Store("key", cacheEntryTimedCache)
 
 	tests := []struct {
 		description    string
 		nodeName       string
-		vmssVMCache    *sync.Map
+		vmssVMCache    *azcache.TimedCache
 		expectedResult bool
 	}{
 		{
@@ -347,31 +380,21 @@ func TestIsNodeInVMSSVMCache(t *testing.T) {
 			vmssVMCache:    nil,
 			expectedResult: false,
 		},
-		{
-			description:    "empty cache",
-			vmssVMCache:    &sync.Map{},
-			expectedResult: false,
-		},
-		{
-			description:    "empty timed cache",
-			vmssVMCache:    emptyTimedCacheMap,
-			expectedResult: false,
-		},
 		{
 			description:    "empty CacheEntry timed cache",
-			vmssVMCache:    emptyCacheEntryTimedCacheMap,
+			vmssVMCache:    emptyCacheEntryTimedCache,
 			expectedResult: false,
 		},
 		{
 			description:    "node name in the cache",
 			nodeName:       "node",
-			vmssVMCache:    cacheEntryTimedCacheMap,
+			vmssVMCache:    cacheEntryTimedCache,
 			expectedResult: true,
 		},
 		{
 			description:    "node name not in the cache",
 			nodeName:       "node2",
-			vmssVMCache:    cacheEntryTimedCacheMap,
+			vmssVMCache:    cacheEntryTimedCache,
 			expectedResult: false,
 		},
 	}
diff --git a/pkg/provider/azure_vmss_cache_test.go b/pkg/provider/azure_vmss_cache_test.go
index 3895938b7..2404415b1 100644
--- a/pkg/provider/azure_vmss_cache_test.go
+++ b/pkg/provider/azure_vmss_cache_test.go
@@ -19,7 +19,6 @@ package provider
 import (
 	"fmt"
 	"net/http"
-	"strings"
 	"testing"
 
 	"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-03-01/compute"
@@ -178,7 +177,7 @@ func TestVMSSVMCacheClearedWhenRGDeleted(t *testing.T) {
 	mockVMSSClient.EXPECT().List(gomock.Any(), gomock.Any()).Return([]compute.VirtualMachineScaleSet{expectedScaleSet}, nil).Times(1)
 
 	expectedVMs, _, _ := buildTestVirtualMachineEnv(ss.cloud, testVMSSName, "", 0, vmList, "", false)
-	mockVMSSVMClient.EXPECT().List(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(expectedVMs, nil).AnyTimes()
+	mockVMSSVMClient.EXPECT().List(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(expectedVMs, nil).Times(1)
 
 	// validate getting VMSS VM via cache.
 	vm := expectedVMs[0]
@@ -190,19 +189,20 @@ func TestVMSSVMCacheClearedWhenRGDeleted(t *testing.T) {
 	assert.Equal(t, &vm, realVM.AsVirtualMachineScaleSetVM())
 
 	// verify cache has test vmss.
-	cacheKey := strings.ToLower(fmt.Sprintf("%s/%s", "rg", testVMSSName))
-	_, ok := ss.vmssVMCache.Load(cacheKey)
-	assert.Equal(t, true, ok)
+	cacheKey := getVMSSVMCacheKey("rg", testVMSSName)
+	_, err = ss.vmssVMCache.Get(cacheKey, azcache.CacheReadTypeDefault)
+	assert.Nil(t, err)
 
 	// refresh the cache with error.
 	mockVMSSClient.EXPECT().List(gomock.Any(), gomock.Any()).Return([]compute.VirtualMachineScaleSet{}, &retry.Error{HTTPStatusCode: http.StatusNotFound}).Times(2)
+	mockVMSSVMClient.EXPECT().List(gomock.Any(), "rg", testVMSSName, gomock.Any()).Return([]compute.VirtualMachineScaleSetVM{}, &retry.Error{HTTPStatusCode: http.StatusNotFound}).Times(1)
 	realVM, err = ss.getVmssVM(vmName, azcache.CacheReadTypeForceRefresh)
 	assert.Nil(t, realVM)
 	assert.Equal(t, cloudprovider.InstanceNotFound, err)
 
 	// verify cache is cleared.
-	_, ok = ss.vmssVMCache.Load(cacheKey)
-	assert.Equal(t, false, ok)
+	_, err = ss.vmssVMCache.Get(cacheKey, azcache.CacheReadTypeDefault)
+	assert.NotNil(t, err)
 }
 
 func TestGetVMManagementTypeByNodeName(t *testing.T) {
diff --git a/pkg/provider/azure_vmss_test.go b/pkg/provider/azure_vmss_test.go
index cd17709cd..73917767a 100644
--- a/pkg/provider/azure_vmss_test.go
+++ b/pkg/provider/azure_vmss_test.go
@@ -19,7 +19,6 @@ package provider
 import (
 	"fmt"
 	"strings"
-	"sync"
 	"testing"
 
 	"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-03-01/compute"
@@ -955,12 +954,9 @@ func TestGetVmssVMByNodeIdentity(t *testing.T) {
 			mockVMSSVMClient := ss.cloud.VirtualMachineScaleSetVMsClient.(*mockvmssvmclient.MockInterface)
 			mockVMSSVMClient.EXPECT().List(gomock.Any(), ss.ResourceGroup, testVMSSName, gomock.Any()).Return(expectedVMSSVMs, nil).AnyTimes()
 
-			// Make some nil VMSS VM in cache.
-			cacheKey, cache, err := ss.getVMSSVMCache(ss.ResourceGroup, testVMSSName)
+			cacheKey := getVMSSVMCacheKey(ss.ResourceGroup, testVMSSName)
+			virtualMachines, err := ss.getVMSSVMsFromCache(ss.ResourceGroup, testVMSSName, azcache.CacheReadTypeDefault)
 			assert.Nil(t, err)
-			cached, err := cache.Get(cacheKey, azcache.CacheReadTypeDefault)
-			assert.Nil(t, err)
-			virtualMachines := cached.(*sync.Map)
 			for _, vm := range test.goneVMList {
 				entry := VMSSVirtualMachinesEntry{
 					ResourceGroup: ss.ResourceGroup,
@@ -968,7 +964,7 @@ func TestGetVmssVMByNodeIdentity(t *testing.T) {
 				}
 				virtualMachines.Store(vm, &entry)
 			}
-			cache.Set(cacheKey, cached)
+			ss.vmssVMCache.Update(cacheKey, virtualMachines)
 
 			for i := 0; i < len(test.vmList); i++ {
 				node := nodeIdentity{ss.ResourceGroup, testVMSSName, test.vmList[i]}
@@ -982,11 +978,9 @@ func TestGetVmssVMByNodeIdentity(t *testing.T) {
 				assert.Equal(t, test.goneVMExpectedErr, err)
 			}
 
-			cacheKey, cache, err = ss.getVMSSVMCache(ss.ResourceGroup, testVMSSName)
-			assert.Nil(t, err)
-			cached, err = cache.Get(cacheKey, azcache.CacheReadTypeDefault)
+			virtualMachines, err = ss.getVMSSVMsFromCache(ss.ResourceGroup, testVMSSName, azcache.CacheReadTypeDefault)
 			assert.Nil(t, err)
-			virtualMachines = cached.(*sync.Map)
+
 			for _, vm := range test.goneVMList {
 				_, ok := virtualMachines.Load(vm)
 				assert.True(t, ok)