Skip to content

Conversation

pappz
Copy link
Contributor

@pappz pappz commented Sep 4, 2025

Describe your changes

Cache management server key

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

@Copilot Copilot AI review requested due to automatic review settings September 4, 2025 23:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements caching for the management server's public key to avoid repeated gRPC calls when the key is already known.

  • Adds a srvKey field to the GrpcClient struct to store the cached server key
  • Modifies GetServerPublicKey() to return the cached key if available, otherwise fetches and caches it
Comments suppressed due to low confidence (1)

shared/management/client/grpc.go:1

  • The cached server key access and assignment is not thread-safe. Multiple goroutines calling GetServerPublicKey() concurrently could cause race conditions. Consider protecting the srvKey field with a mutex or using atomic operations.
package client

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

sonarqubecloud bot commented Sep 5, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant