Merge pull request #713 from XiShanYongYe-Chang/fixbug-rsp
Update binding object with replicas and replicaRequirements
This commit is contained in:
commit
41b0e36b2f
|
@ -440,6 +440,8 @@ func (d *ResourceDetector) ApplyPolicy(object *unstructured.Unstructured, object
|
||||||
bindingCopy.Labels = binding.Labels
|
bindingCopy.Labels = binding.Labels
|
||||||
bindingCopy.OwnerReferences = binding.OwnerReferences
|
bindingCopy.OwnerReferences = binding.OwnerReferences
|
||||||
bindingCopy.Spec.Resource = binding.Spec.Resource
|
bindingCopy.Spec.Resource = binding.Spec.Resource
|
||||||
|
bindingCopy.Spec.ReplicaRequirements = binding.Spec.ReplicaRequirements
|
||||||
|
bindingCopy.Spec.Replicas = binding.Spec.Replicas
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -486,6 +488,8 @@ func (d *ResourceDetector) ApplyClusterPolicy(object *unstructured.Unstructured,
|
||||||
bindingCopy.Labels = binding.Labels
|
bindingCopy.Labels = binding.Labels
|
||||||
bindingCopy.OwnerReferences = binding.OwnerReferences
|
bindingCopy.OwnerReferences = binding.OwnerReferences
|
||||||
bindingCopy.Spec.Resource = binding.Spec.Resource
|
bindingCopy.Spec.Resource = binding.Spec.Resource
|
||||||
|
bindingCopy.Spec.ReplicaRequirements = binding.Spec.ReplicaRequirements
|
||||||
|
bindingCopy.Spec.Replicas = binding.Spec.Replicas
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -513,6 +517,8 @@ func (d *ResourceDetector) ApplyClusterPolicy(object *unstructured.Unstructured,
|
||||||
bindingCopy.Labels = binding.Labels
|
bindingCopy.Labels = binding.Labels
|
||||||
bindingCopy.OwnerReferences = binding.OwnerReferences
|
bindingCopy.OwnerReferences = binding.OwnerReferences
|
||||||
bindingCopy.Spec.Resource = binding.Spec.Resource
|
bindingCopy.Spec.Resource = binding.Spec.Resource
|
||||||
|
bindingCopy.Spec.ReplicaRequirements = binding.Spec.ReplicaRequirements
|
||||||
|
bindingCopy.Spec.Replicas = binding.Spec.Replicas
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -451,11 +451,26 @@ var _ = ginkgo.Describe("[ReplicaScheduling] ReplicaSchedulingStrategy testing",
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("replicas duplicated testing when rescheduling", func() {
|
ginkgo.It("replicas duplicated testing when rescheduling", func() {
|
||||||
ginkgo.By(fmt.Sprintf("Update deployment(%s/%s)'s replicas to 2", policyNamespace, policyName), func() {
|
ginkgo.By("make sure deployment has been propagated to member clusters", func() {
|
||||||
|
for _, cluster := range clusters {
|
||||||
|
clusterClient := getClusterClient(cluster.Name)
|
||||||
|
gomega.Expect(clusterClient).ShouldNot(gomega.BeNil())
|
||||||
|
|
||||||
|
gomega.Eventually(func() bool {
|
||||||
|
_, err := clusterClient.AppsV1().Deployments(deploymentNamespace).Get(context.TODO(), deploymentName, metav1.GetOptions{})
|
||||||
|
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||||
|
|
||||||
|
return true
|
||||||
|
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.By(fmt.Sprintf("Update deployment(%s/%s)'s replicas", deploymentNamespace, deploymentName), func() {
|
||||||
updateReplicas := int32(2)
|
updateReplicas := int32(2)
|
||||||
deployment.Spec.Replicas = &updateReplicas
|
deployment.Spec.Replicas = &updateReplicas
|
||||||
_, err := kubeClient.AppsV1().Deployments(deploymentNamespace).Update(context.TODO(), deployment, metav1.UpdateOptions{})
|
_, err := kubeClient.AppsV1().Deployments(deploymentNamespace).Update(context.TODO(), deployment, metav1.UpdateOptions{})
|
||||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||||
|
klog.Infof("Update deployment(%s/%s)'s replicas to %d", deploymentNamespace, deploymentName, *deployment.Spec.Replicas)
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.By("check if deployment's replicas have been updated on member clusters", func() {
|
ginkgo.By("check if deployment's replicas have been updated on member clusters", func() {
|
||||||
|
@ -598,6 +613,20 @@ var _ = ginkgo.Describe("[ReplicaScheduling] ReplicaSchedulingStrategy testing",
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("replicas divided and weighted testing when rescheduling", func() {
|
ginkgo.It("replicas divided and weighted testing when rescheduling", func() {
|
||||||
|
ginkgo.By("make sure deployment has been propagated to member clusters", func() {
|
||||||
|
for _, cluster := range clusters {
|
||||||
|
clusterClient := getClusterClient(cluster.Name)
|
||||||
|
gomega.Expect(clusterClient).ShouldNot(gomega.BeNil())
|
||||||
|
|
||||||
|
gomega.Eventually(func() bool {
|
||||||
|
_, err := clusterClient.AppsV1().Deployments(deploymentNamespace).Get(context.TODO(), deploymentName, metav1.GetOptions{})
|
||||||
|
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||||
|
|
||||||
|
return true
|
||||||
|
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
expectedReplicas := int32(3)
|
expectedReplicas := int32(3)
|
||||||
ginkgo.By(fmt.Sprintf("Update deployment(%s/%s)'s replicas to 3*len(clusters)", policyNamespace, policyName), func() {
|
ginkgo.By(fmt.Sprintf("Update deployment(%s/%s)'s replicas to 3*len(clusters)", policyNamespace, policyName), func() {
|
||||||
updateReplicas := expectedReplicas * int32(len(clusters))
|
updateReplicas := expectedReplicas * int32(len(clusters))
|
||||||
|
@ -780,6 +809,20 @@ var _ = ginkgo.Describe("[ReplicaScheduling] ReplicaSchedulingStrategy testing",
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("replicas divided and weighted testing when rescheduling", func() {
|
ginkgo.It("replicas divided and weighted testing when rescheduling", func() {
|
||||||
|
ginkgo.By("make sure deployment has been propagated to member clusters", func() {
|
||||||
|
for _, cluster := range clusters {
|
||||||
|
clusterClient := getClusterClient(cluster.Name)
|
||||||
|
gomega.Expect(clusterClient).ShouldNot(gomega.BeNil())
|
||||||
|
|
||||||
|
gomega.Eventually(func() bool {
|
||||||
|
_, err := clusterClient.AppsV1().Deployments(deploymentNamespace).Get(context.TODO(), deploymentName, metav1.GetOptions{})
|
||||||
|
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||||
|
|
||||||
|
return true
|
||||||
|
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
ginkgo.By(fmt.Sprintf("Update deployment(%s/%s)'s replicas to 2*sumWeight", policyNamespace, policyName), func() {
|
ginkgo.By(fmt.Sprintf("Update deployment(%s/%s)'s replicas to 2*sumWeight", policyNamespace, policyName), func() {
|
||||||
sumWeight := 0
|
sumWeight := 0
|
||||||
for index := range clusterNames {
|
for index := range clusterNames {
|
||||||
|
|
Loading…
Reference in New Issue