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

Add suport for specifying percentage of pods for RollingUpdate #36

Merged
merged 1 commit into from
Jul 14, 2020

Conversation

qianjun1993
Copy link
Contributor

Add suport for specifying percentage of pods for RollingUpdate

@@ -103,7 +104,7 @@ type TAppUpdateStrategy struct {
// Template is the rolling update template name
Template string `json:"template,omitempty"`
// MaxUnavailable is the max unavailable number when tapp is rolling update, default is 1.
MaxUnavailable *int32 `json:"maxUnavailable,omitempty"`
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

能兼容处理已经创建的tapp对象吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

测试已创建的tapp更新没问题

@@ -823,7 +824,11 @@ func (c *Controller) transformPodActions(tapp *tappv1.TApp, podActions map[strin

maxUnavailable := tappv1.DefaultMaxUnavailable
if tapp.Spec.UpdateStrategy.MaxUnavailable != nil {
maxUnavailable = int(*tapp.Spec.UpdateStrategy.MaxUnavailable)
var err error
maxUnavailable, err = intstr.GetValueFromIntOrPercent(tapp.Spec.UpdateStrategy.MaxUnavailable, len(rollingUpdateIds), true)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里len(rollingUpdateIds) 改成desiredRunningPods.Len()会不会更合理

Copy link
Contributor Author

Choose a reason for hiding this comment

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

百分比应该是指定要滚动更新的template的pod的,也就是rollingupdate的。换成desiredRunningpod会变成所有pod的

Copy link
Contributor Author

Choose a reason for hiding this comment

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

结合现有的测试样例看了一下,其他template的更新会影响到滚动更新的template的数量,所以还是换成了desiredRunningpod。

var err error
maxUnavailable, err = intstr.GetValueFromIntOrPercent(tapp.Spec.UpdateStrategy.MaxUnavailable, len(rollingUpdateIds), true)
if err != nil {
klog.Errorf("invalid value for MaxUnavailable: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

如果出错了,return err直接返回?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add return

@qianjun1993 qianjun1993 force-pushed the master branch 2 times, most recently from b5535b9 to 74843d1 Compare July 6, 2020 07:05
@hex108
Copy link
Contributor

hex108 commented Jul 7, 2020

@qianjun1993 没问题了,加一个测试用例?

@qianjun1993
Copy link
Contributor Author

追加了测试用例

@hex108
Copy link
Contributor

hex108 commented Jul 14, 2020

LGTM

@hex108 hex108 merged commit 2dc454c into tkestack:master Jul 14, 2020
@hex108 hex108 mentioned this pull request Jul 15, 2020
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants