Skip to content

Expose ServerInfo resource in tctl#34008

Merged
atburke merged 11 commits intomasterfrom
atburke/server-info-tctl
Nov 1, 2023
Merged

Expose ServerInfo resource in tctl#34008
atburke merged 11 commits intomasterfrom
atburke/server-info-tctl

Conversation

@atburke
Copy link
Copy Markdown
Contributor

@atburke atburke commented Oct 28, 2023

This change adds the ability for users to create ServerInfo resources with tctl.

In addition to matching a node by its AWS info, a ServerInfo can now match a node by its ID. For a node with name <name>, the ServerInfo that matches it should be named si-<name>. If both types of ServerInfo exist, the labels provided by both will be merged, with labels from the ID ServerInfo taking precedent if they conflict.

Resolves #31261.

Changelog: Exposed ServerInfo resource in tctl

@github-actions github-actions Bot added size/md tctl tctl - Teleport admin tool labels Oct 28, 2023
Comment thread api/types/server_info.go Outdated
Comment thread api/types/server_info.go Outdated
Comment thread lib/auth/server_info.go Outdated
if meta := node.GetCloudMetadata(); meta != nil && meta.AWS != nil {
names = append(names, types.ServerInfoNameFromAWS(meta.AWS.AccountID, meta.AWS.InstanceID))
}
// Manually added ServerInfos should override any other ServerInfos.
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.

I get the comment, but I don't get it in the context of this method. What manually added infos do we see here?

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.

I believe that "manually added ServerInfos" are the node-name-based ones. The AWS ones are created by the discovery process in lib/srv/server/ec2_watcher.go. Not sure where it is best to record this information in a comment - perhaps this could say:

// Node name based ServerInfos are manually added and override the AWS ServerInfos automatically
// added by discovery. Labels from ServerInfos later in the list will override the earlier ones.

or something like that perhaps.

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 removed the "manually added" language since the matching method is really the only thing that determines the order.

Comment thread lib/auth/server_info.go Outdated
Comment thread lib/auth/server_info.go Outdated
Comment thread tool/tctl/common/resource_command_test.go Outdated
Comment thread tool/tctl/common/resource_command_test.go Outdated
Comment thread tool/tctl/common/resource_command_test.go Outdated
Comment thread tool/tctl/common/resource_command_test.go Outdated
Comment thread tool/tctl/common/resource_command_test.go Outdated
Copy link
Copy Markdown
Contributor

@camscale camscale left a comment

Choose a reason for hiding this comment

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

Mostly just style comments that would make things a little clearer/cleaner IMHO

Comment thread lib/auth/server_info.go Outdated
Comment thread lib/auth/server_info_test.go Outdated
Comment thread lib/auth/server_info_test.go Outdated
Comment thread lib/services/resource.go Outdated
Comment thread tool/tctl/common/resource_command_test.go Outdated
Comment thread tool/tctl/common/resource_command_test.go Outdated
Comment thread tool/tctl/common/resource_command_test.go Outdated
Comment thread tool/tctl/common/resource_command_test.go
Comment thread lib/auth/server_info.go Outdated
if meta := node.GetCloudMetadata(); meta != nil && meta.AWS != nil {
names = append(names, types.ServerInfoNameFromAWS(meta.AWS.AccountID, meta.AWS.InstanceID))
}
// Manually added ServerInfos should override any other ServerInfos.
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.

I believe that "manually added ServerInfos" are the node-name-based ones. The AWS ones are created by the discovery process in lib/srv/server/ec2_watcher.go. Not sure where it is best to record this information in a comment - perhaps this could say:

// Node name based ServerInfos are manually added and override the AWS ServerInfos automatically
// added by discovery. Labels from ServerInfos later in the list will override the earlier ones.

or something like that perhaps.

Comment thread tool/tctl/common/resource_command.go Outdated
Comment thread tool/tctl/common/resource_command_test.go Outdated
@atburke atburke enabled auto-merge November 1, 2023 20:49
@atburke atburke added this pull request to the merge queue Nov 1, 2023
Merged via the queue into master with commit 584b466 Nov 1, 2023
@atburke atburke deleted the atburke/server-info-tctl branch November 1, 2023 21:18
@public-teleport-github-review-bot
Copy link
Copy Markdown

@atburke See the table below for backport results.

Branch Result
branch/v14 Failed

atburke added a commit that referenced this pull request Nov 2, 2023
* Add second server info type to reconciler

* Add server info tctl CRUD

* Fix parsing

* Add test

* Remove unused constant

* Fix EC2 server info names

* Extract server info names to functions

* Fix test

* Address comments

* Fix test

* Fix error message
github-merge-queue Bot pushed a commit that referenced this pull request Nov 14, 2023
* Add second server info type to reconciler

* Add server info tctl CRUD

* Fix parsing

* Add test

* Remove unused constant

* Fix EC2 server info names

* Extract server info names to functions

* Fix test

* Address comments

* Fix test

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

Labels

size/md tctl tctl - Teleport admin tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to create ServerInfo resources for users

3 participants