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

Merged
merged 1 commit into from Oct 30, 2023

Conversation

cuisongliu
Copy link
Collaborator

@cuisongliu cuisongliu commented Oct 24, 2023

🤖 Generated by Copilot at 0fd86df

Summary

🗑️⚡📷

This pull request adds a feature to processor to force override images in the cluster, and removes the redundant SetMountImage function from v1beta1.

Sing, O Muse, of the mighty pull request
That changed the code of the v1beta1 package
And how the SetMountImage function was laid to rest
By the skillful hands of the processor sage

Walkthrough

  • Delete old image and its containers, and update cluster status mounts, before installing a new image (link, link)
  • Remove unused function SetMountImage from pkg/types/v1beta1/utils.go (link)

@sealos-ci-robot
Copy link
Member

sealos-ci-robot commented Oct 24, 2023

🤖 Generated by lychee action

Summary

Status Count
🔍 Total 956
✅ Successful 375
⏳ Timeouts 0
🔀 Redirected 0
👻 Excluded 580
❓ Unknown 0
🚫 Errors 0

Full action output

Full Github Actions output

@sweep-ai
Copy link

sweep-ai bot commented Oct 24, 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.

@cuisongliu cuisongliu added this to the v4.4 milestone Oct 24, 2023
@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!.

pkg/apply/processor/install.go Outdated Show resolved Hide resolved
pkg/types/v1beta1/utils.go Outdated Show resolved Hide resolved
pkg/apply/processor/install.go Outdated Show resolved Hide resolved
pkg/apply/processor/install.go Outdated Show resolved Hide resolved
@cuisongliu cuisongliu force-pushed the override_unmount_container branch 2 times, most recently from 1f58d0d to 30c5ebb Compare October 26, 2023 11:23
Comment on lines 184 to 194
if index >= 0 {
cluster.Status.Mounts[index] = *mount
continue
}
cluster.Status.Mounts = append(cluster.Status.Mounts, *mount)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if index >= 0 {
        cluster.Status.Mounts = append(cluster.Status.Mounts[:index], cluster.Status.Mounts[index+1:]...)
}
cluster.Status.Mounts = append(cluster.Status.Mounts, *mount)

Comment on lines 143 to 156
syncMounts := make([]v2.MountImage, 0)
imageIndices := make(map[string]int)
for _, mot := range cluster.Status.Mounts {
if idx, exists := imageIndices[mot.ImageName]; exists {
// 如果ImageName已经存在,替换旧的mot
syncMounts[idx] = mot
} else {
// 如果ImageName不存在,添加新的mot并更新索引
imageIndices[mot.ImageName] = len(syncMounts)
syncMounts = append(syncMounts, mot)
}
}
cluster.Status.Mounts = syncMounts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        // de-duplicate, append the latest record to the tail.
	mounts := make([]v2.MountImage, 0)
	indexes := make(map[string]int)
	for _, m := range cluster.Status.Mounts {
		if idx, exists := indexes[m.ImageName]; exists {
			mounts = append(mounts[:idx], mounts[idx+1:]...)
		}
		mounts = append(mounts, *m.DeepCopy())
		indexes[m.ImageName] = len(mounts) - 1
	}
	cluster.Status.Mounts = mounts

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also move this code block to L189

@cuisongliu cuisongliu force-pushed the override_unmount_container branch 3 times, most recently from ef76318 to 6877b05 Compare October 29, 2023 02:05
@sealos-ci-robot
Copy link
Member

🤖 Generated by deploy action

👀 Visit Preview

@cuisongliu cuisongliu force-pushed the override_unmount_container branch 3 times, most recently from 57d21f5 to 41db6ef Compare October 30, 2023 06:51
Signed-off-by: cuisongliu <cuisongliu@qq.com>
@cuisongliu cuisongliu merged commit 4fed20a into labring:main Oct 30, 2023
84 checks passed
@cuisongliu cuisongliu deleted the override_unmount_container branch October 30, 2023 08:56
@sealos-ci-robot
Copy link
Member

/cherry-pick release-v4.4

@sealos-ci-robot
Copy link
Member

🤖 says: cherry pick action finished successfully 🎉!
See: https://github.com/labring/sealos/actions/runs/6690508374

sealos-ci-robot pushed a commit that referenced this pull request Oct 30, 2023
Signed-off-by: cuisongliu <cuisongliu@qq.com>
cuisongliu added a commit that referenced this pull request Oct 30, 2023
Signed-off-by: cuisongliu <cuisongliu@qq.com>
Co-authored-by: cuisongliu <cuisongliu@qq.com>
cuisongliu added a commit to cuisongliu/sealos that referenced this pull request Oct 30, 2023
Signed-off-by: cuisongliu <cuisongliu@qq.com>

(cherry picked from commit 4fed20a)
Signed-off-by: cuisongliu <cuisongliu@qq.com>
cuisongliu added a commit that referenced this pull request Oct 30, 2023
(cherry picked from commit 4fed20a)

Signed-off-by: cuisongliu <cuisongliu@qq.com>
lingdie added a commit to lingdie/sealos that referenced this pull request Nov 3, 2023
* add license app to cloud. (labring#4196)

Signed-off-by: yy <lingdie.yy@outlook.com>

* feature(main): skip sealos.run rule (labring#4198)

* Update README (labring#4197)

Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>

* add cronjob app to cloud. (labring#4201)

Signed-off-by: yy <lingdie.yy@outlook.com>

* fix run init job. (labring#4202)

Signed-off-by: yy <lingdie.yy@outlook.com>

* feat service license (labring#4195)

* feat: license service

Signed-off-by: jingyang <3161362058@qq.com>

* done

* tempalte

Signed-off-by: jingyang <3161362058@qq.com>

* done

Signed-off-by: jingyang <3161362058@qq.com>

* done

Signed-off-by: jingyang <3161362058@qq.com>

* docker build

Signed-off-by: jingyang <3161362058@qq.com>

* done

Signed-off-by: jingyang <3161362058@qq.com>

* license yaml

Signed-off-by: jingyang <3161362058@qq.com>

* image

* fix type bg

* env

* add oss

Signed-off-by: jingyang <3161362058@qq.com>

* done

Signed-off-by: jingyang <3161362058@qq.com>

cluster done

Signed-off-by: jingyang <3161362058@qq.com>

done

Signed-off-by: jingyang <3161362058@qq.com>

cluster done

Signed-off-by: jingyang <3161362058@qq.com>

done cluster

Signed-off-by: jingyang <3161362058@qq.com>

done

Signed-off-by: jingyang <3161362058@qq.com>

* fix build

Signed-off-by: jingyang <3161362058@qq.com>

* fix oss && only zh

Signed-off-by: jingyang <3161362058@qq.com>

* feat checkout wechat

Signed-off-by: jingyang <3161362058@qq.com>

* fix ci

Signed-off-by: jingyang <3161362058@qq.com>

---------

Signed-off-by: jingyang <3161362058@qq.com>

* Docs: update "What is Sealos?" (labring#4200)

Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>

* refactor(main): unmount override container (labring#4161)

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

* feat: Create a demo plugin Monitor (labring#4184)

* feat: lens demo of web version

* chore: add & remove some packages

* fix: connect to desktop bug and change icon

* init: plugin Monitor init

* style: restore frontend/pnpm-workspace.yaml & pnpm-lock.yaml and create new ones in plugins/monitor

* restore: frontend/Makefile

* restore: frontend/pnpm-workspace.yaml

* restore

* feat:frontend license app (labring#4203)

* feat:frontend license app

Signed-off-by: jingyang <3161362058@qq.com>

* fix

Signed-off-by: jingyang <3161362058@qq.com>

* fix

* fix detail

Signed-off-by: jingyang <3161362058@qq.com>

---------

Signed-off-by: jingyang <3161362058@qq.com>

* Docs: update introduction (labring#4207)

Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>

* fix license db uri (labring#4211)

Signed-off-by: yy <lingdie.yy@outlook.com>

* update price (labring#4212)

* docs: Automated Changelog Update for v4.3.7 (labring#4210)

* 🤖 add release changelog using robot.

Signed-off-by: sealos-release-robot <sealos-release-robot@sealos.io>

* Update CHANGELOG.md

---------

Signed-off-by: sealos-release-robot <sealos-release-robot@sealos.io>
Co-authored-by: cuisongliu <cuisongliu@qq.com>

* 🤖 add release changelog using rebot. (labring#4213)

* add alt names. (labring#4214)

Signed-off-by: yy <lingdie.yy@outlook.com>

* Update the workflow to automatically update the website image after the image is built (labring#4209)

Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>

* fix(costcenter): fix unit & invoice amount (labring#4194)

* feat:docs add private cloud page (labring#4215)

* fix scripts (labring#4217)

* Fix database provider i18n. (labring#4216)

Signed-off-by: zzjin <tczzjin@gmail.com>

* fix user avator && url (labring#4218)

* fix user avator && url

Signed-off-by: jingyang <3161362058@qq.com>

* modify purchase page

Signed-off-by: jingyang <3161362058@qq.com>

* fix height

Signed-off-by: jingyang <3161362058@qq.com>

* fix docs

Signed-off-by: jingyang <3161362058@qq.com>

* fix params

* copy code

* license time

---------

Signed-off-by: jingyang <3161362058@qq.com>

* fix oss file name && docs footer (labring#4220)

* feat(frontend/desktop):support modify team limit (labring#4221)

* add acme resolver monitoring (labring#4223)

* feat:docs language-differentiated domain names (labring#4226)

* feat:standard cluster purchase process (labring#4225)

* feat:standard cluster purchase process

Signed-off-by: jingyang <3161362058@qq.com>

* fix cronjob

Signed-off-by: jingyang <3161362058@qq.com>

---------

Signed-off-by: jingyang <3161362058@qq.com>

* add cloud release ci.

Signed-off-by: yy <lingdie.yy@outlook.com>

---------

Signed-off-by: yy <lingdie.yy@outlook.com>
Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>
Signed-off-by: jingyang <3161362058@qq.com>
Signed-off-by: cuisongliu <cuisongliu@qq.com>
Signed-off-by: sealos-release-robot <sealos-release-robot@sealos.io>
Signed-off-by: zzjin <tczzjin@gmail.com>
Co-authored-by: cuisongliu <cuisongliu@qq.com>
Co-authored-by: Carson Yang <yangchuansheng33@gmail.com>
Co-authored-by: zhujingyang <72259332+zjy365@users.noreply.github.com>
Co-authored-by: Wishrem <97738578+Wishrem@users.noreply.github.com>
Co-authored-by: Jiahui <4543bxy@gmail.com>
Co-authored-by: sealos-release-robot <sealos-release-robot@sealos.io>
Co-authored-by: xudaotutou <13435638964@163.com>
Co-authored-by: zzjin <zzjin@users.noreply.github.com>
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