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

Fixed namespace checker to use the correct name #437

Merged
merged 4 commits into from
Jan 4, 2021
Merged

Fixed namespace checker to use the correct name #437

merged 4 commits into from
Jan 4, 2021

Conversation

hellozee
Copy link
Contributor

@hellozee hellozee commented Dec 8, 2020

ISSUE TYPE
  • Bug fix Pull Request
SUMMARY

Apparently the wrong member was used to check the resource name. I don't
know how resillient this patch is, but it works for most of the part.

Fixes #419

Fixes #419

Apparently the wrong member was used to check the resource name. I don't
know how resillient this patch is, but it works for most of the part.
@hellozee hellozee requested a review from PrasadG193 December 8, 2020 10:44
@@ -56,7 +56,8 @@ func (f NamespaceChecker) Run(object interface{}, event *events.Event) {
}
if botkubeConfig != nil {
for _, resource := range botkubeConfig.Resources {
if resource.Name == strings.ToLower(event.Kind) {
resourceName := strings.Split(strings.ToLower(event.Title), " ")[0]
if resource.Name == resourceName {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hellozee we have a helper function implemented which returns GVR from given Kind https://github.com/infracloudio/botkube/blob/develop/pkg/utils/utils.go#L258. We can use that method to build "group/version/resource" or "version/resource" (if the group is nil) check

Copy link
Contributor Author

@hellozee hellozee Dec 15, 2020

Choose a reason for hiding this comment

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

This is not working for delete events since the resource type return by that method is /. Here is how I am trying to do it.

var eventObj *coreV1.Event
err := utils.TransformIntoTypedObject(object.(*unstructured.Unstructured), &eventObj)
if err != nil {
    log.Errorf("Unable to transform object type: %v, into type: %v", reflect.TypeOf(object), reflect.TypeOf(eventObj))
    return
}
tempResourceName, _ := utils.GetResourceFromKind(eventObj.InvolvedObject.GroupVersionKind())
resourceName := utils.GVRToString(tempResourceName)

Also tbf this is not working for any events, though it might be my fault since the resource name is correct.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@hellozee let's do this

  1. Add a new field Resource in the Event struct
  2. Set the Resource value while creating New Event
  3. Refer event.Resource while building Title as well as in filters
    Sounds good?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, will do that instead, 🐱

Choose a reason for hiding this comment

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

@hellozee will you be able to implement the suggested changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh sorry, completely forgot about it, will do by this weekend, 😸

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hey @hellozee, please let me know if you are working on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops! expect a PR by evening for sure, 🙃

@PrasadG193 PrasadG193 added the release-blocker Upcoming release is blocked by this issue label Jan 4, 2021
@hellozee
Copy link
Contributor Author

hellozee commented Jan 4, 2021

Done, but this doesn't work in case of a delete event.

@PrasadG193
Copy link
Collaborator

@hellozee do you mind adding the e2e test for the namespace checker filter (https://github.com/infracloudio/botkube/blob/develop/test/e2e/filters/filters.go#L44)? I am fine if we address that as a separate task.
Please file an issue if you can't add that in this PR.
Thank you!

@hellozee
Copy link
Contributor Author

hellozee commented Jan 4, 2021

It would be better if someone else picks it. I cant promise anything this week, sorry. If no one picks it up this week, I would put up a patch next week, 🐱

@PrasadG193
Copy link
Collaborator

Sounds good @hellozee

@PrasadG193
Copy link
Collaborator

Filed #443 to track. Merging this PR

@mergify mergify bot merged commit 14c8c9d into kubeshop:develop Jan 4, 2021
@PrasadG193
Copy link
Collaborator

@hellozee this doesn't seem to be working. I've added a fix #449. PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-blocker Upcoming release is blocked by this issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Ignored namespace list gets ignored
3 participants