Skip to content

[OCPERT-343] [OCPERT-344] Preserve all imports during OTE migration, fix test/e2e subdirectory logic, and update documentation links#398

Merged
openshift-merge-bot[bot] merged 4 commits into
openshift-eng:mainfrom
ming1013:ote-migration-fixes
Apr 2, 2026
Merged

Conversation

@ming1013

@ming1013 ming1013 commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

This PR improves the OTE migration workflow with three key fixes:

  1. Preserve all existing imports during migration- Changed the test migration logic to preserve all existing imports (exutil, compat_otp, etc.) from source files rather than selectively adding/removing them. This ensures compatibility with the OTE framework and prevents import-related build failures.

  2. Fix test/e2e subdirectory prompt logic - Corrected the conditional logic so that the subdirectory name prompt only appears when test/e2e already exists in the repository. Previously, the variable initialization was outside the conditional block, causing potential issues in the workflow.

  3. Update documentation links - Replaced references to deleted local markdown files (skill-updates-summary.md, latest-skill-updates.md, OTE_PLUGIN_COMPLETE_DESIGN.md) with the canonical Confluence wiki link for the OTE migration plugin design documentation.

These changes make the migration workflow more robust and prevent import-related build failures during component repository migrations.

Which issue(s) this PR fixes:

Fixes: Incorrectly removed compat_otp imports in helper/utility Go files
Fixes: Unnecessary subdirectory prompts when test/e2e doesn't exist
Fixes: Broken documentation links in README

Special notes for your reviewer:

monorepo mode tested in: openshift/router#756
single-module mode tested in: openshift/router#757

Summary by CodeRabbit

  • Documentation
    • Added explicit required-import guidance and stronger import management; migration now preserves existing imports and adds testdata where needed.
    • Expanded migration to process all Go files and modernize CLI initialization patterns in tests.
    • Ensures test startup/cleanup behavior is correctly configured and preserves fixture file permissions during extraction.
    • Strengthened validation and dependency/verification steps for generated outputs.

@openshift-ci openshift-ci Bot requested review from dgoodwin and stleerh March 30, 2026 07:51
@coderabbitai

coderabbitai Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 553c82c4-2bdb-437f-b91b-1783eda5b1a3

📥 Commits

Reviewing files that changed from the base of the PR and between f3a4754 and 7e9226c.

📒 Files selected for processing (1)
  • plugins/ote-migration/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/ote-migration/README.md

Walkthrough

Documentation and migration workflow expanded: README clarifies automatic test migration and import preservation; SKILL.md adds required import guidance, dependency pinning and go-command flags, fixture permission fixes, broader .go file migration (including testdata imports), CLI initialization rewrites, and additional validation steps.

Changes

