Skip to content
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

refactor(main): unmount override container (#4161) #4208

Merged

Conversation

cuisongliu
Copy link
Collaborator

@cuisongliu cuisongliu commented Oct 30, 2023

(cherry picked from commit 4fed20a)

🤖 Generated by Copilot at e489328

Summary

🔧🗃️🚀

This pull request enhances the handling of MountImage instances in the cluster.Status.Mounts slice by sorting, deduplicating, and appending them. It also simplifies the cluster.FindImage method and removes the cluster.SetMountImage method. These changes aim to avoid conflicts or errors when applying the cluster configuration.

Sing, O Muse, of the skillful coder who modified the cluster code
To find the image and its index, and return them both with ease
No longer needing to set the mount, he removed the method old
And made the slice of mounts more ordered, with the help of sorting god

Walkthrough

  • Ensure that cluster.Status.Mounts slice is consistent and up-to-date with the latest MountImage instances (link, link)
  • Import sort package in pkg/apply/processor/install.go (link)
  • Create a map of ImageName to the index of the last occurrence in the slice and sort the indexes (link)
  • Create a new slice of MountImage instances based on the sorted indexes and assign it to the cluster status (link)
  • Check if a new MountImage instance already exists in the slice before appending it and remove the old one if found (link)
  • Modify cluster.FindImage method to return both the index and the pointer to the MountImage instance in pkg/types/v1beta1/cluster_args.go (link)
    • Remove cluster.SetMountImage method as it is no longer needed (link)

Signed-off-by: cuisongliu <cuisongliu@qq.com>

(cherry picked from commit 4fed20a)
Signed-off-by: cuisongliu <cuisongliu@qq.com>
@sweep-ai
Copy link

sweep-ai bot commented Oct 30, 2023

Apply Sweep Rules to your PR?

  • Apply: Leftover TODOs in the code should be handled.
  • Apply: All new business logic should have corresponding unit tests in the tests/ directory.
  • Apply: Any clearly inefficient or repeated code should be optimized or refactored.

@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!.

@cuisongliu cuisongliu merged commit f39b233 into labring:release-v4.3 Oct 30, 2023
71 checks passed
@cuisongliu cuisongliu deleted the release-v4.3-cherry-pick-unmount branch October 30, 2023 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants