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

Generalize resource watchers #47561

Merged
merged 1 commit into from
Oct 28, 2024
Merged

Conversation

rosstimothy
Copy link
Contributor

Consolidate resource watchers into a single watcher that leverages generics. While most of the resource watchers were similar, some resources have some one off functionality. These watchers have not been touched, however, all that could be refactored to use the generic watcher easily were.

@rosstimothy rosstimothy added the no-changelog Indicates that a PR does not require a changelog entry label Oct 14, 2024
@rosstimothy rosstimothy force-pushed the tross/generic_resource_watcher branch 10 times, most recently from 47236c1 to 50a3ebb Compare October 21, 2024 18:35
@rosstimothy rosstimothy marked this pull request as ready for review October 21, 2024 19:12
@github-actions github-actions bot requested a review from greedy52 October 21, 2024 19:12
@rosstimothy rosstimothy force-pushed the tross/generic_resource_watcher branch from 50a3ebb to c26f411 Compare October 23, 2024 18:37
@rosstimothy
Copy link
Contributor Author

Friendly ping @fspmarshall @greedy52

Copy link
Contributor

@greedy52 greedy52 left a comment

Choose a reason for hiding this comment

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

LGTM.

Just one questino on the ReadOnlyXXX types, are they necessary? They do add some extra maintenance when updating these objects.

@rosstimothy
Copy link
Contributor Author

Just one questino on the ReadOnlyXXX types, are they necessary? They do add some extra maintenance when updating these objects.

I don't really like it either but I don't have many other good ideas. The intent is to try and thwart any modifications to resources during the filter+iteration provided by the resource watcher. Copies of the resources are only made if the filter matches to avoid excessive memory consumption, however, that means callers must be well behaved.

api/types/app.go Outdated Show resolved Hide resolved
lib/services/watcher.go Outdated Show resolved Hide resolved
@rosstimothy rosstimothy force-pushed the tross/generic_resource_watcher branch 2 times, most recently from 7f51dcd to ca70101 Compare October 28, 2024 18:14
Consolidate resource watchers into a single watcher that leverages
generics. While most of the resource watchers were similar, some
resources have some one off functionality. These watchers have not
been touched, however, all that could be refactored to use the
generic watcher easily were.
@rosstimothy rosstimothy force-pushed the tross/generic_resource_watcher branch from ca70101 to be13733 Compare October 28, 2024 18:32
@rosstimothy rosstimothy enabled auto-merge October 28, 2024 18:32
@rosstimothy rosstimothy added this pull request to the merge queue Oct 28, 2024
Merged via the queue into master with commit 24e8b68 Oct 28, 2024
40 checks passed
@rosstimothy rosstimothy deleted the tross/generic_resource_watcher branch October 28, 2024 19:14
@public-teleport-github-review-bot

@rosstimothy See the table below for backport results.

Branch Result
branch/v16 Failed
branch/v17 Create PR

rosstimothy added a commit that referenced this pull request Oct 31, 2024
#47561 incorrectly translated the logic on when to call the diff
function for resources. The previous logic only called the differ
_if_ the resource was not brand new, however, after the conversion
to the generic watcher the differ was always called.
rosstimothy added a commit that referenced this pull request Oct 31, 2024
#47561 incorrectly translated the logic on when to call the diff
function for resources. The previous logic only called the differ
_if_ the resource had already been seen before, which guaranteed
that both the old and new resource provided to the diff function
were not nil. However, after the conversion to the generic watcher
the diff function was called for new resources, resulting in a nil
value being provided for the old resource and caused a panic.
The previous behavior has been restored, and the ProxyWatcher test
has been updated to set a diff function to prevent regressions.
github-merge-queue bot pushed a commit that referenced this pull request Oct 31, 2024
#47561 incorrectly translated the logic on when to call the diff
function for resources. The previous logic only called the differ
_if_ the resource had already been seen before, which guaranteed
that both the old and new resource provided to the diff function
were not nil. However, after the conversion to the generic watcher
the diff function was called for new resources, resulting in a nil
value being provided for the old resource and caused a panic.
The previous behavior has been restored, and the ProxyWatcher test
has been updated to set a diff function to prevent regressions.
github-actions bot pushed a commit that referenced this pull request Oct 31, 2024
#47561 incorrectly translated the logic on when to call the diff
function for resources. The previous logic only called the differ
_if_ the resource had already been seen before, which guaranteed
that both the old and new resource provided to the diff function
were not nil. However, after the conversion to the generic watcher
the diff function was called for new resources, resulting in a nil
value being provided for the old resource and caused a panic.
The previous behavior has been restored, and the ProxyWatcher test
has been updated to set a diff function to prevent regressions.
github-merge-queue bot pushed a commit that referenced this pull request Oct 31, 2024
#47561 incorrectly translated the logic on when to call the diff
function for resources. The previous logic only called the differ
_if_ the resource had already been seen before, which guaranteed
that both the old and new resource provided to the diff function
were not nil. However, after the conversion to the generic watcher
the diff function was called for new resources, resulting in a nil
value being provided for the old resource and caused a panic.
The previous behavior has been restored, and the ProxyWatcher test
has been updated to set a diff function to prevent regressions.
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