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(webhook): Handle nil in mutation webhooks #62

Merged
merged 2 commits into from
Apr 18, 2022

Conversation

irvinlim
Copy link
Member

@irvinlim irvinlim commented Apr 17, 2022

Fixes #59.

  • Extract JobPatcher and JobConfigPatcher from Mutator. There are many hidden assumptions in the MutateX methods, as we have seen that not only does it make the tests brittle, it also does not fully catch edge cases that may fall through the cracks.
  • The Patcher types will simply just compose multiple MutateX methods in the desired order, and we will write tests based on the Operation and objects to be patched.
  • Other fixes:
    • PodTemplateSpec should only add RestartPolicy on Job creates/updates, not JobConfig.
    • Handle nil for JobTemplate to add MaxAttempts.

@irvinlim irvinlim added kind/bug Categorizes issue or PR as related to a bug. component/execution Issues or PRs related exclusively to the Execution component (Job, JobConfig) area/webhooks Related to validating and mutating admission webhooks. labels Apr 17, 2022
@codecov
Copy link

codecov bot commented Apr 17, 2022

Codecov Report

Merging #62 (984881e) into main (3e93e53) will decrease coverage by 0.09%.
The diff coverage is 39.13%.

@@            Coverage Diff             @@
##             main      #62      +/-   ##
==========================================
- Coverage   61.15%   61.06%   -0.10%     
==========================================
  Files         166      168       +2     
  Lines        8406     8447      +41     
==========================================
+ Hits         5141     5158      +17     
- Misses       3024     3047      +23     
- Partials      241      242       +1     
Impacted Files Coverage Δ
pkg/execution/mutation/patcher_jobconfigs.go 0.00% <0.00%> (ø)
...ution/webhooks/jobconfigmutatingwebhook/webhook.go 0.00% <0.00%> (ø)
...g/execution/webhooks/jobmutatingwebhook/webhook.go 0.00% <0.00%> (ø)
pkg/execution/mutation/patcher_jobs.go 65.00% <65.00%> (ø)
pkg/execution/mutation/mutation.go 88.02% <87.50%> (-1.17%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e93e53...984881e. Read the comment docs.

@irvinlim irvinlim merged commit f2af3e2 into main Apr 18, 2022
@irvinlim irvinlim deleted the irvinlim/fix/mutate-nil branch April 18, 2022 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/webhooks Related to validating and mutating admission webhooks. component/execution Issues or PRs related exclusively to the Execution component (Job, JobConfig) kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JobMutationWebhook nil pointer crash
1 participant