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: mutation: use generateName for generated resources when logging #2974

Merged

Conversation

acpana
Copy link
Contributor

@acpana acpana commented Aug 25, 2023

  • also log the source type.

fixes #2907

old logs

{"level":"info","ts":1692401098.0970972,"logger":"mutation","msg":"Mutation applied","process":"mutation","Mutation Id":"e0423b26-e8a2-4abf-9daf-81c16c8e7116","event_type":"mutation_applied","resource_group":"","resource_kind":"Pod","resource_api_version":"v1","resource_namespace":"default","resource_name":"","iteration_0":"Assign//always-pull-image:2"}

notice "" for resource_name

Using generateName

{"level":"info","ts":1692923248.9436867,"logger":"mutation","msg":"Mutation applied","process":"mutation","Mutation Id":"62517173-127b-4b61-ac45-ee96e482eeef","event_type":"mutation_applied","resource_group":"","resource_kind":"Pod","resource_api_version":"v1","resource_namespace":"default","resource_name":"nginx-deployment-cb78f6b8c-","resource_source_type":"Original","iteration_0":"Assign//always-pull-image:2"}

notice ""nginx-deployment-cb78f6b8c-" for resource_name which is best we can do on CREATE in the webhook I think.

Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
@acpana acpana requested a review from maxsmythe August 25, 2023 01:01
@acpana acpana changed the title fix, mutation: use generateName for generated resources when logging fix: mutation: use generateName for generated resources when logging Aug 25, 2023
@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2023

Codecov Report

Patch coverage: 58.82% and project coverage change: -0.07% ⚠️

Comparison is base (c86ddd2) 52.58% compared to head (17d0541) 52.52%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2974      +/-   ##
==========================================
- Coverage   52.58%   52.52%   -0.07%     
==========================================
  Files         134      134              
  Lines       11891    11901      +10     
==========================================
- Hits         6253     6251       -2     
- Misses       5148     5158      +10     
- Partials      490      492       +2     
Flag Coverage Δ
unittests 52.52% <58.82%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
pkg/logging/logging.go 100.00% <ø> (ø)
pkg/mutation/system.go 77.30% <40.00%> (ø)
pkg/mutation/logging.go 24.24% <66.66%> (+24.24%) ⬆️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

LGTM

@ritazh
Copy link
Member

ritazh commented Aug 30, 2023

Is this PR still in draft state?

@acpana acpana marked this pull request as ready for review August 30, 2023 16:06
@acpana
Copy link
Contributor Author

acpana commented Aug 30, 2023

@ritazh yes this can be reviewed now 🙏🏼

Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Copy link
Contributor

@JaydipGabani JaydipGabani left a comment

Choose a reason for hiding this comment

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

lgtm

@acpana acpana requested review from ritazh and sozercan August 30, 2023 23:01
@acpana
Copy link
Contributor Author

acpana commented Sep 6, 2023

@ritazh / @sozercan PTAL 🙏🏼

@acpana
Copy link
Contributor Author

acpana commented Sep 12, 2023

@ritazh / @sozercan PTAL 🙏🏼

hey @ritazh / @sozercan PTAL 🙏🏼

@ritazh
Copy link
Member

ritazh commented Sep 13, 2023

The change looks pretty good @acpana Thanks! No test to validate the change?

@acpana
Copy link
Contributor Author

acpana commented Sep 13, 2023

No test to validate the change?

hey @ritazh I added a blurb in the PR description about how the log lines looked after the change.

{"level":"info","ts":1692923248.9436867,"logger":"mutation","msg":"Mutation applied","process":"mutation","Mutation Id":"62517173-127b-4b61-ac45-ee96e482eeef","event_type":"mutation_applied","resource_group":"","resource_kind":"Pod","resource_api_version":"v1","resource_namespace":"default","resource_name":"nginx-deployment-cb78f6b8c-","resource_source_type":"Original","iteration_0":"Assign//always-pull-image:2"}

Was there a specific test you had in mind? Or is there prior art that I missed in GK for testing in this scenario?

@ritazh
Copy link
Member

ritazh commented Sep 13, 2023

No test to validate the change?

hey @ritazh I added a blurb in the PR description about how the log lines looked after the change.

{"level":"info","ts":1692923248.9436867,"logger":"mutation","msg":"Mutation applied","process":"mutation","Mutation Id":"62517173-127b-4b61-ac45-ee96e482eeef","event_type":"mutation_applied","resource_group":"","resource_kind":"Pod","resource_api_version":"v1","resource_namespace":"default","resource_name":"nginx-deployment-cb78f6b8c-","resource_source_type":"Original","iteration_0":"Assign//always-pull-image:2"}

Was there a specific test you had in mind? Or is there prior art that I missed in GK for testing in this scenario?

ah ok. I didnt realize we didnt have any tests for this.

Copy link
Member

@ritazh ritazh left a comment

Choose a reason for hiding this comment

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

LGTM

@ritazh ritazh merged commit 83ca660 into open-policy-agent:master Sep 13, 2023
15 checks passed
Mattes83 pushed a commit to Mattes83/gatekeeper that referenced this pull request Oct 25, 2023
open-policy-agent#2974)

Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
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.

Mutation applied log messages missing the resource name
6 participants