Skip to content

MWI: Add lib/boundkeypair for bound keypair backend implementation#54766

Merged
timothyb89 merged 3 commits intomasterfrom
timothyb89/lib-boundkeypair
May 13, 2025
Merged

MWI: Add lib/boundkeypair for bound keypair backend implementation#54766
timothyb89 merged 3 commits intomasterfrom
timothyb89/lib-boundkeypair

Conversation

@timothyb89
Copy link
Copy Markdown
Contributor

This splits the backend implementation of lib/boundkeypair out from the main bound keypair joining PR in #54371. It makes no changes beyond those already reviewed in that PR.

This splits the backend implementation of lib/boundkeypair out from
the main bound keypair joining PR in #54371. It makes no changes
beyond those already reviewed in that PR.
@timothyb89 timothyb89 requested review from boxofrad and strideynet May 13, 2025 16:40
@timothyb89 timothyb89 added machine-id no-changelog Indicates that a PR does not require a changelog entry labels May 13, 2025
@github-actions github-actions bot requested review from atburke and tigrato May 13, 2025 16:41
@timothyb89
Copy link
Copy Markdown
Contributor Author

Reviewer note, this just exists to reduce the changed LoC count in #54371 and to appease the size check. This package is relatively isolated and could be split out of the larger PR without much effort.

Comment thread lib/boundkeypair/bound_keypair.go Outdated
)

func newTestKeypair(t *testing.T) crypto.Signer {
key, err := cryptosuites.GenerateKey(context.Background(), func(ctx context.Context) (types.SignatureAlgorithmSuite, error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Many of these helper funcs could do with a t.Helper() call.

Suggested change
key, err := cryptosuites.GenerateKey(context.Background(), func(ctx context.Context) (types.SignatureAlgorithmSuite, error) {
t.Helper()
key, err := cryptosuites.GenerateKey(context.Background(), func(ctx context.Context) (types.SignatureAlgorithmSuite, error) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, good call. Fixed now, thanks!


var mu sync.Mutex

var experimentEnabled = os.Getenv("TELEPORT_BOUND_KEYPAIR_JOINING_EXPERIMENT") == "1"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we use strconv.ParseBool here just to be consistent with other similar env vars?

You might also consider a TELEPORT_UNSTABLE_ prefix for the var name to be consistent with similar approaches we've taken in the past. This communicates to the person who enables the feature that it's early and subject to change in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've changed the impl to use strconv.ParseBool(). We've been copying and pasting this for our feature flags for a while and I see why we went with the simpler implementation for these hacky flags, handling the error case does make things a bit uglier.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I typically don't handle the error case - if you get an error from ParseBool you are guaranteed to get false (not enabled).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, good call, that's much simpler. Thanks!

}

// SetEnabled sets the experiment enabled flag.
func SetEnabled(enabled bool) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to be able to change this at runtime? It might be simpler to check the env var on startup and require a process restart to pick up changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's used in tests, unfortunately. I'm okay with it being a bit ugly since it won't stick around for long.

// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package experiment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't love the name of the package. At the call site, it's going to look something like if experiment.Enabled() { ... and the first question the reader will have is "what experiment?"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's fair enough, I've renamed the package.

- Renames the experiment package
- Fixes missing test helper flags
- Renames the experiment env var
- Uses strconv.ParseBool()
@timothyb89 timothyb89 added this pull request to the merge queue May 13, 2025
Merged via the queue into master with commit 37d28d0 May 13, 2025
40 checks passed
@timothyb89 timothyb89 deleted the timothyb89/lib-boundkeypair branch May 13, 2025 22:17
timothyb89 added a commit that referenced this pull request May 22, 2025
…54766)

* MWI: Add lib/boundkeypair for bound keypair backend implementation

This splits the backend implementation of lib/boundkeypair out from
the main bound keypair joining PR in #54371. It makes no changes
beyond those already reviewed in that PR.

* Apply code review suggestions

- Renames the experiment package
- Fixes missing test helper flags
- Renames the experiment env var
- Uses strconv.ParseBool()

* Simplify experiment flag
github-merge-queue bot pushed a commit that referenced this pull request May 24, 2025
…ion (#54766) (#55079)

* MWI: Add lib/boundkeypair for bound keypair backend implementation (#54766)

* MWI: Add lib/boundkeypair for bound keypair backend implementation

This splits the backend implementation of lib/boundkeypair out from
the main bound keypair joining PR in #54371. It makes no changes
beyond those already reviewed in that PR.

* Apply code review suggestions

- Renames the experiment package
- Fixes missing test helper flags
- Renames the experiment env var
- Uses strconv.ParseBool()

* Simplify experiment flag

* Fix broken test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

machine-id no-changelog Indicates that a PR does not require a changelog entry size/md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants