diff --git a/goKMS/kms/kmsintercom.go b/goKMS/kms/kmsintercom.go index d7338d6eed4d98acb546f6a761cf24c875d743fe..c4667496791c1160aa2ca7660addb56ceb3dd6c7 100644 --- a/goKMS/kms/kmsintercom.go +++ b/goKMS/kms/kmsintercom.go @@ -58,7 +58,7 @@ func (s *kmsTalkerServer) KeyIdNotification(ctx context.Context, in *pb.KeyIdNot switch { case !eqm.IsActive(): - log.Debugf("The key store for quantum module: %s is not active and denied incoming key sync attempts", eqm.ID()) + log.Debugf("The key store for quantum module: %s is not active and denied incoming key sync attempts, current key store length: %d", eqm.ID(), eqm.KeyStore().Length()) return nil, status.Errorf(codes.Aborted, "The corresponding key store is not active and does not accept incoming key sync attempts") case eqm.KeyStore().Length() >= int(eqm.MaxKeyFillLevel()): log.Debugf("The key store for quantum module: %s is at its maximum key fill level and does not accept incoming key sync attempts", eqm.ID()) diff --git a/goKMS/kms/peers/etsi14Quantummodule.go b/goKMS/kms/peers/etsi14Quantummodule.go index a948cbd39212bcfadcac915c888542609b913959..45d1465bcba0f26f53e0fb7f1b0973d10c623450 100644 --- a/goKMS/kms/peers/etsi14Quantummodule.go +++ b/goKMS/kms/peers/etsi14Quantummodule.go @@ -109,29 +109,31 @@ func (qm *ETSI014HTTPQuantumModule) Client() *etsi14ClientImpl.ClientImpl { } func (qm *ETSI014HTTPQuantumModule) Initialize() error { - var ctx context.Context - ctx, qm.stopFetch = context.WithCancel(context.Background()) - - qm.active = true - - // start polling keys - if qm.master { - go func() { - restartWaitingTime := time.Duration(2) * time.Minute - ticker := time.NewTicker(restartWaitingTime) - defer ticker.Stop() - - // immediately start with the ticker instead of waiting the defined amount - RestartFetchLoop: - for { - select { - case <-ticker.C: - qm.doKeyFetching(ctx) - case <-ctx.Done(): - break RestartFetchLoop + if !qm.active { + var ctx context.Context + ctx, qm.stopFetch = context.WithCancel(context.Background()) + + qm.active = true + + // start polling keys + if qm.master { + go func() { + restartWaitingTime := time.Duration(20) * time.Second + ticker := time.NewTicker(restartWaitingTime) + defer ticker.Stop() + + // immediately start with the ticker instead of waiting the defined amount + RestartFetchLoop: + for { + select { + case <-ticker.C: + qm.doKeyFetching(ctx) + case <-ctx.Done(): + break RestartFetchLoop + } } - } - }() + }() + } } return nil } diff --git a/goKMS/kms/store/kms-keystore.go b/goKMS/kms/store/kms-keystore.go index 565f33bf17afb6829ddb85594bbe79d51b73095f..652ff3373d53f66648a66905f16531c55f334f78 100644 --- a/goKMS/kms/store/kms-keystore.go +++ b/goKMS/kms/store/kms-keystore.go @@ -7,6 +7,7 @@ import ( etsi14 "code.fbi.h-da.de/danet/quant/etsi014/go/rest/etsi/client" "github.com/google/uuid" + log "github.com/sirupsen/logrus" ) type Status int @@ -121,5 +122,6 @@ func AddETSIKeysToKeystore(keyStore *KmsKeyStore, keyContainer []etsi14.KeyConta // add to keystore keyStore.AddKey(keyId, key) } + log.Debugf("Current key store length: %d", keyStore.Length()) return nil }