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

Improve the logic of grace period #226

Merged
merged 1 commit into from
Aug 13, 2024
Merged

Conversation

myname4423
Copy link
Contributor

Ⅰ. Describe what this PR does

use a map to store key(resource and action) and value (last modified time), if an operation require a grace period after update, we record the time of update, so that next time we can check if the grace period expires before executing this operation again.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Special notes for reviews

pkg/util/grace/grace_expectations.go Outdated Show resolved Hide resolved
pkg/util/grace/grace_expectations.go Show resolved Hide resolved
pkg/util/grace/grace_wrapper.go Show resolved Hide resolved
@myname4423 myname4423 force-pushed the improve branch 3 times, most recently from 19c1336 to 1308b4d Compare August 8, 2024 02:13
}

func (r *realGraceExpectations) SatisfiedExpectations(controllerKey string, action Action, graceSeconds int32) (bool, time.Duration) {
r.Lock()
Copy link
Member

Choose a reason for hiding this comment

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

consider using RLock

klog.Infof("%s start finalising traffic routing", c.Key)
// remove stable service the pod revision selector, so stable service will be selector all version pods.
verify, err := m.restoreStableService(c)
if err != nil || !verify {
if retry, err := m.RestoreStableService(c); err != nil || retry {
Copy link
Member

Choose a reason for hiding this comment

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

plz add log before each steps in this func

// returning (false, nil) means the update has been submitted, and no error occurred
// but we need to wait graceful time before returning true
func (m *Manager) PatchStableService(c *TrafficRoutingContext) (bool, error) {
func (m *Manager) RemoveCanaryService(c *TrafficRoutingContext) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

plz comment the return variable

Copy link
Member

@furykerry furykerry left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: furykerry

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kruise-bot kruise-bot merged commit 5378dc2 into openkruise:master Aug 13, 2024
20 of 21 checks passed
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.

4 participants