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

v1.14 Backports 2024-12-02 #36290

Closed
wants to merge 3 commits into from
Closed
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
15 changes: 7 additions & 8 deletions cilium/cmd/preflight_identity_crd_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/cilium/cilium/pkg/identity/cache"
cacheKey "github.com/cilium/cilium/pkg/identity/key"
"github.com/cilium/cilium/pkg/idpool"
"github.com/cilium/cilium/pkg/k8s"
ciliumClient "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/client"
k8sClient "github.com/cilium/cilium/pkg/k8s/client"
"github.com/cilium/cilium/pkg/k8s/identitybackend"
Expand Down Expand Up @@ -96,7 +95,7 @@ func migrateIdentityCmd() *cobra.Command {
// NOTE: It is assumed that the migration is from k8s to k8s installations. The
// key labels different when running in non-k8s mode.
func migrateIdentities(ctx cell.HookContext, clientset k8sClient.Clientset, shutdowner hive.Shutdowner) error {
defer shutdowner.Shutdown(nil)
defer shutdowner.Shutdown()

// Setup global configuration
// These are defined in cilium/cmd/kvstore.go
Expand All @@ -108,7 +107,7 @@ func migrateIdentities(ctx cell.HookContext, clientset k8sClient.Clientset, shut

// Init Identity backends
initCtx, initCancel := context.WithTimeout(ctx, opTimeout)
kvstoreBackend := initKVStore(initCtx)
kvstoreBackend := initKVStore(ctx, initCtx)

crdBackend, crdAllocator := initK8s(initCtx, clientset)
initCancel()
Expand Down Expand Up @@ -207,10 +206,6 @@ func migrateIdentities(ctx cell.HookContext, clientset k8sClient.Clientset, shut
func initK8s(ctx context.Context, clientset k8sClient.Clientset) (crdBackend allocator.Backend, crdAllocator *allocator.Allocator) {
log.Info("Setting up kubernetes client")

if err := k8s.WaitForNodeInformation(ctx, clientset); err != nil {
log.WithError(err).Fatal("Unable to connect to get node spec from apiserver")
}

// Update CRDs to ensure ciliumIdentity is present
ciliumClient.RegisterCRDs(clientset)

Expand Down Expand Up @@ -247,10 +242,14 @@ func initK8s(ctx context.Context, clientset k8sClient.Clientset) (crdBackend all

// initKVStore connects to the kvstore with a allocator.Backend, initialised to
// find identities at the default cilium paths.
func initKVStore(ctx context.Context) (kvstoreBackend allocator.Backend) {
func initKVStore(ctx, wctx context.Context) (kvstoreBackend allocator.Backend) {
log.Info("Setting up kvstore client")
setupKvstore(ctx)

if err := <-kvstore.Client().Connected(wctx); err != nil {
log.WithError(err).Fatal("Cannot connect to the kvstore")
}

idPath := path.Join(cache.IdentitiesPath, "id")
kvstoreBackend, err := kvstoreallocator.NewKVStoreBackend(cache.IdentitiesPath, idPath, &cacheKey.GlobalIdentity{}, kvstore.Client())
if err != nil {
Expand Down
Loading