Skip to content

CNF-23380: Migrate away from deprecated ioutil#292

Open
sebrandon1 wants to merge 1 commit intoopenshift:mainfrom
sebrandon1:ioutil_deprecation
Open

CNF-23380: Migrate away from deprecated ioutil#292
sebrandon1 wants to merge 1 commit intoopenshift:mainfrom
sebrandon1:ioutil_deprecation

Conversation

@sebrandon1
Copy link
Copy Markdown
Member

@sebrandon1 sebrandon1 commented Nov 24, 2025

ioutil has been deprecated since Go 1.16: https://go.dev/doc/go1.16#ioutil

Tracking issue: redhat-best-practices-for-k8s/telco-bot#52

Summary by CodeRabbit

  • Chores
    • Replaced deprecated file/io helpers with current standard library equivalents.
    • Updated internal file-handling in tests and runtime to use modern APIs; no behavioral changes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 24, 2025

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5ae95fd4-0eb0-4296-9460-e68df9e09dc6

📥 Commits

Reviewing files that changed from the base of the PR and between 1d5fcdc and 969a042.

📒 Files selected for processing (3)
  • pkg/controller/cabundleinjector/starter.go
  • pkg/controller/servingcert/starter/starter.go
  • test/util/rotate.go

Walkthrough

Replace deprecated ioutil APIs with os equivalents across three files: switch ReadFile to os.ReadFile and TempFile to os.CreateTemp; remove unused io/ioutil imports and reorder imports. No functional or error-handling behavior changed. (50 words)

Changes

Ioutil → os replacements

Layer / File(s) Summary
Imports
pkg/controller/cabundleinjector/starter.go, pkg/controller/servingcert/starter/starter.go, test/util/rotate.go
Removed io/ioutil, added os, strings, time where applicable; adjusted import ordering.
File read API
pkg/controller/cabundleinjector/starter.go, pkg/controller/servingcert/starter/starter.go
Replaced ioutil.ReadFile(...) with os.ReadFile(...) for CA/intermediate cert reads; preserved existing error handling and processing.
Temp file API (tests)
test/util/rotate.go
Replaced ioutil.TempFile(...) with os.CreateTemp(...) for cert/key temp files; retained write/cleanup logic.
Manifest
go.mod
Indirect or minimal module metadata touch noted in diffs (no API surface changes).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 10 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Microshift Test Compatibility ⚠️ Warning Five new Ginkgo tests use ClusterOperator API (unavailable on MicroShift): refresh-CA, time-based-ca-rotation, forced-ca-rotation, and NetworkPolicy tests. No MicroShift protection found. Add [apigroup:config.openshift.io] to test names or add exutil.IsMicroShiftCluster() checks in test bodies to skip on MicroShift.
✅ Passed checks (10 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: migrating away from the deprecated ioutil package across three Go files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The PR does not modify any Ginkgo test names. It only replaces deprecated ioutil functions with os.* equivalents in three files. The check is not applicable to this PR.
Test Structure And Quality ✅ Passed Custom check for Ginkgo test code quality is not applicable. PR modifies only production code and test utilities, not Ginkgo test files. Repository uses standard testing package instead.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests are added. Changes are deprecation migrations only (ioutil→os/os.CreateTemp). test/util/rotate.go is a utility file with no test definitions. Check not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR contains only internal utility code changes replacing deprecated ioutil calls with modern Go stdlib functions. No scheduling constraints or topology-related changes are introduced.
Ote Binary Stdout Contract ✅ Passed PR contains only mechanical migrations from deprecated ioutil to os package equivalents. No new stdout writes in process-level code introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR does not add Ginkgo e2e tests. It migrates away from deprecated ioutil. The new test/e2e/e2e_test.go uses standard Go testing (testing.T), not Ginkgo. Custom check not applicable.

✏️ 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.

@xingxingxia
Copy link
Copy Markdown

@sebrandon1 @coderabbitai

err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
has one ioutil.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 25, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the specific file mentioned by the user
echo "=== Examining pkg/operator/v4_00_assets/bindata.go ==="
cat pkg/operator/v4_00_assets/bindata.go | head -20
echo ""
echo "=== Looking for ioutil usage around line 614 ==="
sed -n '610,620p' pkg/operator/v4_00_assets/bindata.go

echo ""
echo "=== Searching for all remaining ioutil usages in the codebase ==="
rg -n 'ioutil\.' --type=go

echo ""
echo "=== Checking if bindata.go is a generated file ==="
head -5 pkg/operator/v4_00_assets/bindata.go

Length of output: 1466


@xingxingxia @sebrandon1 Good catch! I've verified that pkg/operator/v4_00_assets/bindata.go line 614 does indeed contain a remaining ioutil.WriteFile usage (and an io/ioutil import on line 15). This is actually the only remaining ioutil usage in the entire codebase.

However, this file is a generated file created by go-bindata, as indicated by the header comment:

// Code generated for package v4_00_assets by go-bindata DO NOT EDIT. (@generated)

To address this ioutil usage, you'll need to:

  1. Regenerate the bindata file using the go-bindata tool (or its replacement) with updated code that uses os.WriteFile instead of ioutil.WriteFile
  2. Check if you're using an older version of go-bindata that still generates ioutil calls, and update to a newer version if available
  3. Alternatively, consider migrating to a more modern alternative like go:embed (introduced in Go 1.16) if feasible for your use case

Would you like me to help investigate the bindata generation process or search for the command/script that generates this file?

@sebrandon1
Copy link
Copy Markdown
Member Author

Yes, this is bindata so I didn't edit that file.

@xingxingxia
Copy link
Copy Markdown

Maybe it needs regenerated to be updated?

@sebrandon1
Copy link
Copy Markdown
Member Author

I think that's a good plan. I wonder if that should be a separate PR because regenerating might encompass more changes than just ioutil.

@sebrandon1
Copy link
Copy Markdown
Member Author

/retest

@sebrandon1 sebrandon1 changed the title Migrate away from deprecated ioutil CNF-23380: Migrate away from deprecated ioutil Apr 30, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 30, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Apr 30, 2026

@sebrandon1: This pull request references CNF-23380 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

ioutil has been deprecated since Go 1.16: https://go.dev/doc/go1.16#ioutil

Tracking issue: redhat-best-practices-for-k8s/telco-bot#52

Summary by CodeRabbit

  • Chores
  • Upgraded internal code to use current standard library versions.

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.

@sebrandon1 sebrandon1 force-pushed the ioutil_deprecation branch from 1d5fcdc to 969a042 Compare May 5, 2026 22:35
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 5, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ingvagabund for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 6, 2026

@sebrandon1: all tests passed!

Full PR test history. Your PR dashboard.

Details

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.

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants