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

chore: carriedNamespace/carriesIgnoredNamespace account for Namespace object #1619

Merged
merged 6 commits into from
Jan 6, 2025

Conversation

cmwylie19
Copy link
Collaborator

@cmwylie19 cmwylie19 commented Jan 3, 2025

Description

CarriedNamespace did not account for Namespace objects which caused some strange behaviors in #1610

After Fix:

[14:20:13.943] DEBUG (44989): Ignoring Watch Callback: Object carries namespace 'pepr-demo-2' but ignored namespaces include '["pepr-demo-2"]'.

Related Issue

Fixes #1618

Relates to #

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other (security config, docs update, etc)

Checklist before merging

@cmwylie19 cmwylie19 requested a review from a team as a code owner January 3, 2025 19:26
Copy link

codecov bot commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.40%. Comparing base (1955962) to head (1bad7de).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1619      +/-   ##
==========================================
+ Coverage   81.31%   81.40%   +0.09%     
==========================================
  Files          43       43              
  Lines        1969     1979      +10     
  Branches      435      438       +3     
==========================================
+ Hits         1601     1611      +10     
  Misses        340      340              
  Partials       28       28              
Files with missing lines Coverage Δ
src/lib/filter/adjudicators/adjudicators.ts 98.57% <100.00%> (+0.10%) ⬆️
src/lib/filter/filter.ts 100.00% <100.00%> (ø)

@cmwylie19 cmwylie19 self-assigned this Jan 6, 2025
Copy link
Collaborator

@btlghrants btlghrants left a comment

Choose a reason for hiding this comment

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

Wait, but... Namespace objects don't "carry" namespaces -- they have no metadata.namespace prop, nor should they -- because they "are" namespaces. Namespaces shouldn't carry namespace props, right? So why would we want this method to present like they do?

Also, this edit makes the carriedNamespace() give back what carriedName() already gives back but only for Namespaces which is confusing, IMO. Why was this update needed, exactly?

@cmwylie19
Copy link
Collaborator Author

Wait, but... Namespace objects don't "carry" namespaces -- they have no metadata.namespace prop, nor should they -- because they "are" namespaces. Namespaces shouldn't carry namespace props, right? So why would we want this method to present like they do?

Also, this edit makes the carriedNamespace() give back what carriedName() already gives back but only for Namespaces which is confusing, IMO. Why was this update needed, exactly?

The reason this is need is due to the fact that if you are using alwaysIgnore.namespaces, then you should not execute any callback on anything in the namespace, including the namespace object. For instance, In the below binding I am ignoring the pepr-demo-2 namespace, however, the callback gets executed. Due to the currently implementation we are not ignoring the namespace that we should.

When(a.Namespace)
  .IsCreated()
  .WithName("pepr-demo-2")
  .Watch(async ns => {
    Log.info("Namespace pepr-demo-2 was created.");

RE- carriedName() - Yes- good callout - maybe we need to make carriedName check if the object is a namespace too and return the metadata.name

Copy link
Collaborator

@btlghrants btlghrants left a comment

Choose a reason for hiding this comment

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

Seems like the uncarryableNamespace() func would be a better place to put the new check -- this method lives one-level above the carriesNamespace and carriedNamespace methods & is the actual method responsible for using available information to give a final determination on whether a forbidden namespace is in use or not.

If we want to update our definition of what it means to "use a forbidden namespace" from only "has a forbidden metadata.namespace defined" and have it also include "or IS a Namespace with a forbidden name" then I think that would be the place.

@cmwylie19 cmwylie19 changed the title chore: carriedNamespace account for Namespace object chore: carriedNamespace/carriesIgnoredNamespace account for Namespace object Jan 6, 2025
Copy link
Collaborator

@btlghrants btlghrants left a comment

Choose a reason for hiding this comment

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

Yep, seems like that should do it.

@btlghrants btlghrants enabled auto-merge January 6, 2025 20:54
@btlghrants btlghrants added this pull request to the merge queue Jan 6, 2025
Merged via the queue into main with commit 36b87fe Jan 6, 2025
46 checks passed
@btlghrants btlghrants deleted the 1618 branch January 6, 2025 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

carriedNamespace does not account for the Namespace Kubernetes Object
2 participants