Revision 14f576449f0d8396b13e800c82d1f1cd07560555 authored by Arthur Outhenin-Chalandre on 08 June 2024, 00:03:57 UTC, committed by André Martins on 17 June 2024, 10:48:51 UTC
This commit fixes the case when a remote service gets deleted while the local service remains. Previously the Reconcile on the controller wasn't called because we weren't returning the deleted Service in the service informer List method which may leave some EndpointSlice in the cluster that should be deleted. In an usual Kubernetes environment this is not an issue since the OwnerReference should be deleting the EndpointSlices as well. In our case the actual Service still exist because we have this mechanism of creating "virtual" service by adding the cluster name in suffix to trigger a reconcile on each remote cluster. To fix that we are now returning the combination of all the local Services and the remote clusters instead of returning all the remote services. This allows to trigger a reconcile on all the possible services including some of them that don't exist which would make the Get method of the Service informer to return a not found error which will then trigger a deletion via our cleanup hook. Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>
1 parent 6f9b8fd
cells_test.go
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package cmd
import (
"testing"
"github.com/cilium/hive/hivetest"
"github.com/stretchr/testify/assert"
"go.uber.org/goleak"
"github.com/cilium/cilium/pkg/hive"
"github.com/cilium/cilium/pkg/logging"
"github.com/cilium/cilium/pkg/metrics"
"github.com/cilium/cilium/pkg/option"
)
var goleakOptions = []goleak.Option{
// Ignore all the currently running goroutines spawned
// by prior tests or by package init() functions (like the
// client-go logger).
goleak.IgnoreCurrent(),
// Ignore goroutines started by the policy trifecta, see [newPolicyTrifecta].
goleak.IgnoreTopFunction("github.com/cilium/cilium/pkg/identity/cache.(*identityWatcher).watch.func1"),
goleak.IgnoreTopFunction("github.com/cilium/cilium/pkg/trigger.(*Trigger).waiter"),
// Ignore goroutine started by the ipset reconciler rate limiter
goleak.IgnoreTopFunction("github.com/cilium/cilium/pkg/rate.NewLimiter.func1"),
}
// TestAgentCell verifies that the Agent hive can be instantiated with
// default configuration and thus the Agent hive can be inspected with
// the hive commands and documentation can be generated from it.
func TestAgentCell(t *testing.T) {
defer goleak.VerifyNone(t, goleakOptions...)
defer metrics.Reinitialize()
logging.SetLogLevelToDebug()
// Populate config with default values normally set by Viper flag defaults
option.Config.IPv4ServiceRange = AutoCIDR
option.Config.IPv6ServiceRange = AutoCIDR
err := hive.New(Agent).Populate(hivetest.Logger(t))
assert.NoError(t, err, "Populate()")
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...