fix some little rollout bug
Signed-off-by: liheng.zms <liheng.zms@alibaba-inc.com>
This commit is contained in:
parent
279a4e8fab
commit
37509f1033
|
|
@ -89,7 +89,7 @@ func (p podEventHandler) enqueue(pod *corev1.Pod, q workqueue.RateLimitingInterf
|
||||||
workloadGVK := schema.FromAPIVersionAndKind(owner.APIVersion, owner.Kind)
|
workloadGVK := schema.FromAPIVersionAndKind(owner.APIVersion, owner.Kind)
|
||||||
workloadObj, err := util.GetOwnerWorkload(p.Reader, pod)
|
workloadObj, err := util.GetOwnerWorkload(p.Reader, pod)
|
||||||
if err != nil || workloadObj == nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,11 +70,7 @@ func (r *rolloutContext) doCanaryTrafficRouting() (bool, error) {
|
||||||
return false, err
|
return false, err
|
||||||
} else if errors.IsNotFound(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)
|
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, r.createCanaryService(stableService)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update service selector
|
// update service selector
|
||||||
|
|
@ -184,7 +180,7 @@ func (r *rolloutContext) doFinalisingTrafficRouting() (bool, error) {
|
||||||
if len(r.rollout.Spec.Strategy.Canary.TrafficRoutings) == 0 {
|
if len(r.rollout.Spec.Strategy.Canary.TrafficRoutings) == 0 {
|
||||||
return true, nil
|
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 {
|
if r.rollout.Spec.Strategy.Canary.TrafficRoutings[0].GracePeriodSeconds <= 0 {
|
||||||
r.rollout.Spec.Strategy.Canary.TrafficRoutings[0].GracePeriodSeconds = defaultGracePeriodSeconds
|
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) {
|
func (r *rolloutContext) newTrafficRoutingController(roCtx *rolloutContext) (trafficrouting.Controller, error) {
|
||||||
canary := roCtx.rollout.Spec.Strategy.Canary
|
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"}
|
gvk := schema.GroupVersionKind{Group: rolloutv1alpha1.GroupVersion.Group, Version: rolloutv1alpha1.GroupVersion.Version, Kind: "Rollout"}
|
||||||
return nginx.NewNginxTrafficRouting(r.Client, r.newStatus, nginx.Config{
|
return nginx.NewNginxTrafficRouting(r.Client, r.newStatus, nginx.Config{
|
||||||
RolloutName: r.rollout.Name,
|
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())
|
klog.Errorf("create rollout(%s/%s) canary service(%s) failed: %s", r.rollout.Namespace, r.rollout.Name, r.canaryService, err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
klog.Infof("create rollout(%s/%s) canary service(%s) success", r.rollout.Namespace, r.rollout.Name, util.DumpJSON(canaryService))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,10 +190,10 @@ func validateRolloutSpecCanaryTraffic(traffic *appsv1alpha1.TrafficRouting, fldP
|
||||||
}
|
}
|
||||||
|
|
||||||
if traffic.Ingress != nil {
|
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"))
|
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"))
|
errList = append(errList, field.Invalid(fldPath.Child("Ingress"), traffic.Ingress, "TrafficRouting.Ingress.ClassType only support nginx"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2798,7 +2798,7 @@ var _ = SIGDescribe("Rollout", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
KruiseDescribe("Advanced StatefulSet rollout canary nginx", 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...")
|
By("Creating Rollout...")
|
||||||
rollout := &rolloutsv1alpha1.Rollout{}
|
rollout := &rolloutsv1alpha1.Rollout{}
|
||||||
Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred())
|
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(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)))
|
Expect(cIngress.Annotations[fmt.Sprintf("%s/canary-weight", nginxIngressAnnotationDefaultPrefix)]).Should(Equal(fmt.Sprintf("%d", *rollout.Spec.Strategy.Canary.Steps[1].Weight)))
|
||||||
// cloneset
|
// cloneset
|
||||||
|
time.Sleep(time.Second * 10)
|
||||||
Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred())
|
Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred())
|
||||||
Expect(workload.Status.UpdatedReplicas).Should(BeNumerically("==", 3))
|
Expect(workload.Status.UpdatedReplicas).Should(BeNumerically("==", 3))
|
||||||
Expect(workload.Status.ReadyReplicas).Should(BeNumerically("==", *workload.Spec.Replicas))
|
Expect(workload.Status.ReadyReplicas).Should(BeNumerically("==", *workload.Spec.Replicas))
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ spec:
|
||||||
# kind: Service
|
# kind: Service
|
||||||
# name: echoserver-canary
|
# name: echoserver-canary
|
||||||
# port: 80
|
# port: 80
|
||||||
# weight: 20
|
# weight: 40
|
||||||
matches:
|
matches:
|
||||||
- path:
|
- path:
|
||||||
type: PathPrefix
|
type: PathPrefix
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue