Skip to content

Commit

Permalink
Fix invalid ServiceExport Conflict status condition
Browse files Browse the repository at this point in the history
This occurs if there's more than one service exported in a cluster. The
conflict checking was processing all local EndpointSlices instead of only
those corresponding to the service in question.

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
  • Loading branch information
tpantelis committed Nov 17, 2023
1 parent 2053f2a commit 2b62b61
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/agent/controller/clusterip_service_test.go
Original file line number Diff line number Diff line change
@@ -19,13 +19,16 @@ limitations under the License.
package controller_test

import (
"context"
"fmt"
"strconv"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/submariner-io/admiral/pkg/resource"
"github.com/submariner-io/admiral/pkg/syncer/test"
testutil "github.com/submariner-io/admiral/pkg/test"
"github.com/submariner-io/lighthouse/pkg/agent/controller"
"github.com/submariner-io/lighthouse/pkg/constants"
corev1 "k8s.io/api/core/v1"
discovery "k8s.io/api/discovery/v1"
@@ -272,6 +275,16 @@ 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)

Eventually(func() interface{} {
obj, err := serviceExportClientFor(t.cluster1.localDynClient, service.Namespace).Get(context.Background(),
serviceExport.Name, metav1.GetOptions{})
Expect(err).To(Succeed())

return controller.FindServiceExportStatusCondition(toServiceExport(obj).Status.Conditions, mcsv1a1.ServiceExportConflict)
}).Should(BeNil(), "Unexpected ServiceExport status condition")
})
})

4 changes: 4 additions & 0 deletions pkg/agent/controller/endpoint_slice.go
Original file line number Diff line number Diff line change
@@ -247,6 +247,10 @@ func (c *EndpointSliceController) checkForConflicts(_, name, namespace string) (
for _, o := range epsList {
eps := o.(*discovery.EndpointSlice)

if eps.Labels[mcsv1a1.LabelServiceName] != name || eps.Labels[constants.LabelSourceNamespace] != namespace {
continue
}

servicePorts := c.serviceExportClient.toServicePorts(eps.Ports)
if prevServicePorts == nil {
prevServicePorts = servicePorts

0 comments on commit 2b62b61

Please sign in to comment.