From 0b90136a7ae759c8399a2c55222bdf90aa2c46bd Mon Sep 17 00:00:00 2001 From: divyapola5 Date: Mon, 27 Sep 2021 16:28:08 -0500 Subject: [PATCH 1/4] Add missing read unlock calls in transit backend code --- builtin/logical/transit/backend.go | 4 ++++ builtin/logical/transit/path_cache_config.go | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/builtin/logical/transit/backend.go b/builtin/logical/transit/backend.go index 0e2f8264153b..d91df7df1863 100644 --- a/builtin/logical/transit/backend.go +++ b/builtin/logical/transit/backend.go @@ -122,11 +122,13 @@ func (b *backend) GetPolicy(ctx context.Context, polReq keysutil.PolicyRequest, currentCacheSize := b.lm.GetCacheSize() storedCacheSize, err := GetCacheSizeFromStorage(ctx, polReq.Storage) if err != nil { + b.configMutex.RUnlock() return nil, false, err } if currentCacheSize != storedCacheSize { err = b.lm.InitCache(storedCacheSize) if err != nil { + b.configMutex.RUnlock() return nil, false, err } } @@ -135,6 +137,8 @@ func (b *backend) GetPolicy(ctx context.Context, polReq keysutil.PolicyRequest, b.configMutex.Lock() defer b.configMutex.Unlock() b.cacheSizeChanged = false + } else { + b.configMutex.RUnlock() } p, _, err := b.lm.GetPolicy(ctx, polReq, rand) if err != nil { diff --git a/builtin/logical/transit/path_cache_config.go b/builtin/logical/transit/path_cache_config.go index 6610548ce135..6a1f791e0c03 100644 --- a/builtin/logical/transit/path_cache_config.go +++ b/builtin/logical/transit/path_cache_config.go @@ -86,16 +86,19 @@ func (b *backend) pathCacheConfigRead(ctx context.Context, req *logical.Request, return nil, err } + if currentCacheSize != storedCacheSize { + err = b.lm.InitCache(storedCacheSize) + if err != nil { + return nil, err + } + } + resp := &logical.Response{ Data: map[string]interface{}{ "size": storedCacheSize, }, } - if currentCacheSize != storedCacheSize { - resp.Warnings = []string{"This cache size will not be applied until the transit mount is reloaded"} - } - return resp, nil } From 101dd30fd10d339761b8393e6ba5aeeffdd4b44e Mon Sep 17 00:00:00 2001 From: divyapola5 Date: Mon, 27 Sep 2021 16:59:32 -0500 Subject: [PATCH 2/4] Added changelog --- changelog/12652.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/12652.txt diff --git a/changelog/12652.txt b/changelog/12652.txt new file mode 100644 index 000000000000..627963ac028e --- /dev/null +++ b/changelog/12652.txt @@ -0,0 +1,4 @@ +```release-note:bug +Add missing read unlock calls in transit backend code. +Invoke initCache in pathCacheConfigRead routine if needed. +``` From fdd0bb345b77d9963c968f0d5c3fcea5f1d8e2e3 Mon Sep 17 00:00:00 2001 From: divyapola5 Date: Tue, 28 Sep 2021 11:14:33 -0500 Subject: [PATCH 3/4] Removed changelog entry --- changelog/12418.txt | 1 + changelog/12652.txt | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 changelog/12652.txt diff --git a/changelog/12418.txt b/changelog/12418.txt index 5ec2f6055393..bdad667e16b7 100644 --- a/changelog/12418.txt +++ b/changelog/12418.txt @@ -1,4 +1,5 @@ ```release-note:bug +secrets/transit: Enforce minimum cache size for transit backend. Init cache size on transit backend without restart. ``` diff --git a/changelog/12652.txt b/changelog/12652.txt deleted file mode 100644 index 627963ac028e..000000000000 --- a/changelog/12652.txt +++ /dev/null @@ -1,4 +0,0 @@ -```release-note:bug -Add missing read unlock calls in transit backend code. -Invoke initCache in pathCacheConfigRead routine if needed. -``` From 7412bf1e666eafe148dd0f66af49cbfa2246ac1f Mon Sep 17 00:00:00 2001 From: divyapola5 Date: Tue, 28 Sep 2021 11:23:09 -0500 Subject: [PATCH 4/4] Correct formatting in changelog entry --- changelog/12418.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/changelog/12418.txt b/changelog/12418.txt index bdad667e16b7..e6c07e9b9515 100644 --- a/changelog/12418.txt +++ b/changelog/12418.txt @@ -1,5 +1,3 @@ ```release-note:bug -secrets/transit: -Enforce minimum cache size for transit backend. -Init cache size on transit backend without restart. -``` +secrets/transit: Enforce minimum cache size for transit backend and init cache size on transit backend without restart. +``` \ No newline at end of file