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

Fix invalid ServiceExport Conflict status condition #1439

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions pkg/agent/controller/clusterip_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ func testClusterIPServiceInOneCluster() {

// Ensure the resources for the first Service weren't overwritten
t.awaitAggregatedServiceImport(mcsv1a1.ClusterSetIP, t.cluster1.service.Name, t.cluster1.service.Namespace, &t.cluster1)

t.cluster1.ensureNoServiceExportCondition(mcsv1a1.ServiceExportConflict)
t.cluster1.ensureNoServiceExportCondition(mcsv1a1.ServiceExportConflict, serviceExport)
})
})

Expand Down
33 changes: 23 additions & 10 deletions pkg/agent/controller/controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,9 @@ func (c *cluster) newGlobalIngressIP(name, ip string) *unstructured.Unstructured
return ingressIP
}

func (c *cluster) retrieveServiceExportCondition(condType mcsv1a1.ServiceExportConditionType) *mcsv1a1.ServiceExportCondition {
obj, err := c.localServiceExportClient.Get(context.TODO(), c.serviceExport.Name, metav1.GetOptions{})
func (c *cluster) retrieveServiceExportCondition(se *mcsv1a1.ServiceExport, condType mcsv1a1.ServiceExportConditionType,
) *mcsv1a1.ServiceExportCondition {
obj, err := serviceExportClientFor(c.localDynClient, se.Namespace).Get(context.TODO(), se.Name, metav1.GetOptions{})
Expect(err).To(Succeed())

return controller.FindServiceExportStatusCondition(toServiceExport(obj).Status.Conditions, condType)
Expand Down Expand Up @@ -571,16 +572,28 @@ func (c *cluster) ensureLastServiceExportCondition(expected *mcsv1a1.ServiceExpo
resource.ToJSON(expected)))
}

func (c *cluster) ensureNoServiceExportCondition(condType mcsv1a1.ServiceExportConditionType) {
Consistently(func() interface{} {
return c.retrieveServiceExportCondition(condType)
}).Should(BeNil(), "Unexpected ServiceExport status condition")
func (c *cluster) ensureNoServiceExportCondition(condType mcsv1a1.ServiceExportConditionType, serviceExports ...*mcsv1a1.ServiceExport) {
if len(serviceExports) == 0 {
serviceExports = []*mcsv1a1.ServiceExport{c.serviceExport}
}

for _, se := range serviceExports {
Consistently(func() interface{} {
return c.retrieveServiceExportCondition(se, condType)
}).Should(BeNil(), "Unexpected ServiceExport status condition")
}
}

func (c *cluster) awaitNoServiceExportCondition(condType mcsv1a1.ServiceExportConditionType) {
Eventually(func() interface{} {
return c.retrieveServiceExportCondition(condType)
}).Should(BeNil(), "Unexpected ServiceExport status condition")
func (c *cluster) awaitNoServiceExportCondition(condType mcsv1a1.ServiceExportConditionType, serviceExports ...*mcsv1a1.ServiceExport) {
if len(serviceExports) == 0 {
serviceExports = []*mcsv1a1.ServiceExport{c.serviceExport}
}

for _, se := range serviceExports {
Eventually(func() interface{} {
return c.retrieveServiceExportCondition(se, condType)
}).Should(BeNil(), "Unexpected ServiceExport status condition")
}
}

func (c *cluster) awaitServiceUnavailableStatus() {
Expand Down
5 changes: 4 additions & 1 deletion pkg/agent/controller/endpoint_slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ func (c *EndpointSliceController) checkForConflicts(_, name, namespace string) (
return false, nil
}

epsList := c.syncer.ListLocalResources(&discovery.EndpointSlice{})
epsList := c.syncer.ListLocalResourcesBySelector(&discovery.EndpointSlice{}, k8slabels.SelectorFromSet(map[string]string{
constants.LabelSourceNamespace: namespace,
mcsv1a1.LabelServiceName: name,
}))

var prevServicePorts []mcsv1a1.ServicePort
var intersectedServicePorts []mcsv1a1.ServicePort
Expand Down
Loading