Skip to content

Do not use --force with --dry-run #633

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rafal-jan
Copy link

Closes #623.

Currently the same value of force parameter is passed when performing dry-run of a resource and actually creating it on the cluster. This causes issues when using Force=true with sync waves.

@rafal-jan rafal-jan force-pushed the no-force-on-dry-run branch from 5610c85 to b22663c Compare November 4, 2024 18:58
Copy link

sonarqubecloud bot commented Nov 4, 2024

@rafal-jan rafal-jan force-pushed the no-force-on-dry-run branch from b22663c to caa404a Compare June 6, 2025 17:24
@rafal-jan rafal-jan requested a review from a team as a code owner June 6, 2025 17:24
@rafal-jan rafal-jan force-pushed the no-force-on-dry-run branch 2 times, most recently from d2060c0 to 8d14c43 Compare June 6, 2025 17:47
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 53.52%. Comparing base (8849c3f) to head (c349708).
Report is 47 commits behind head on master.

Files with missing lines Patch % Lines
pkg/utils/kube/resource_ops.go 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #633      +/-   ##
==========================================
- Coverage   54.26%   53.52%   -0.74%     
==========================================
  Files          64       64              
  Lines        6164     6520     +356     
==========================================
+ Hits         3345     3490     +145     
- Misses       2549     2753     +204     
- Partials      270      277       +7     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@agaudreault agaudreault left a comment

Choose a reason for hiding this comment

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

Replace behavior is controlled by the options submitted to the package https://github.com/kubernetes/kubectl/blob/4d27286e9c49486b259d0e722b10a11dccfeb494/pkg/cmd/replace/replace.go#L253C1-L253C2

GitOps engine code should respect these options. It would seem like force and dryRun options are not properly configured when calling the Replace command.

What should be done is to update the newReplaceOptions to pass to the Run() method. We should set Force to false if DryRun is provided and we know that validate would throw an error. We should also call the validate method and return any error before calling the Run().

@rafal-jan rafal-jan force-pushed the no-force-on-dry-run branch from 8d14c43 to e4e8400 Compare June 10, 2025 16:04
Signed-off-by: rafal-jan <rafal7jan@gmail.com>
@rafal-jan rafal-jan force-pushed the no-force-on-dry-run branch from e4e8400 to c349708 Compare June 10, 2025 16:17
Copy link

@rafal-jan rafal-jan requested a review from agaudreault June 10, 2025 16:33
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.

Resources are created during dry-run when using Force=true,Replace=true sync options
2 participants