Cohort / File(s) Summary
README Documentation
plugins/ote-migration/README.md
Updated key features and automatic test migration wording to preserve existing imports and add testdata imports; removed the "Smart e2e framework import handling" bullet; modernized example CLI call to exutil.NewCLIWithoutNamespace(...); added explicit util.WithCleanup() guidance in examples/checklist.
Migration Workflow Guidance
plugins/ote-migration/skills/ote-migration-workflow/SKILL.md
Major expansion of phased workflow: require explicit main.go imports (exutil and compat_otp aliases), conditional monorepo prompt for TARGET_TEST_DIR_NAME, template-time grep verifications, pin ORIGIN_VERSION and specific OCI module versions, use GOSUMDB=off for go commands, wrap compat_otp.InitTest() with util.WithCleanup(...), add os.Chmod handling in fixtures, process all .go files for FixturePath replacements and add testdata imports, detect/replace compat_otp.NewCLI() with exutil.NewCLIWithoutNamespace() (and manage imports), and add extra validation/verification steps (including k8s.io/kms pseudo-version checks).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 8
✅ Passed checks (8 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the three main objectives of the PR: preserving imports, fixing test/e2e subdirectory logic, and updating documentation links, matching the changeset contents.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
No Real People Names In Style References ✅ Passed The pull request contains only placeholder names (john, jane, bob) in code examples demonstrating test naming conventions, not style references to real people.
No Assumed Git Remote Names ✅ Passed The pull request demonstrates proper git remote name discovery practices throughout the OTE migration workflow with all git operations using dynamically discovered remote names and no hardcoded remote names.
Git Push Safety Rules ✅ Passed Documentation changes only with no git push commands or force push variants found in affected files.
No Untrusted Mcp Servers ✅ Passed PR contains only documentation updates to OTE migration plugin without introducing any untrusted MCP server dependencies or npm package installations.
Ai-Helpers Overlap Detection ✅ Passed PR modifies only ote-migration plugin documentation and workflow files with no overlapping functionality detected in repository.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
plugins/ote-migration/skills/ote-migration-workflow/SKILL.md (1)

1112-1117: Consider documenting util.WithCleanup() pattern in README.

The added util.WithCleanup() call with empty function body is a clever workaround to set the testsStarted flag for OTP functions. However, this pattern is not mentioned in the README.md.

Suggestion:
Update README line 844 to mention this pattern:

- **Complete Framework Initialization (2026-02-14)** - Uses `util.InitStandardFlags()`, `framework.AfterReadingAllFlags()`, `compat_otp.InitTest()`, and `util.WithCleanup()` to properly initialize the kubernetes e2e framework context and set testsStarted flag for OTP functions

This would help users understand why this seemingly empty function call is necessary.

Also applies to: 1314-1319

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/ote-migration/skills/ote-migration-workflow/SKILL.md` around lines
1112 - 1117, Update the README entry around the framework initialization section
to document the util.WithCleanup() pattern: mention that alongside
util.InitStandardFlags(), framework.AfterReadingAllFlags(), and
compat_otp.InitTest(), callers should invoke util.WithCleanup() (even with an
empty callback) to set the internal testsStarted flag so OTP functions (e.g.,
oc.Run()/compat_otp behaviors) work correctly; add the suggested bullet text (or
equivalent) under the "Complete Framework Initialization" note to explain why
the empty call is necessary for kubernetes e2e framework context initialization.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugins/ote-migration/skills/ote-migration-workflow/SKILL.md`:
- Around line 3387-3391: Update the troubleshooting guidance to stop
recommending removal of util.WithCleanup() and keep the call that sets
testsStarted; specifically, ensure references to util.WithCleanup(func(){})
remain as the correct pattern and delete the contradicting "❌
`util.WithCleanup()` wrapper - OTE handles cleanup automatically" guidance so it
no longer advises removing util.WithCleanup; this aligns the docs with the
main.go template behavior where util.WithCleanup is used to set testsStarted =
true for OTP functions like oc.Run() to work.
- Around line 2041-2133: Step 3b conflicts with the README's preservation
promise by replacing compat_otp.NewCLI() with exutil.NewCLIWithoutNamespace();
update the README to either (A) change the preservation statement (e.g., the
line claiming "All existing imports ... are preserved as-is") to note that CLI
initialization calls are migrated, and update the examples that show
compat_otp.NewCLI() (references: README examples around lines 373, 385 and the
preservation line around 845) to use exutil.NewCLIWithoutNamespace(), or (B)
clarify the migration scope by adding a short note to Step 3b that this
replacement is intentional and applies to tests that would panic in OTE, and
ensure the step documents adding the exutil import and retaining compat_otp
helpers like By(); keep references to compat_otp.NewCLI and
exutil.NewCLIWithoutNamespace in the updated text so readers can find the
change.

---

Nitpick comments:
In `@plugins/ote-migration/skills/ote-migration-workflow/SKILL.md`:
- Around line 1112-1117: Update the README entry around the framework
initialization section to document the util.WithCleanup() pattern: mention that
alongside util.InitStandardFlags(), framework.AfterReadingAllFlags(), and
compat_otp.InitTest(), callers should invoke util.WithCleanup() (even with an
empty callback) to set the internal testsStarted flag so OTP functions (e.g.,
oc.Run()/compat_otp behaviors) work correctly; add the suggested bullet text (or
equivalent) under the "Complete Framework Initialization" note to explain why
the empty call is necessary for kubernetes e2e framework context initialization.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 93626a14-f8ab-405d-ad2a-08973a882f25

📥 Commits

Reviewing files that changed from the base of the PR and between b34767c and 306449a.

📒 Files selected for processing (2)
  • plugins/ote-migration/README.md
  • plugins/ote-migration/skills/ote-migration-workflow/SKILL.md

Comment thread plugins/ote-migration/skills/ote-migration-workflow/SKILL.md
Comment thread plugins/ote-migration/skills/ote-migration-workflow/SKILL.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
plugins/ote-migration/README.md (1)

48-48: ⚠️ Potential issue | 🟡 Minor

Clarify "preserve all existing imports" vs CLI initialization rewrite.

Line 48 states the workflow "preserves all existing imports," but this conflicts with:

  1. README line 385 shows compat_otp.NewCLI() in the "After migration" example
  2. SKILL.md Step 3b (lines 2041-2133) actively replaces compat_otp.NewCLI() with exutil.NewCLIWithoutNamespace()
  3. Past review comment flagged this exact inconsistency

The current wording implies imports remain untouched, but the workflow actively rewrites CLI initialization patterns. This is technically a function call modernization, not import preservation.

Suggestion: Update line 48 to clarify the scope:

-- **Automatic test migration** - Replaces FixturePath() calls, adds testdata imports, preserves all existing imports, and adds annotations atomically with rollback
+- **Automatic test migration** - Replaces FixturePath() calls, adds testdata imports, preserves import statements (though some function calls like CLI initialization are modernized for OTE compatibility), and adds annotations atomically with rollback

Or update the examples at lines 373, 385 to show exutil.NewCLIWithoutNamespace() instead of compat_otp.NewCLI() to match the actual post-migration behavior documented in SKILL.md.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/ote-migration/README.md` at line 48, Update the README statement that
claims "preserves all existing imports" to clarify that imports are preserved
except for intentional CLI initialization rewrites (e.g., compat_otp.NewCLI() ->
exutil.NewCLIWithoutNamespace()), or alternatively update the "After migration"
examples (lines showing compat_otp.NewCLI()) to use
exutil.NewCLIWithoutNamespace() so examples match SKILL.md Step 3b behavior;
locate references to compat_otp.NewCLI() and exutil.NewCLIWithoutNamespace() in
the README (examples around lines 373, 385) and SKILL.md Step 3b and either
change the phrasing at line 48 to mention CLI-call modernization or replace the
example CLI calls to reflect the actual migrated API.
plugins/ote-migration/skills/ote-migration-workflow/SKILL.md (1)

2041-2165: ⚠️ Potential issue | 🟡 Minor

CLI initialization rewrite is sound but contradicts README preservation claim.

The CLI initialization modernization (Step 3b, lines 2041-2125) and unused import cleanup (Step 3c, lines 2137-2158) are technically correct:

  • compat_otp.NewCLI() fails in OTE due to OTP-specific initialization (lines 2127-2132 explain why)
  • exutil.NewCLIWithoutNamespace() is the correct OTE pattern
  • The code properly adds/removes imports as needed

However: This directly contradicts README line 48 and 845 which claim imports are "preserved." The past review comment (lines 2041-2133) flagged this exact inconsistency.

The implementation is correct, but the documentation needs updating to reflect that CLI calls are modernized, not just preserved. See my earlier review comment on README.md line 48 for the suggested fix.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/ote-migration/skills/ote-migration-workflow/SKILL.md` around lines
2041 - 2165, Update the README entries that claim imports/CLI initialization are
"preserved" (referenced at README lines 48 and 845) to state that CLI
initialization has been modernized: replace wording to indicate
compat_otp.NewCLI calls are converted to exutil.NewCLIWithoutNamespace (as done
in SKILL.md Step 3b) and that exutil imports may be added/removed per Step 3c;
ensure the README mentions both the replacement of compat_otp.NewCLI and the
cleanup of unused exutil imports so the docs match the implemented changes.
🧹 Nitpick comments (1)
plugins/ote-migration/skills/ote-migration-workflow/SKILL.md (1)

772-779: Origin version pinning prevents breaking changes.

Pinning to a specific version (v1.5.0-alpha.3.0.20260310231025-5d3fd0545b5d) instead of using @main is a good practice to avoid unexpected breaking changes. The version is recent (March 10, 2026) relative to the PR date.

Consideration: This creates a maintenance point - the pinned version should be updated periodically to incorporate upstream fixes and improvements. Consider documenting when/how to update this version, or adding a comment with the last update date.

Also applies to: 904-911

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/ote-migration/skills/ote-migration-workflow/SKILL.md` around lines
772 - 779, The script pins ORIGIN_VERSION to a specific commit tag
(ORIGIN_VERSION="v1.5.0-alpha.3.0.20260310231025-5d3fd0545b5d") which is good,
but you should add a short maintenance comment and update guidance next to that
variable and the two go get invocations (the GOTOOLCHAIN=auto GOSUMDB=off go get
"github.com/openshift/origin@$ORIGIN_VERSION" lines) so future maintainers know
when/how to refresh the pin; add the last-updated date, a brief note to
periodically bump ORIGIN_VERSION (or link to a documented policy), and ensure
the same comment is added where the value is duplicated (also around the other
occurrence referenced in the review).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugins/ote-migration/README.md`:
- Line 845: The README claim that "All existing import statements ... are
preserved ... and never commented out or removed" is inaccurate because SKILL.md
Phase 5 actually adds exutil imports in Step 3b and removes unused exutil
imports in Step 3c; update the README text to reflect that imports are preserved
where possible but the migration will add missing imports (see Step 3b) and
remove unused ones (see Step 3c) to keep the code compiling, and rephrase the
sentence to accurately describe this add/remove behavior rather than stating
imports are never removed.

---

Duplicate comments:
In `@plugins/ote-migration/README.md`:
- Line 48: Update the README statement that claims "preserves all existing
imports" to clarify that imports are preserved except for intentional CLI
initialization rewrites (e.g., compat_otp.NewCLI() ->
exutil.NewCLIWithoutNamespace()), or alternatively update the "After migration"
examples (lines showing compat_otp.NewCLI()) to use
exutil.NewCLIWithoutNamespace() so examples match SKILL.md Step 3b behavior;
locate references to compat_otp.NewCLI() and exutil.NewCLIWithoutNamespace() in
the README (examples around lines 373, 385) and SKILL.md Step 3b and either
change the phrasing at line 48 to mention CLI-call modernization or replace the
example CLI calls to reflect the actual migrated API.

In `@plugins/ote-migration/skills/ote-migration-workflow/SKILL.md`:
- Around line 2041-2165: Update the README entries that claim imports/CLI
initialization are "preserved" (referenced at README lines 48 and 845) to state
that CLI initialization has been modernized: replace wording to indicate
compat_otp.NewCLI calls are converted to exutil.NewCLIWithoutNamespace (as done
in SKILL.md Step 3b) and that exutil imports may be added/removed per Step 3c;
ensure the README mentions both the replacement of compat_otp.NewCLI and the
cleanup of unused exutil imports so the docs match the implemented changes.

---

Nitpick comments:
In `@plugins/ote-migration/skills/ote-migration-workflow/SKILL.md`:
- Around line 772-779: The script pins ORIGIN_VERSION to a specific commit tag
(ORIGIN_VERSION="v1.5.0-alpha.3.0.20260310231025-5d3fd0545b5d") which is good,
but you should add a short maintenance comment and update guidance next to that
variable and the two go get invocations (the GOTOOLCHAIN=auto GOSUMDB=off go get
"github.com/openshift/origin@$ORIGIN_VERSION" lines) so future maintainers know
when/how to refresh the pin; add the last-updated date, a brief note to
periodically bump ORIGIN_VERSION (or link to a documented policy), and ensure
the same comment is added where the value is duplicated (also around the other
occurrence referenced in the review).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 09ec9c1c-b25f-43f4-be76-1d11b00e265e

📥 Commits

Reviewing files that changed from the base of the PR and between 306449a and 1f43114.

📒 Files selected for processing (2)
  • plugins/ote-migration/README.md
  • plugins/ote-migration/skills/ote-migration-workflow/SKILL.md

Comment thread plugins/ote-migration/README.md Outdated
Ming Li added 2 commits March 30, 2026 17:38
…e needed, cleaning up unused imports rather than simply preserved as-is.
…mework initialization rather than incorrectly claiming it's not needed.

@LuboTerifaj LuboTerifaj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

11. **Enhanced Dependency Management** - Added retry logic and better error handling for all `go get` commands
12. **Ginkgo Version Alignment** - Automatically aligns with OTE framework's Ginkgo version (December 2024) instead of using OTP's older version (August 2024)
13. **Old kube-openapi Pin Removal** - Automatically removes stale kube-openapi pins from February 2024 that cause yaml type errors
14. **Old kube-openapi Pin Removal** - Automatically removes stale kube-openapi pins from February 2024 that cause yaml type errors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 2, 2026
@openshift-ci

openshift-ci Bot commented Apr 2, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LuboTerifaj, ming1013

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

The pull request process is described here

Details 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 Apr 2, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit 234f3a4 into openshift-eng:main Apr 2, 2026
5 checks passed
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. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants