Skip to content

chore: bump newrelic-auth-rs#2399

Merged
sigilioso merged 9 commits intofeat/k8s-cli-system-identityfrom
chore/bump-nr-auth-040
Apr 13, 2026
Merged

chore: bump newrelic-auth-rs#2399
sigilioso merged 9 commits intofeat/k8s-cli-system-identityfrom
chore/bump-nr-auth-040

Conversation

@sigilioso
Copy link
Copy Markdown
Contributor

@sigilioso sigilioso commented Apr 9, 2026

Summary

PR on top of #2378

This PR bumps newrelic-auth-rs to 0.4.0 and adapts the System Identity CLI code to the corresponding breaking change.

Details

  • Cleans up the data model: types make explicit when a System Identity needs to be created and when it already exists.
  • Removes the Creator trait indirection for the k8s cli.
  • Handles onhost key-pair generation explicitly.

@sigilioso sigilioso requested a review from a team as a code owner April 9, 2026 10:05
@sigilioso sigilioso changed the title Chore/bump nr auth 040 chore: bump nr auth 040 Apr 9, 2026
@sigilioso sigilioso changed the title chore: bump nr auth 040 chore: bump newrelic-auth-rs Apr 9, 2026
Comment thread agent-control/src/cli/common/system_identity.rs Outdated
Comment thread agent-control/src/cli/common/system_identity.rs Outdated
/// Valid data to create a SystemIdentity, represent [SystemIdentityArgs] after validation.
#[derive(Debug)]
pub struct SystemIdentitySpec {
pub system_identity_data: SystemIdentityData,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I find it quite confusing, the meaning of private_key_path is different depending on system_identity_data, no?

in one case is where to read the key, in the other is where to store it I guess

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, exactly! In both cases it is the path were the private-key is expected to be (it could be because it was already there or because it needs to be created there)

SystemIdentityData::Existing { auth_client_id } => auth_client_id.to_string(),
SystemIdentityData::Provision(provisioning_method) => {
let pub_key = public_key_from_key_pair(identity_spec.private_key_path.clone())?;
provide_identity_fn(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

provide_identity_fn as a name is still a bit confusing, no? this creates the identity

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 agree, create_identity_fn would better, right?

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 just renamed it. LTMKYT

let client_id = match &identity_spec.system_identity_data {
SystemIdentityData::Existing { auth_client_id } => auth_client_id.to_string(),
SystemIdentityData::Provision(provisioning_method) => {
let pub_key = public_key_from_key_pair(identity_spec.private_key_path.clone())?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also this is quite confusing, it seems that "from_key_pair" is retrieving a pub_key from the keypair, but it is actually generating it in that path!

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.

Do you have any better name suggestion for the function name?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe a two-step call can clarify? Like create_key_pair(identity_spec.private_key_path.clone())?.get_pub_key().

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also this is probably too much but perhaps the identity structure or data can reside in the FleetControl type, which might allow to reuse some of the data.

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 can also completely get rid of the helper, we don't have a create_key_pair function because the key generator implementation (From nr-auth) returns the public-key only

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 finally ditched the helper, it was causing confusion so it wasn't helping that much 6a02f74

let SystemIdentityData::Provision(provisioning_method) = &spec.identity.system_identity_data
else {
return Err(K8sCliError::Generic(
"the k8s cli requires provisioning a new System Identity; use --auth-parent-token or --auth-parent-client-secret instead of --auth-client-id"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO the message is a bit confusing, I think that the reason is that we are allowing an argument that is not actually allowed 😅 Shouldn't we avoid to have that enum variant for k8s?

Copy link
Copy Markdown
Contributor Author

@sigilioso sigilioso Apr 9, 2026

Choose a reason for hiding this comment

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

We already had this issue before but now it is more evident. I wanted to use the same arguments we already had in the on-host cli, but maybe it doesn't worth it.

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 can try to break the types a little bit. WDYT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes I think it would be better unless there is a ton of code duplication

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 think it is better now 5c44470, let me know your thoughts

})]
#[case::parent_secret(|| SystemIdentityArgs {
auth_private_key_path: Some(PathBuf::from("/some/path")),
#[case::parent_secret(|| ProvisionIdentityArgs {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why this closure and not the value directly?

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.

It is a leftover! Thanks!

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.

Fixed! 6a02f74

let client_id = match &identity_spec.system_identity_data {
SystemIdentityData::Existing { auth_client_id } => auth_client_id.to_string(),
SystemIdentityData::Provision(provisioning_method) => {
let pub_key = public_key_from_key_pair(identity_spec.private_key_path.clone())?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe a two-step call can clarify? Like create_key_pair(identity_spec.private_key_path.clone())?.get_pub_key().

let client_id = match &identity_spec.system_identity_data {
SystemIdentityData::Existing { auth_client_id } => auth_client_id.to_string(),
SystemIdentityData::Provision(provisioning_method) => {
let pub_key = public_key_from_key_pair(identity_spec.private_key_path.clone())?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also this is probably too much but perhaps the identity structure or data can reside in the FleetControl type, which might allow to reuse some of the data.

@sigilioso sigilioso requested a review from DavSanchez April 10, 2026 11:47
@sigilioso sigilioso force-pushed the feat/k8s-cli-system-identity branch from c51a3c8 to 8e82dca Compare April 13, 2026 09:18
@sigilioso sigilioso force-pushed the chore/bump-nr-auth-040 branch from d6a634d to cee90f1 Compare April 13, 2026 09:19
Comment thread agent-control/src/cli/common/system_identity.rs Outdated
Comment thread agent-control/src/cli/common/system_identity.rs Outdated
let result = system_identity_generator
.generate(&auth_credential)
let result = iam_client
.create_l2_system_identity(&auth_credentials, &pub_key)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice decoupling!!!

Comment thread agent-control/src/cli/on_host/config_gen.rs Outdated
Comment thread agent-control/src/cli/on_host/config_gen.rs Outdated
Comment thread agent-control/src/cli/on_host/config_gen.rs Outdated
Copy link
Copy Markdown
Contributor

@gsanchezgavier gsanchezgavier left a comment

Choose a reason for hiding this comment

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

Looks good thanks

identity_input: &SystemIdentitySpec,
/// Creates a key-based identity considering the supplied args. It returns the corresponding **client_id** as a String.
pub fn create_identity(
method: &ProvisioningMethod,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: parent_auth: ParentAuth ?

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 here: 98148db

parent_auth_method: ParentAuthMethod

Comment thread agent-control/src/cli/on_host/config_gen.rs
@sigilioso sigilioso merged commit f109f9f into feat/k8s-cli-system-identity Apr 13, 2026
47 of 50 checks passed
@sigilioso sigilioso deleted the chore/bump-nr-auth-040 branch April 13, 2026 15:36
sigilioso added a commit that referenced this pull request Apr 13, 2026
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.

5 participants