openyurtio / openyurt

OpenYurt - Extending your native Kubernetes to edge(project under CNCF)
https://openyurt.io
Apache License 2.0
1.69k stars 398 forks source link

fix cache manager panic in yurthub #1950

Closed rambohe-ch closed 6 months ago

rambohe-ch commented 6 months ago

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line: /kind bug /kind documentation /kind enhancement /kind good-first-issue /kind feature /kind question /kind design /sig ai /sig iot /sig network /sig storage

/kind bug

What this PR does / why we need it:

background:

yurt-hub-cfg configmap is used in multiple places, like:

In the cache manager, configmap is read, but in the approver, configmap is modified, so a panic maybe triggered.

solution:

deepcopy configmap before modify to avoid panic.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

other Note

sonarcloud[bot] commented 6 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.1% Duplication on New Code

See analysis details on SonarCloud

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (3e5d8fc) 52.04% compared to head (3de0034) 52.34%. Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1950 +/- ## ========================================== + Coverage 52.04% 52.34% +0.30% ========================================== Files 174 173 -1 Lines 21213 21012 -201 ========================================== - Hits 11040 10999 -41 + Misses 9199 9062 -137 + Partials 974 951 -23 ``` | [Flag](https://app.codecov.io/gh/openyurtio/openyurt/pull/1950/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openyurtio) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/openyurtio/openyurt/pull/1950/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openyurtio) | `52.34% <100.00%> (+0.30%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openyurtio#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

rambohe-ch commented 6 months ago

/backport release-v1.4

github-actions[bot] commented 6 months ago

Successfully created backport PR for release-v1.4: