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

Remove unused parameter from NewCachingIdentityAllocator #25594

Merged
merged 1 commit into from
May 24, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion clustermesh-apiserver/vmmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewVMManager(clientset k8sClient.Clientset) *VMManager {
if option.Config.EnableWellKnownIdentities {
identity.InitWellKnownIdentities(option.Config)
}
m.identityAllocator.InitIdentityAllocator(clientset, identityStore)
m.identityAllocator.InitIdentityAllocator(clientset)
m.startCiliumExternalWorkloadWatcher(clientset)
return m
}
Expand Down
2 changes: 1 addition & 1 deletion daemon/cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ func newDaemon(ctx context.Context, cleaner *daemonCleanup, params *daemonParams
// Ignore the channel returned by this function, as we want the global
// identity allocator to run asynchronously.
realIdentityAllocator := d.identityAllocator
realIdentityAllocator.InitIdentityAllocator(params.Clientset, nil)
realIdentityAllocator.InitIdentityAllocator(params.Clientset)

d.bootstrapClusterMesh(params.NodeManager)
}
Expand Down
3 changes: 1 addition & 2 deletions daemon/cmd/fqdn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

miekgdns "github.com/miekg/dns"
. "gopkg.in/check.v1"
k8sCache "k8s.io/client-go/tools/cache"

"github.com/cilium/cilium/pkg/allocator"
"github.com/cilium/cilium/pkg/checker"
Expand Down Expand Up @@ -111,7 +110,7 @@ func (f *FakeRefcountingIdentityAllocator) IdentityReferenceCounter() counter.In

func (f *FakeRefcountingIdentityAllocator) Close() {
}
func (f *FakeRefcountingIdentityAllocator) InitIdentityAllocator(versioned.Interface, k8sCache.Store) <-chan struct{} {
func (f *FakeRefcountingIdentityAllocator) InitIdentityAllocator(versioned.Interface) <-chan struct{} {
return nil
}
func (f *FakeRefcountingIdentityAllocator) WatchRemoteIdentities(string, kvstore.BackendOperations) (*allocator.RemoteCache, error) {
Expand Down
3 changes: 1 addition & 2 deletions daemon/cmd/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net/netip"

"github.com/go-openapi/runtime/middleware"
k8sCache "k8s.io/client-go/tools/cache"

"github.com/cilium/cilium/api/v1/models"
. "github.com/cilium/cilium/api/v1/server/restapi/policy"
Expand Down Expand Up @@ -95,7 +94,7 @@ type CachingIdentityAllocator interface {
cache.IdentityAllocator
clustermesh.RemoteIdentityWatcher

InitIdentityAllocator(versioned.Interface, k8sCache.Store) <-chan struct{}
InitIdentityAllocator(versioned.Interface) <-chan struct{}
Close()
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/clustermesh/clustermesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (s *ClusterMeshTestSuite) TestClusterMesh(c *C) {
identity.InitWellKnownIdentities(&fakeConfig.Config{})
// The nils are only used by k8s CRD identities. We default to kvstore.
mgr := cache.NewCachingIdentityAllocator(&testidentity.IdentityAllocatorOwnerMock{})
<-mgr.InitIdentityAllocator(nil, nil)
<-mgr.InitIdentityAllocator(nil)
defer mgr.Close()

dir, err := os.MkdirTemp("", "multicluster")
Expand Down
2 changes: 1 addition & 1 deletion pkg/clustermesh/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s *ClusterMeshServicesTestSuite) SetUpTest(c *C) {

mgr := cache.NewCachingIdentityAllocator(&testidentity.IdentityAllocatorOwnerMock{})
// The nils are only used by k8s CRD identities. We default to kvstore.
<-mgr.InitIdentityAllocator(nil, nil)
<-mgr.InitIdentityAllocator(nil)
dir, err := os.MkdirTemp("", "multicluster")
s.testDir = dir
c.Assert(err, IsNil)
Expand Down
2 changes: 1 addition & 1 deletion pkg/endpoint/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (s *EndpointSuite) SetUpTest(c *C) {
identity.InitWellKnownIdentities(&fakeConfig.Config{})
// The nils are only used by k8s CRD identities. We default to kvstore.
mgr := NewCachingIdentityAllocator(&testidentity.IdentityAllocatorOwnerMock{})
<-mgr.InitIdentityAllocator(nil, nil)
<-mgr.InitIdentityAllocator(nil)
s.mgr = mgr
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/endpoint/redirect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (s *RedirectSuite) TestAddVisibilityRedirects(c *check.C) {
idAllocatorOwner := &DummyIdentityAllocatorOwner{}

mgr := NewCachingIdentityAllocator(idAllocatorOwner)
<-mgr.InitIdentityAllocator(nil, nil)
<-mgr.InitIdentityAllocator(nil)
defer mgr.Close()

do := &DummyOwner{
Expand Down
12 changes: 6 additions & 6 deletions pkg/identity/cache/allocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *IdentityCacheTestSuite) TestAllocateIdentityReserved(c *C) {
}

mgr := NewCachingIdentityAllocator(newDummyOwner())
<-mgr.InitIdentityAllocator(nil, nil)
<-mgr.InitIdentityAllocator(nil)

c.Assert(identity.IdentityAllocationIsLocal(lbls), Equals, true)
i, isNew, err = mgr.AllocateIdentity(context.Background(), lbls, false, identity.InvalidIdentity)
Expand Down Expand Up @@ -239,7 +239,7 @@ func (ias *IdentityAllocatorSuite) TestGetIdentityCache(c *C) {
identity.InitWellKnownIdentities(&fakeConfig.Config{})
// The nils are only used by k8s CRD identities. We default to kvstore.
mgr := NewCachingIdentityAllocator(newDummyOwner())
<-mgr.InitIdentityAllocator(nil, nil)
<-mgr.InitIdentityAllocator(nil)
defer mgr.Close()
defer mgr.IdentityAllocator.DeleteAllKeys()

Expand All @@ -257,7 +257,7 @@ func (ias *IdentityAllocatorSuite) TestAllocator(c *C) {
identity.InitWellKnownIdentities(&fakeConfig.Config{})
// The nils are only used by k8s CRD identities. We default to kvstore.
mgr := NewCachingIdentityAllocator(owner)
<-mgr.InitIdentityAllocator(nil, nil)
<-mgr.InitIdentityAllocator(nil)
defer mgr.Close()
defer mgr.IdentityAllocator.DeleteAllKeys()

Expand Down Expand Up @@ -342,7 +342,7 @@ func (ias *IdentityAllocatorSuite) TestLocalAllocation(c *C) {
identity.InitWellKnownIdentities(&fakeConfig.Config{})
// The nils are only used by k8s CRD identities. We default to kvstore.
mgr := NewCachingIdentityAllocator(owner)
<-mgr.InitIdentityAllocator(nil, nil)
<-mgr.InitIdentityAllocator(nil)
defer mgr.Close()
defer mgr.IdentityAllocator.DeleteAllKeys()

Expand Down Expand Up @@ -414,10 +414,10 @@ func (s *IdentityCacheTestSuite) TestAllocatorReset(c *C) {
c.Assert(queued, Equals, id1a.ID)
}

<-mgr.InitIdentityAllocator(nil, nil)
<-mgr.InitIdentityAllocator(nil)
testAlloc()
mgr.Close()
<-mgr.InitIdentityAllocator(nil, nil)
<-mgr.InitIdentityAllocator(nil)
testAlloc()
mgr.Close()
}
10 changes: 2 additions & 8 deletions pkg/identity/cache/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"path"

"github.com/sirupsen/logrus"
"k8s.io/client-go/tools/cache"

"github.com/cilium/cilium/pkg/allocator"
"github.com/cilium/cilium/pkg/identity"
Expand Down Expand Up @@ -135,14 +134,13 @@ type IdentityAllocator interface {
// invocation of this function will have an effect. The Caller must have
// initialized well known identities before calling this (by calling
// identity.InitWellKnownIdentities()).
// client and identityStore are only used by the CRD identity allocator,
// currently, and identityStore may be nil.
// The client is only used by the CRD identity allocator currently.
// Returns a channel which is closed when initialization of the allocator is
// completed.
// TODO: identity backends are initialized directly in this function, pulling
// in dependencies on kvstore and k8s. It would be better to decouple this,
// since the backends are an interface.
func (m *CachingIdentityAllocator) InitIdentityAllocator(client clientset.Interface, identityStore cache.Store) <-chan struct{} {
func (m *CachingIdentityAllocator) InitIdentityAllocator(client clientset.Interface) <-chan struct{} {
m.setupMutex.Lock()
defer m.setupMutex.Unlock()

Expand Down Expand Up @@ -189,10 +187,6 @@ func (m *CachingIdentityAllocator) InitIdentityAllocator(client clientset.Interf

case option.IdentityAllocationModeCRD:
log.Debug("Identity allocation backed by CRD")
if identityStore != nil {
// ListAndWatch overwrites the store.
log.Warnf("Ignoring provided identityStore")
}
backend, err = identitybackend.NewCRDBackend(identitybackend.CRDBackendConfiguration{
Store: nil,
Client: client,
Expand Down
2 changes: 1 addition & 1 deletion pkg/identity/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s *IdentityCacheTestSuite) SetUpSuite(c *C) {

func (s *IdentityCacheTestSuite) TestLookupReservedIdentity(c *C) {
mgr := NewCachingIdentityAllocator(newDummyOwner())
<-mgr.InitIdentityAllocator(nil, nil)
<-mgr.InitIdentityAllocator(nil)

hostID := identity.GetReservedID("host")
c.Assert(mgr.LookupIdentityByID(context.TODO(), hostID), Not(IsNil))
Expand Down