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 continuous release logic #222

Merged
merged 1 commit into from
Jul 15, 2024
Merged

Conversation

myname4423
Copy link
Contributor

@myname4423 myname4423 commented Jun 25, 2024

Ⅰ. Describe what this PR does

  1. fix the Incorrect Traffic Routing During Continuous Releases (for both partition style and canary style) #221
  2. add some simple traffic functions to do single traffic related work.

Ⅱ. Does this pull request fix one issue?

#221

Ⅲ. Special notes for reviews

@@ -10,4 +10,5 @@ type ReleaseManager interface {
doCanaryFinalising(c *RolloutContext) (bool, error)
fetchBatchRelease(ns, name string) (*v1beta1.BatchRelease, error)
removeBatchRelease(c *RolloutContext) (bool, error)
doCanaryReset(c *RolloutContext) (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.

what is the difference bewteen doCanaryFinalising and doCanaryReset, plz add the missing description of all these methods, and the workflow to call these methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

comment added

@myname4423 myname4423 force-pushed the fix branch 2 times, most recently from 54cf862 to 9cd7411 Compare July 3, 2024 03:03
return done, err
}
if subStatus.LastUpdateTime != nil && subStatus.LastUpdateTime.Add(time.Second*time.Duration(3)).After(time.Now()) {
Copy link
Member

Choose a reason for hiding this comment

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

use time.Since() instead of After to compare two time for better readability.
plz change similar comparison in the patch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

} else {
klog.Infof("rollout(%s/%s) in step (%s), and success", c.Rollout.Namespace, c.Rollout.Name, subStatus.FinalisingStep)
subStatus.LastUpdateTime = &metav1.Time{Time: time.Now()}
subStatus.FinalisingStep = v1beta1.FinalisingStepTypeDeleteBR
Copy link
Member

Choose a reason for hiding this comment

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

just fallthrough to FinalisingStepTypeDeleteBR ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

return done, err
}
if subStatus.LastUpdateTime != nil && subStatus.LastUpdateTime.Add(time.Second*time.Duration(3)).After(time.Now()) {
Copy link
Member

Choose a reason for hiding this comment

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

use defaultGracePeriodSeconds instead of const 3
plz change similar const in the patch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -274,6 +274,119 @@ func (m *Manager) FinalisingTrafficRouting(c *TrafficRoutingContext, onlyRestore
return true, nil
}

// RestoreGateway can be seen as route all traffic to stable service
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 comment about the return variables in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

cService := &corev1.Service{ObjectMeta: metav1.ObjectMeta{Namespace: c.Namespace, Name: cServiceName}}
// end to end deployment, don't remove the canary service;
// because canary service is stable service
if !c.OnlyTrafficRouting && !c.DisableGenerateCanaryService {
Copy link
Member

Choose a reason for hiding this comment

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

plz double check the logic, is it And or Or

// RestoreGateway restore gateway resources without graceful time
// bool return value indicates whether the gateway resources has been successfully restored
// error return value indicates error encountered during restoring
func (m *Manager) RestoreGateway(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.

the first return variable seems redundant, consider remove it. actually this problem also applies to other func changed in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is mainly to maintain consistency with other traffic routing functions.
anyway, i removed the first return variable.

pkg/controller/rollout/rollout_progressing.go Show resolved Hide resolved
return false, err
}
// usually, GracePeriodSeconds means duration to wait after an operation done
// we use defaultGracePeriodSeconds+1 because the count start from the time before the RestoreGateway called
Copy link
Member

Choose a reason for hiding this comment

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

shall we use trafficrouting.GracePeriodSeconds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

// usually, GracePeriodSeconds means duration to wait after an operation done
// we use defaultGracePeriodSeconds+1 because the count start from the time before the RestoreGateway called
if subStatus.LastUpdateTime != nil && time.Since(subStatus.LastUpdateTime.Time) < time.Second*time.Duration(defaultGracePeriodSeconds+1) {
klog.Infof("rollout(%s/%s) in step (%s), and wait %d seconds", c.Rollout.Namespace, c.Rollout.Name, subStatus.FinalisingStep, defaultGracePeriodSeconds+1)
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 //TODO to wait for gateway accept the new routing setting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

pkg/controller/rollout/rollout_progressing.go Outdated Show resolved Hide resolved
@myname4423 myname4423 force-pushed the fix branch 2 times, most recently from 0b56327 to c04b484 Compare July 10, 2024 02:49
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

@zmberg
Copy link
Member

zmberg commented Jul 15, 2024

/approve

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zmberg

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 e7652cb into openkruise:master Jul 15, 2024
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.

5 participants