Skip to content

Conversation

@liouk
Copy link
Member

@liouk liouk commented Oct 16, 2025

The create subcommands of oc do not pass along the --dry-run option when used on the command-line. Therefore, the server-side dry run is ignored, and the resources get created.

The fix provided in openshift/openshift-apiserver#511 was necessary for image streams, but we also need wiring on the oc side.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 16, 2025
@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Oct 16, 2025
@openshift-ci-robot
Copy link

@liouk: This pull request references Jira Issue OCPBUGS-62875, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @wangke19

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

The create subcommands of oc do not pass along the --dry-run option when used on the command-line. Therefore, the server-side dry run is ignored, and the resources get created.

The fix provided in openshift/openshift-apiserver#511 was necessary for image streams, but we also need wiring on the oc side.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested a review from wangke19 October 16, 2025 14:27
@coderabbitai
Copy link

coderabbitai bot commented Oct 16, 2025

Walkthrough

This PR systematically replaces hardcoded empty metav1.CreateOptions{} arguments across 12 CLI create commands with dynamic options built from toCreateOptions() helper methods. Two new helper methods conditionally set the DryRun field based on the DryRunStrategy configuration.

Changes

Cohort / File(s) Summary
Helper Method Definitions
pkg/cli/create/create.go, pkg/cli/create/route.go
Added toCreateOptions() methods to CreateSubcommandOptions and CreateRouteSubcommandOptions respectively. Both methods construct metav1.CreateOptions instances and conditionally set DryRun to metav1.DryRunAll when DryRunStrategy is DryRunServer. Added metav1 import to create.go.
Build/Cluster/Deployment/Identity Commands
pkg/cli/create/build.go, pkg/cli/create/clusterquota.go, pkg/cli/create/deploymentconfig.go, pkg/cli/create/identity.go
Updated Create calls to use o.CreateSubcommandOptions.toCreateOptions() instead of static metav1.CreateOptions{}.
Image/User Commands
pkg/cli/create/imagestream.go, pkg/cli/create/imagestreamtag.go, pkg/cli/create/user.go, pkg/cli/create/user_identity_mapping.go
Updated Create calls to use o.CreateSubcommandOptions.toCreateOptions() instead of static metav1.CreateOptions{}.
Route Subcommand Variants
pkg/cli/create/routeedge.go, pkg/cli/create/routepassthrough.go, pkg/cli/create/routereenecrypt.go
Updated Create calls to use o.CreateRouteSubcommandOptions.toCreateOptions() instead of static metav1.CreateOptions{}. Removed metav1 imports (no longer directly needed).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

The review scope is broad (12 files affected), but the changes are highly homogeneous—the same refactoring pattern is applied consistently across multiple files. The new logic is straightforward (simple conditional assignment). The mechanical nature of replacing static options with dynamic method calls and the low behavioral impact keep complexity minimal. The main verification task is confirming consistency of the implementation across all callsites.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed The pull request description is directly related to the changeset. It explains the problem—that create subcommands do not pass the --dry-run option to the server, causing server-side dry-run behavior to be ignored—and identifies the solution as wiring on the oc client side. This matches exactly what the changes accomplish: adding toCreateOptions() methods and updating create API calls throughout multiple files to use dynamic options instead of static empty CreateOptions. The description provides meaningful context about the issue and references the corresponding server-side fix.
Title Check ✅ Passed The PR title "OCPBUGS-62875: Pass dry-run option to all create API calls" accurately describes the main objective of the changeset. The changes systematically add a toCreateOptions() method that builds a CreateOptions with the dry-run field conditionally set based on the DryRunStrategy, and then applies this to all create API calls across multiple files (build, clusterquota, deploymentconfig, identity, imagestream, imagestreamtag, route operations, user, and user_identity_mapping). The title is specific, concise, and clearly communicates the purpose of the PR without vague terminology or misleading information.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci bot requested review from atiratree and tchap October 16, 2025 14:28
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
pkg/cli/create/route.go (1)

126-133: Consider consolidating duplicate toCreateOptions() implementations.

This method duplicates the logic from CreateSubcommandOptions.toCreateOptions() in create.go (lines 68-75). Both helpers have identical implementations.

Consider one of these approaches:

Option 1: Make CreateRouteSubcommandOptions embed or reference CreateSubcommandOptions:

 type CreateRouteSubcommandOptions struct {
+	CreateSubcommandOptions *CreateSubcommandOptions
 	// PrintFlags holds options necessary for obtaining a printer
 	PrintFlags *genericclioptions.PrintFlags

Then delegate to the shared helper:

 func (o *CreateRouteSubcommandOptions) toCreateOptions() metav1.CreateOptions {
-	createOptions := metav1.CreateOptions{}
-	if o.DryRunStrategy == cmdutil.DryRunServer {
-		createOptions.DryRun = []string{metav1.DryRunAll}
-	}
-
-	return createOptions
+	return o.CreateSubcommandOptions.toCreateOptions()
 }

Option 2: Extract a standalone helper function that both can call:

func buildCreateOptions(dryRunStrategy cmdutil.DryRunStrategy) metav1.CreateOptions {
	createOptions := metav1.CreateOptions{}
	if dryRunStrategy == cmdutil.DryRunServer {
		createOptions.DryRun = []string{metav1.DryRunAll}
	}
	return createOptions
}

This reduces maintenance burden if the dry-run logic needs updating.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 672ff62 and b89c9f9.

📒 Files selected for processing (13)
  • pkg/cli/create/build.go (1 hunks)
  • pkg/cli/create/clusterquota.go (1 hunks)
  • pkg/cli/create/create.go (2 hunks)
  • pkg/cli/create/deploymentconfig.go (1 hunks)
  • pkg/cli/create/identity.go (1 hunks)
  • pkg/cli/create/imagestream.go (1 hunks)
  • pkg/cli/create/imagestreamtag.go (1 hunks)
  • pkg/cli/create/route.go (2 hunks)
  • pkg/cli/create/routeedge.go (1 hunks)
  • pkg/cli/create/routepassthrough.go (1 hunks)
  • pkg/cli/create/routereenecrypt.go (1 hunks)
  • pkg/cli/create/user.go (1 hunks)
  • pkg/cli/create/user_identity_mapping.go (1 hunks)
🔇 Additional comments (13)
pkg/cli/create/routeedge.go (1)

139-139: LGTM! Consistent application of the new options builder pattern.

The change correctly replaces the static metav1.CreateOptions{} with a dynamic call to o.CreateRouteSubcommandOptions.toCreateOptions(), aligning with the PR objective to pass dry-run options to the server. The existing DryRunClient check on line 138 is preserved, ensuring correct flow control.

pkg/cli/create/deploymentconfig.go (1)

114-114: LGTM! Correctly applies the dynamic options pattern.

The change appropriately replaces the literal metav1.CreateOptions{} with o.CreateSubcommandOptions.toCreateOptions(), enabling server-side dry-run behavior. The dry-run strategy check on line 112 remains intact, maintaining the expected control flow.

pkg/cli/create/imagestreamtag.go (1)

184-184: LGTM! Pattern applied correctly.

The replacement of metav1.CreateOptions{} with o.CreateSubcommandOptions.toCreateOptions() is consistent with the PR's objective to properly forward dry-run options to the API server. The existing dry-run handling on line 183 is preserved.

pkg/cli/create/identity.go (1)

115-115: LGTM! Change aligns with the PR objective.

The update correctly replaces the hardcoded metav1.CreateOptions{} with o.CreateSubcommandOptions.toCreateOptions(), ensuring that dry-run options are properly communicated to the server. The dry-run strategy check on line 113 remains unchanged.

pkg/cli/create/clusterquota.go (1)

140-140: LGTM! Consistent with the broader refactoring.

The change from metav1.CreateOptions{} to o.CreateSubcommandOptions.toCreateOptions() properly implements the pattern for forwarding dry-run options to the API server. The control flow with the dry-run check on line 138 is maintained.

pkg/cli/create/imagestream.go (1)

102-102: LGTM! Properly implements the options builder pattern.

The substitution of metav1.CreateOptions{} with o.CreateSubcommandOptions.toCreateOptions() correctly enables dynamic configuration of create options, particularly for dry-run behavior. The dry-run strategy check on line 100 is preserved.

pkg/cli/create/routepassthrough.go (1)

105-105: LGTM! Change is consistent with the refactoring pattern.

The replacement of metav1.CreateOptions{} with o.CreateRouteSubcommandOptions.toCreateOptions() follows the established pattern across the PR, ensuring dry-run options are passed to the API server. The dry-run check on line 104 remains intact.

pkg/cli/create/routereenecrypt.go (2)

154-154: LGTM! Pattern correctly applied.

The change from metav1.CreateOptions{} to o.CreateRouteSubcommandOptions.toCreateOptions() aligns with the PR's goal of forwarding dry-run options to the server. The dry-run strategy check on line 153 is preserved.


1-161: Implementation verified; add tests for dry-run forwarding.

All toCreateOptions() implementations are correctly in place:

  • CreateSubcommandOptions.toCreateOptions() at pkg/cli/create/create.go:68
  • CreateRouteSubcommandOptions.toCreateOptions() at pkg/cli/create/route.go:126

Both properly set DryRun: []string{metav1.DryRunAll} when DryRunStrategy == cmdutil.DryRunServer. All 11 create subcommands (routereenecrypt, routepassthrough, routeedge, user, user_identity_mapping, imagestreamtag, identity, deploymentconfig, clusterquota, build, imagestream) have been updated to use toCreateOptions() in their API calls.

However, no test files exist in pkg/cli/create/ to verify dry-run options are properly forwarded to the API server. Add tests to validate this behavior.

pkg/cli/create/user.go (1)

110-110: LGTM!

The Create call now correctly uses dynamic CreateOptions from toCreateOptions(), enabling server-side dry-run when --dry-run=server is specified.

pkg/cli/create/create.go (1)

68-75: LGTM!

The helper correctly builds CreateOptions with DryRun set to metav1.DryRunAll when DryRunStrategy is DryRunServer, enabling server-side dry-run validation without creating resources.

pkg/cli/create/build.go (1)

222-222: LGTM!

The Create call now uses dynamic CreateOptions, consistent with the PR objectives to pass --dry-run to the server.

pkg/cli/create/user_identity_mapping.go (1)

134-134: LGTM!

The Create call correctly uses dynamic CreateOptions from the helper method.

@ardaguclu
Copy link
Member

Overall idea sounds good to me. Nice catch!

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 16, 2025

@liouk: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-scos-e2e-aws-ovn b89c9f9 link false /test okd-scos-e2e-aws-ovn

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@tchap
Copy link
Contributor

tchap commented Oct 20, 2025

Would be nice to somehow test this, not sure how much extra work that would be.

@liouk
Copy link
Member Author

liouk commented Oct 21, 2025

Would be nice to somehow test this, not sure how much extra work that would be.

@tchap I am currently writing some e2e tests in openshift/origin, I'll post an update here once I have a PR.

@liouk liouk changed the title WIP: OCPBUGS-62875: Pass dry-run option to all create API calls OCPBUGS-62875: Pass dry-run option to all create API calls Oct 21, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 21, 2025
@ardaguclu
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 21, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 21, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, liouk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 21, 2025
@liouk
Copy link
Member Author

liouk commented Oct 21, 2025

Before merging this, we must wait for openshift/origin#30403 to have a failed run of the newly introduced test, in order to prove the issue exists. Once that happens, I'll merge this and rerun that test to prove the fix.

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 21, 2025
@wangke19
Copy link

@wangke19
Copy link

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 21, 2025
@wangke19
Copy link

/verified by @wangke19

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Oct 21, 2025
@openshift-ci-robot
Copy link

@wangke19: This PR has been marked as verified by @wangke19.

In response to this:

/verified by @wangke19

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 4568a24 and 2 for PR HEAD b89c9f9 in total

@openshift-merge-bot openshift-merge-bot bot merged commit 9735e9b into openshift:main Oct 22, 2025
16 of 17 checks passed
@openshift-ci-robot
Copy link

@liouk: Jira Issue OCPBUGS-62875: Some pull requests linked via external trackers have merged:

The following pull request, linked via external tracker, has not merged:

All associated pull requests must be merged or unlinked from the Jira bug in order for it to move to the next state. Once unlinked, request a bug refresh with /jira refresh.

Jira Issue OCPBUGS-62875 has not been moved to the MODIFIED state.

This PR is marked as verified. If the remaining PRs listed above are marked as verified before merging, the issue will automatically be moved to VERIFIED after all of the changes from the PRs are available in an accepted nightly payload.

In response to this:

The create subcommands of oc do not pass along the --dry-run option when used on the command-line. Therefore, the server-side dry run is ignored, and the resources get created.

The fix provided in openshift/openshift-apiserver#511 was necessary for image streams, but we also need wiring on the oc side.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@wangke19
Copy link

/cherry-pick releasel-4.20

@openshift-cherrypick-robot

@wangke19: cannot checkout releasel-4.20: error checking out "releasel-4.20": exit status 1 error: pathspec 'releasel-4.20' did not match any file(s) known to git

In response to this:

/cherry-pick releasel-4.20

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@wangke19
Copy link

/cherry-pick release-4.20

@openshift-cherrypick-robot

@wangke19: new pull request created: #2121

In response to this:

/cherry-pick release-4.20

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants