Repository navigation
util: cache the controller publish secret - #5497
Conversation
88e216a to
6521610
Compare
Rakshith-R
left a comment
There was a problem hiding this comment.
just a small nit,
please open the pr for review
6521610 to
0c1960f
Compare
c9aa5ae to
c1d7017
Compare
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/client-go/informers" | ||
| "k8s.io/client-go/tools/cache" | ||
| "sigs.k8s.io/controller-runtime/pkg/manager/signals" |
There was a problem hiding this comment.
controller-runtime is very large, I don't think you need it here.
The signals package is only used for this:
<-signals.SetupSignalHandler().Done()I think you can just write an empty struct to the channel too?
<-struct{}{}Or, consider replacing stopCh chan struct{} by stopCh chan bool and write <-true or something to it.
There was a problem hiding this comment.
The idea was to avoid leaking the unclosed channel. Handled it via signal.Notify.
| "sigs.k8s.io/controller-runtime/pkg/manager/signals" | ||
| ) | ||
|
|
||
| type cachedSecret struct { |
There was a problem hiding this comment.
Why introduce this type, and not use the Kubernetes Secret type?
There was a problem hiding this comment.
To avoid iterating, casting and copying secret.Data
There was a problem hiding this comment.
I guess nothing uses secret.StringData, but only the base64 encoded values?
There was a problem hiding this comment.
map[string][]byte vs map[string]string. While storing in cache we iterate over the bytes and cast them to string. Storing them like that is more convenient as the code elsewhere expects a map[string]string
Only the namespaces+secrets that are requested. There will be many Secrets in a Kubernetes cluster, we definitely should not cache all of them. Even all Secrets in the namespace where Ceph-CSI is deployed may be way too much. We also don't want auditing to fire alarms when Ceph-CSI is caching secrets it would not use.
A non-changeable default is never ideal. For some users it will be fine, others may want/need to tune it. Ideally there is an option to adjust the behavior. |
c1d7017 to
915b8b7
Compare
915b8b7 to
6d7b981
Compare
nixpanic
left a comment
There was a problem hiding this comment.
Looks good, just a few nits that should be corrected. The OOP change would be nice, but isn't absolutely required.
| "sigs.k8s.io/controller-runtime/pkg/manager/signals" | ||
| ) | ||
|
|
||
| type cachedSecret struct { |
There was a problem hiding this comment.
I guess nothing uses secret.StringData, but only the base64 encoded values?
6d7b981 to
f8cb6b4
Compare
nixpanic
left a comment
There was a problem hiding this comment.
Looks good. Just waiting for a response on the outstanding questions/comments.
| input := fmt.Sprintf("%s/%s", ns, name) | ||
| h := sha256.Sum256([]byte(input)) | ||
|
|
||
| // Only use 16bytes |
There was a problem hiding this comment.
I understand that the code only uses 16 bytes. The comment should better explain why only 16 bytes should be used. Is there no issue with potential abbreviated-hash-collisions?
There was a problem hiding this comment.
Added a comment. For a cache key, 128bits is collision is improbable until order of 10^9 entries. We'd be good with more than a billion entries.
| } | ||
|
|
||
| // secretCache is a thread safe cache for secrets. | ||
| // /!\ The `cache` must be read/modified with the lock held. |
There was a problem hiding this comment.
Just wondering why you decided to use sync.RWMutex and not sync.Map. Can you explain that a little?
There was a problem hiding this comment.
sync.Map is not strongly typed and would require type casting.
f8cb6b4 to
d874ea9
Compare
|
@Mergifyio rebase |
This patch introduces a caching mechanism based on the shared informers for ControllerPublish secrets. Signed-off-by: Niraj Yadav <[email protected]>
✅ Branch has been successfully rebased |
d874ea9 to
05f8a41
Compare
|
/test ci/centos/mini-e2e/k8s-1.33 |
|
@Mergifyio rebase |
☑️ Nothing to do, the required conditions are not metDetails
|
|
@Mergifyio queue |
🛑 The pull request has been removed from the queue
|
|
This pull request has been removed from the queue for the following reason: The merge conditions cannot be satisfied due to failing checks: You may have to fix your CI before adding the pull request to the queue again. |
|
@Mergifyio queue |
🛑 The pull request has been removed from the queue
|
|
/test ci/centos/k8s-e2e-external-storage/1.33 |
|
/test ci/centos/k8s-e2e-external-storage/1.32 |
|
/test ci/centos/upgrade-tests-cephfs |
|
/test ci/centos/k8s-e2e-external-storage/1.31 |
|
/test ci/centos/mini-e2e-helm/k8s-1.32 |
|
/test ci/centos/mini-e2e-helm/k8s-1.33 |
|
/test ci/centos/upgrade-tests-rbd |
|
/test ci/centos/mini-e2e-helm/k8s-1.31 |
|
/test ci/centos/mini-e2e/k8s-1.32 |
|
/test ci/centos/mini-e2e/k8s-1.33 |
|
/test ci/centos/mini-e2e/k8s-1.31 |
🛑 The pull request has been removed from the queue
|
|
@Mergifyio refresh |
✅ Pull request refreshed |
This patch adds watch and list RBACs to clusterroles for CephFS and RBD nodeplugin. This is to comply with the enhancement at: ceph/ceph-csi#5497 Signed-off-by: Niraj Yadav <[email protected]>
This patch adds watch and list RBACs to clusterroles for CephFS and RBD nodeplugin. This is to comply with the enhancement at: ceph/ceph-csi#5497 Signed-off-by: Niraj Yadav <[email protected]>
This patch adds watch and list RBACs to clusterroles for CephFS and RBD nodeplugin. This is to comply with the enhancement at: ceph/ceph-csi#5497 Signed-off-by: Niraj Yadav <[email protected]> (cherry picked from commit 0308496)
Describe what this PR does
This patch introduces a caching mechanism based on the shared informers for ControllerPublish secrets.
Is there anything that requires special attention
Do you have any questions?