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 <[email protected]>
  • Loading branch information
tpantelis committed Nov 17, 2023
1 parent 2053f2a commit 2b62b61
Show file tree
Hide file tree
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
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
})
})

Expand Down
4 changes: 4 additions & 0 deletions pkg/agent/controller/endpoint_slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2b62b61

Please sign in to comment.