Skip to content

Introduce inventory service counts.#25755

Merged
mdwn merged 5 commits intomasterfrom
mike.wilson/inventory-service-counts
May 9, 2023
Merged

Introduce inventory service counts.#25755
mdwn merged 5 commits intomasterfrom
mike.wilson/inventory-service-counts

Conversation

@mdwn
Copy link
Copy Markdown
Contributor

@mdwn mdwn commented May 6, 2023

Inventory service counts have been introduced. These will be useful when trying to conditionally act on the presence of a particular service in a Teleport cluster. In particular, these will be used to disable Okta's access request reconciler when there are no Okta services connected to the cluster.

@mdwn mdwn requested a review from fspmarshall May 6, 2023 01:37
Copy link
Copy Markdown
Contributor

@fspmarshall fspmarshall left a comment

Choose a reason for hiding this comment

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

LGTM overall. I suggest altering the naming of public methods/types to ConnectedServiceCounts (or similar). This doesn't tell us the total inventory counts, just the counts of instances connected to a given auth server. Very important distinction for most use cases.

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.

Could we also expose some sort of notification mechanism that triggers whenever some counts go from zero to non-zero and viceversa? I imagine it could be useful for other components in the auth server that depend on some agent to be connected but don't necessarily care about the exact number.

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.

Discussed a bit of this offline. This is useful but may not be immediately useful for the Okta service use case.

Comment thread lib/inventory/servicecounter.go
}

// counts returns the count of each service seen in the counter.
func (s *serviceCounter) counts() map[types.SystemRole]uint64 {
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.

Is it worth it to add a dedicated function to fetch the count for a single role?

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 was waffling about that. It makes sense, but it's also not a huge deal to just query the map. I'm ambivalent, I think. If you feel strongly I can add one.

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 just realized that serviceCounter has a get method that does that already (although it could be made to not actually add to the map if there's no need for it).

I wouldn't bother with wiring it up for the gRPC service (making a map is nothing compared to the overhead of protobuf encoding and network transmission, and saving like 5 strings and integers worth of data is kinda useless) but it might be useful as an exposed ConnectedServiceCount(types.SystemRole) method in Controller. The first usecase for this, after all, is going to be about checking if there's any Okta agents connected, and we won't care about any other count.

Comment thread api/proto/teleport/legacy/client/proto/authservice.proto Outdated
Comment thread lib/inventory/servicecounter.go Outdated
Mike Wilson added 2 commits May 8, 2023 09:20
Inventory service counts have been introduced. These will be useful when
trying to conditionally act on the presence of a particular service in a
Teleport cluster. In particular, these will be used to disable Okta's
access request reconciler when there are no Okta services connected to the
cluster.
@mdwn mdwn force-pushed the mike.wilson/inventory-service-counts branch from ffd6864 to 3391cb5 Compare May 8, 2023 13:34
@mdwn mdwn marked this pull request as ready for review May 8, 2023 13:59
@github-actions github-actions Bot requested review from jakule and xacrimon May 8, 2023 14:00
@mdwn mdwn removed request for jakule and xacrimon May 8, 2023 15:13
Comment thread lib/auth/auth_with_roles.go Outdated
}

// counts returns the count of each service seen in the counter.
func (s *serviceCounter) counts() map[types.SystemRole]uint64 {
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 just realized that serviceCounter has a get method that does that already (although it could be made to not actually add to the map if there's no need for it).

I wouldn't bother with wiring it up for the gRPC service (making a map is nothing compared to the overhead of protobuf encoding and network transmission, and saving like 5 strings and integers worth of data is kinda useless) but it might be useful as an exposed ConnectedServiceCount(types.SystemRole) method in Controller. The first usecase for this, after all, is going to be about checking if there's any Okta agents connected, and we won't care about any other count.

… don't populate the underlying map on read.
@mdwn mdwn enabled auto-merge May 9, 2023 17:49
@mdwn mdwn added this pull request to the merge queue May 9, 2023
Merged via the queue into master with commit 11fe042 May 9, 2023
@mdwn mdwn deleted the mike.wilson/inventory-service-counts branch May 9, 2023 18:42
@public-teleport-github-review-bot
Copy link
Copy Markdown

@mdwn See the table below for backport results.

Branch Result
branch/v12 Failed
branch/v13 Create PR

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants