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

fix: remove unused informers #698

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

britaniar
Copy link
Contributor

@britaniar britaniar commented Feb 28, 2024

Description of your changes

Removed unused informers from the informer manager

Fixes #

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Special notes for your reviewer

pkg/utils/informer/informermanager.go Outdated Show resolved Hide resolved
pkg/utils/informer/informermanager.go Outdated Show resolved Hide resolved
@britaniar britaniar changed the title remove function for informers fix: remove function for informers Feb 29, 2024
@britaniar britaniar changed the title fix: remove function for informers fix: remove unused informers Feb 29, 2024
pkg/utils/informer/informermanager.go Show resolved Hide resolved
pkg/utils/informer/informermanager.go Outdated Show resolved Hide resolved
@britaniar britaniar force-pushed the removeUnusedInformers branch 3 times, most recently from 58404fa to d826166 Compare March 4, 2024 22:16
@britaniar britaniar marked this pull request as ready for review March 11, 2024 18:17
impl.AddDynamicResources([]APIResourceMeta{}, handler, true)

// verify the map. Check that the dynamic resource was removed from the informer manager
_, ok = impl.apiResources[dynResources[0].GroupVersionKind]
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to test more than if the imp has it, we don't need IT to test that.

@@ -1,17 +1,17 @@
module go.goms.io/fleet

go 1.20
go 1.21
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi Britania! Is this Go + deps version bump intentional?

Copy link
Contributor Author

@britaniar britaniar Mar 19, 2024

Choose a reason for hiding this comment

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

I updated the controller-runtime package I guess I updated the other as well with it.

@britaniar britaniar force-pushed the removeUnusedInformers branch 2 times, most recently from 0e9ca75 to 721e4f7 Compare March 20, 2024 01:41
Copy link
Contributor Author

@britaniar britaniar left a comment

Choose a reason for hiding this comment

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

We are trying out to switch from dynamic informer factory to informer cache to be able to remove unused informers. There is currently some errors that I have been running into.

Arvind helped me look into it further and some links that may be helpful:

  • there are no tests which test the case of adding dynamic resources in this file
  • This commit that shows it allows dynamic addition/removal of informers not the ability to add informers for dynamic resources

}
//if !r.InformerManager.IsInformerSynced(gvr) {
// return nil, controller.NewExpectedBehaviorError(fmt.Errorf("informer cache for %+v is not synced yet", gvr))
//}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to change to use GVK to be able to get the informer but GVK does not used in this function

if err != nil {
klog.V(2).ErrorS(err, "Could not get object of a disappeared resource", "res", dynRes)
}
err = s.cache.RemoveInformer(s.ctx, obj.(client.Object))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added RemoveInformer() function here.

if !exist {
newRes.isPresent = true
// TODO: how to add GVK to scheme?
Copy link
Contributor Author

@britaniar britaniar Mar 20, 2024

Choose a reason for hiding this comment

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

The old method (using dynamic informer factory) automatically added the dynamic resources to the scheme, but informer cache does not and adds only known types. Currently, running into an issue where the not how to add the dynamic resources to the scheme using only the GVK?

Current errors I see:
E0320 01:57:50.893982 1 informer/informermanager.go:148] "Failed to create informer for resource" err="no kind \"CloneSet\" is registered for version \"apps.kruise.io/v1alpha1\" in scheme \"pkg/runtime/scheme.go:100\"" gvk="apps.kruise.io/v1alpha1, Kind=CloneSet" err="no kind \"CloneSet\" is registered for version \"apps.kruise.io/v1alpha1\" in scheme \"pkg/runtime/scheme.go:100\"" E0320 01:57:50.894143 1 informer/informermanager.go:148] "Failed to create informer for resource" err="no kind \"VolumeSnapshot\" is registered for version \"snapshot.storage.k8s.io/v1\" in scheme \"pkg/runtime/scheme.go:100\"" gvk="snapshot.storage.k8s.io/v1, Kind=VolumeSnapshot" err="no kind \"VolumeSnapshot\" is registered for version \"snapshot.storage.k8s.io/v1\" in scheme \"pkg/runtime/scheme.go:100\"" E0320 01:57:50.894305 1 informer/informermanager.go:148] "Failed to create informer for resource" err="no kind \"VolumeSnapshotContent\" is registered for version \"snapshot.storage.k8s.io/v1\" in scheme \"pkg/runtime/scheme.go:100\"" gvk="snapshot.storage.k8s.io/v1, Kind=VolumeSnapshotContent" err="no kind \"VolumeSnapshotContent\" is registered for version \"snapshot.storage.k8s.io/v1\" in scheme \"pkg/runtime/scheme.go:100\"" E0320 01:57:50.894578 1 informer/informermanager.go:148] "Failed to create informer for resource" err="no kind \"VolumeSnapshotClass\" is registered for version \"snapshot.storage.k8s.io/v1\" in scheme \"pkg/runtime/scheme.go:100\"" gvk="snapshot.storage.k8s.io/v1, Kind=VolumeSnapshotClass" err="no kind \"VolumeSnapshotClass\" is registered for version \"snapshot.storage.k8s.io/v1\" in scheme \"pkg/runtime/scheme.go:100\""

@ryanzhang-oss ryanzhang-oss marked this pull request as draft September 3, 2024 23:06
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.

3 participants