Skip to content

CNF-23380: Migrate away from deprecated ioutil#292

Open
sebrandon1 wants to merge 1 commit into
openshift:mainfrom
sebrandon1:ioutil_deprecation
Open

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

Conversation

@sebrandon1

@sebrandon1 sebrandon1 commented Nov 24, 2025

Copy link
Copy Markdown
Member

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
    • Updated internal code to use current Go standard library functions, replacing deprecated APIs with their modern equivalents.

@coderabbitai

coderabbitai Bot commented Nov 24, 2025

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Replaces deprecated io/ioutil function calls with their os package equivalents: ioutil.ReadFileos.ReadFile in the serving cert starter, and ioutil.TempFileos.CreateTemp in the test rotate utility. Both io/ioutil imports are removed.

Changes

ioutil deprecation cleanup

Layer / File(s) Summary
Replace ioutil with os equivalents
pkg/controller/servingcert/starter/starter.go, test/util/rotate.go
Removes io/ioutil imports and substitutes os.ReadFile for ioutil.ReadFile in readIntermediateCACert, and os.CreateTemp for ioutil.TempFile in checkClientTrust (cert and key temp files). No behavioral changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 13 | ❌ 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 New Ginkgo e2e tests added in test/e2e/network_policy.go use ClusterOperator API (config.openshift.io/v1) without MicroShift protection or apigroup tags. Add [apigroup:config.openshift.io] tag to test names, or add [Skipped:MicroShift] label, or guard with exutil.IsMicroShiftCluster() check.
✅ Passed checks (13 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the PR: migrating away from the deprecated ioutil package, which is reflected in both files changed.
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 PR modifies non-Ginkgo code (production file and test utility helpers). No Ginkgo test definitions (It(), Describe(), Context(), When()) exist in modified files, so the stable test names check does...
Test Structure And Quality ✅ Passed PR modifies only production code (pkg/controller/servingcert/starter/starter.go) and test utility code (test/util/rotate.go), not Ginkgo test files themselves. The custom check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR does not add any new Ginkgo e2e tests; it only migrates deprecated ioutil calls to os package equivalents in utility and controller code.
Topology-Aware Scheduling Compatibility ✅ Passed PR only modernizes deprecated ioutil calls to os equivalents in utility functions; contains no deployment manifests, scheduling constraints, or topology-related code changes.
Ote Binary Stdout Contract ✅ Passed The PR only replaces deprecated ioutil functions with modern os equivalents (ioutil.ReadFile→os.ReadFile, ioutil.TempFile→os.CreateTemp). No stdout/stderr writes, logging configuration changes, or...
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR contains no new Ginkgo e2e tests; it only updates deprecated ioutil calls to standard library equivalents in non-test and utility code.
No-Weak-Crypto ✅ Passed PR migrates from deprecated ioutil to os package (os.ReadFile, os.CreateTemp). No weak crypto (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or insecure secret compariso...
Container-Privileges ✅ Passed PR modifies only Go source files for ioutil deprecation migration, not Kubernetes/container manifests. The container-privileges check is not applicable to this PR's scope.
No-Sensitive-Data-In-Logs ✅ Passed PR only replaces deprecated ioutil functions with os equivalents; no new logging added that exposes passwords, tokens, API keys, PII, session IDs, or sensitive data.

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

@xingxingxia

Copy link
Copy Markdown

@sebrandon1 @coderabbitai

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

@coderabbitai

coderabbitai Bot commented Nov 25, 2025

Copy link
Copy Markdown

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

openshift-ci-robot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

@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

openshift-ci Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

[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

@sebrandon1 sebrandon1 force-pushed the ioutil_deprecation branch from f8c8603 to fafa0d2 Compare June 30, 2026 21:46
@openshift-ci

openshift-ci Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

@sebrandon1: The following tests 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/e2e-aws-operator fafa0d2 link true /test e2e-aws-operator
ci/prow/e2e-aws fafa0d2 link true /test e2e-aws

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