Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DiscoveryConfigStatus: update even when no resource is found #50433

Merged
merged 5 commits into from
Jan 6, 2025

Conversation

marcoandredinis
Copy link
Contributor

@marcoandredinis marcoandredinis commented Dec 19, 2024

During Auto Discover, when using a DiscoveryConfig, if no resources are found, the DiscoveryConfigStatus is not updated accordingly.

This PR ensures that, even when no resources are found, the status will report so.

Demo:
image

There's also a fix for the EC2 flow where we could call ssm:SendCommand with 0 instances. This caused a bad reporting of the status.

@marcoandredinis marcoandredinis added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v17 labels Dec 19, 2024
@marcoandredinis marcoandredinis force-pushed the marco/fix_discoveryconfigstatus_nomatcher branch from 0b9f6d7 to a9ab5d1 Compare December 19, 2024 12:14
lib/utils/slices/slices.go Outdated Show resolved Hide resolved
lib/utils/slices/slices.go Outdated Show resolved Hide resolved
@marcoandredinis marcoandredinis force-pushed the marco/fix_discoveryconfigstatus_nomatcher branch 3 times, most recently from 730cad4 to 0ace00a Compare December 19, 2024 17:37
lib/utils/slices/slices.go Outdated Show resolved Hide resolved
lib/srv/discovery/database_watcher.go Outdated Show resolved Hide resolved
@marcoandredinis marcoandredinis force-pushed the marco/fix_discoveryconfigstatus_nomatcher branch 2 times, most recently from 74eed50 to 119ec30 Compare December 20, 2024 11:12
for _, t := range ts {
if s, include := fn(t); include {
ss = append(ss, s)
if _, ok := seen[s]; !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: so it's readable

Suggested change
if _, ok := seen[s]; !ok {
if _, seen := seen[s]; !seen {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This redefines the seen identifier to be a boolean, and then we can't access the seen map.

I'll change it to found:

if _, found := seen[s]; !found {
	seen[s] = struct{}{}
	ss = append(ss, s)
}

During Auto Discover, when using a DiscoveryConfig, if no resources are
found, the DiscoveryConfigStatus is not updated accordingly.

This PR ensures that, even when no resources are found, the status will
report so.
@marcoandredinis marcoandredinis force-pushed the marco/fix_discoveryconfigstatus_nomatcher branch from 119ec30 to 0316455 Compare January 6, 2025 10:32
@marcoandredinis marcoandredinis added this pull request to the merge queue Jan 6, 2025
Merged via the queue into master with commit b6ffcee Jan 6, 2025
41 checks passed
@marcoandredinis marcoandredinis deleted the marco/fix_discoveryconfigstatus_nomatcher branch January 6, 2025 11:11
@public-teleport-github-review-bot

@marcoandredinis See the table below for backport results.

Branch Result
branch/v17 Failed

marcoandredinis added a commit that referenced this pull request Jan 6, 2025
* DiscoveryConfigStatus: update even when no resource is found

During Auto Discover, when using a DiscoveryConfig, if no resources are
found, the DiscoveryConfigStatus is not updated accordingly.

This PR ensures that, even when no resources are found, the status will
report so.

* use comparable instead of any for generic method

* remove useless un-named function on PreFetchHooks

* prevent call to ssm:SendCommand with 0 instances

* rename var from ok to found
marcoandredinis added a commit that referenced this pull request Jan 6, 2025
* DiscoveryConfigStatus: update even when no resource is found

During Auto Discover, when using a DiscoveryConfig, if no resources are
found, the DiscoveryConfigStatus is not updated accordingly.

This PR ensures that, even when no resources are found, the status will
report so.

* use comparable instead of any for generic method

* remove useless un-named function on PreFetchHooks

* prevent call to ssm:SendCommand with 0 instances

* rename var from ok to found
marcoandredinis added a commit that referenced this pull request Jan 7, 2025
* DiscoveryConfigStatus: update even when no resource is found

During Auto Discover, when using a DiscoveryConfig, if no resources are
found, the DiscoveryConfigStatus is not updated accordingly.

This PR ensures that, even when no resources are found, the status will
report so.

* use comparable instead of any for generic method

* remove useless un-named function on PreFetchHooks

* prevent call to ssm:SendCommand with 0 instances

* rename var from ok to found
github-merge-queue bot pushed a commit that referenced this pull request Jan 7, 2025
…#50766)

* DiscoveryConfigStatus: update even when no resource is found

During Auto Discover, when using a DiscoveryConfig, if no resources are
found, the DiscoveryConfigStatus is not updated accordingly.

This PR ensures that, even when no resources are found, the status will
report so.

* use comparable instead of any for generic method

* remove useless un-named function on PreFetchHooks

* prevent call to ssm:SendCommand with 0 instances

* rename var from ok to found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v17 discovery 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.

3 participants