Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/trafficrouting/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (m *Manager) DoTrafficRouting(c *TrafficRoutingContext) (bool, error) {
klog.Errorf("%s get canary service(%s) failed: %s", c.Key, canaryServiceName, err.Error())
return false, err
} else if errors.IsNotFound(err) {
canaryService, err = m.createCanaryService(c, canaryServiceName, *stableService.Spec.DeepCopy())
canaryService, err = m.createCanaryService(c, canaryServiceName, *stableService.Spec.DeepCopy(), stableService.Annotations, stableService.Labels)
if err != nil {
return false, err
}
Expand Down Expand Up @@ -428,12 +428,14 @@ func newNetworkProvider(c client.Client, con *TrafficRoutingContext, sService, c
return network.CompositeController(networkProviders), nil
}

func (m *Manager) createCanaryService(c *TrafficRoutingContext, cService string, spec corev1.ServiceSpec) (*corev1.Service, error) {
func (m *Manager) createCanaryService(c *TrafficRoutingContext, cService string, spec corev1.ServiceSpec, annotations, labels map[string]string) (*corev1.Service, error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if we have to copy the metadata, then just pass the service object instead of servicespec

canaryService := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Namespace: c.Namespace,
Name: cService,
OwnerReferences: []metav1.OwnerReference{c.OwnerRef},
Annotations: annotations,
Labels: labels,
},
Spec: spec,
}
Expand Down
11 changes: 9 additions & 2 deletions test/e2e/rollout_v1beta1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5379,7 +5379,7 @@ var _ = SIGDescribe("Rollout v1beta1", func() {

KruiseDescribe("StatefulSet canary rollout with Ingress", func() {
KruiseDescribe("Native StatefulSet rollout canary with Ingress", func() {
It("V1->V2: Percentage, 20%,60% Succeeded", func() {
It("V1->V2: Percentage, 20%,60% Succeeded with canary service check", func() {
By("Creating Rollout...")
rollout := &v1beta1.Rollout{}
Expect(ReadYamlToObject("./test_data/rollout/rollout_v1beta1_partition_base.yaml", rollout)).ToNot(HaveOccurred())
Expand Down Expand Up @@ -5443,9 +5443,16 @@ var _ = SIGDescribe("Rollout v1beta1", func() {
Expect(workload.Status.UpdatedReplicas).Should(BeNumerically("==", 1))
Expect(workload.Status.ReadyReplicas).Should(BeNumerically("==", *workload.Spec.Replicas))
Expect(*workload.Spec.UpdateStrategy.RollingUpdate.Partition).Should(BeNumerically("==", *workload.Spec.Replicas-1))
By("check cloneSet status & paused success")

// check service metadata, once is enough
By("check canary service metadata")
canaryService := &v1.Service{}
Expect(GetObject(service.Name+"-canary", canaryService)).NotTo(HaveOccurred())
Expect(canaryService.Labels).To(BeEquivalentTo(service.Labels))
Expect(canaryService.Annotations).To(BeEquivalentTo(service.Annotations))

// check rollout status
By("check cloneSet status & paused success")
Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred())
Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing))
Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision))
Expand Down
Loading