fix some little rollout bug (#59)

Signed-off-by: liheng.zms <liheng.zms@alibaba-inc.com>
This commit is contained in:
berg 2022-07-22 18:47:37 +08:00 committed by GitHub
parent 279a4e8fab
commit 794003c150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 12 deletions

View File

@ -89,7 +89,7 @@ func (p podEventHandler) enqueue(pod *corev1.Pod, q workqueue.RateLimitingInterf
workloadGVK := schema.FromAPIVersionAndKind(owner.APIVersion, owner.Kind)
workloadObj, err := util.GetOwnerWorkload(p.Reader, pod)
if err != nil || workloadObj == nil {
klog.Errorf("Failed to get owner workload for pod %v, err: %v", client.ObjectKeyFromObject(pod), err)
//klog.Errorf("Failed to get owner workload for pod %v, err: %v", client.ObjectKeyFromObject(pod), err)
return
}

View File

@ -70,11 +70,7 @@ func (r *rolloutContext) doCanaryTrafficRouting() (bool, error) {
return false, err
} else if errors.IsNotFound(err) {
klog.Infof("rollout(%s/%s) canary service(%s) Not Found, and create it", r.rollout.Namespace, r.rollout.Name, r.canaryService)
if err = r.createCanaryService(stableService); err != nil {
return false, err
}
data := util.DumpJSON(r.canaryService)
klog.Infof("create rollout(%s/%s) canary service(%s) success", r.rollout.Namespace, r.rollout.Name, data)
return false, r.createCanaryService(stableService)
}
// update service selector
@ -184,7 +180,7 @@ func (r *rolloutContext) doFinalisingTrafficRouting() (bool, error) {
if len(r.rollout.Spec.Strategy.Canary.TrafficRoutings) == 0 {
return true, nil
}
klog.Infof("rollout(%s/%s) start finalising traffic routing")
klog.Infof("rollout(%s/%s) start finalising traffic routing", r.rollout.Namespace, r.rollout.Name)
if r.rollout.Spec.Strategy.Canary.TrafficRoutings[0].GracePeriodSeconds <= 0 {
r.rollout.Spec.Strategy.Canary.TrafficRoutings[0].GracePeriodSeconds = defaultGracePeriodSeconds
}
@ -231,7 +227,7 @@ func (r *rolloutContext) doFinalisingTrafficRouting() (bool, error) {
func (r *rolloutContext) newTrafficRoutingController(roCtx *rolloutContext) (trafficrouting.Controller, error) {
canary := roCtx.rollout.Spec.Strategy.Canary
if canary.TrafficRoutings[0].Ingress != nil && canary.TrafficRoutings[0].Ingress.ClassType == "nginx" {
if canary.TrafficRoutings[0].Ingress != nil {
gvk := schema.GroupVersionKind{Group: rolloutv1alpha1.GroupVersion.Group, Version: rolloutv1alpha1.GroupVersion.Version, Kind: "Rollout"}
return nginx.NewNginxTrafficRouting(r.Client, r.newStatus, nginx.Config{
RolloutName: r.rollout.Name,
@ -285,5 +281,6 @@ func (r *rolloutContext) createCanaryService(stableService *corev1.Service) erro
klog.Errorf("create rollout(%s/%s) canary service(%s) failed: %s", r.rollout.Namespace, r.rollout.Name, r.canaryService, err.Error())
return err
}
klog.Infof("create rollout(%s/%s) canary service(%s) success", r.rollout.Namespace, r.rollout.Name, util.DumpJSON(canaryService))
return nil
}

View File

@ -190,10 +190,10 @@ func validateRolloutSpecCanaryTraffic(traffic *appsv1alpha1.TrafficRouting, fldP
}
if traffic.Ingress != nil {
if len(traffic.Ingress.Name) == 0 {
if traffic.Ingress.Name == "" {
errList = append(errList, field.Invalid(fldPath.Child("Ingress"), traffic.Ingress, "TrafficRouting.Ingress.Ingress cannot be empty"))
}
if traffic.Ingress.ClassType != "nginx" {
if traffic.Ingress.ClassType != "" && traffic.Ingress.ClassType != "nginx" {
errList = append(errList, field.Invalid(fldPath.Child("Ingress"), traffic.Ingress, "TrafficRouting.Ingress.ClassType only support nginx"))
}
}

View File

@ -2798,7 +2798,7 @@ var _ = SIGDescribe("Rollout", func() {
})
KruiseDescribe("Advanced StatefulSet rollout canary nginx", func() {
It("V1->V2: Percentage, 20%,60% Succeeded", func() {
It("Advanced StatefulSet V1->V2: Percentage, 20%,60% Succeeded", func() {
By("Creating Rollout...")
rollout := &rolloutsv1alpha1.Rollout{}
Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred())
@ -2895,6 +2895,7 @@ var _ = SIGDescribe("Rollout", func() {
Expect(GetObject(rollout.Status.CanaryStatus.CanaryService, cIngress)).NotTo(HaveOccurred())
Expect(cIngress.Annotations[fmt.Sprintf("%s/canary-weight", nginxIngressAnnotationDefaultPrefix)]).Should(Equal(fmt.Sprintf("%d", *rollout.Spec.Strategy.Canary.Steps[1].Weight)))
// cloneset
time.Sleep(time.Second * 10)
Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred())
Expect(workload.Status.UpdatedReplicas).Should(BeNumerically("==", 3))
Expect(workload.Status.ReadyReplicas).Should(BeNumerically("==", *workload.Spec.Replicas))

View File

@ -14,7 +14,7 @@ spec:
# kind: Service
# name: echoserver-canary
# port: 80
# weight: 20
# weight: 40
matches:
- path:
type: PathPrefix