Skip to content

fix: install local iso failed#3106

Merged
ks-ci-bot merged 1 commit into
kubesphere:mainfrom
redscholar:iso_install_failed
May 21, 2026
Merged

fix: install local iso failed#3106
ks-ci-bot merged 1 commit into
kubesphere:mainfrom
redscholar:iso_install_failed

Conversation

@redscholar

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR fixes two bugs in the offline repository installation logic that prevent KubeKey from using local ISO repositories on Debian/Ubuntu nodes.

  1. Fixes incorrect local ISO path check:
    In install_package.yaml, the condition [ -f "{{ .tmp_dir }}/iso" ] checks a mount directory using the -f (file) test, which always returns false. This causes the script to skip the local repository branch and fall back to public APT mirrors (archive.ubuntu.com), which are unreachable in offline/air-gapped environments. The condition is changed to [ -f "{{ .tmp_dir }}/repository.iso" ] to correctly detect the ISO file.

  2. Fixes mismatched backup/restore filenames:
    The backup step uses the suffix kubekey-$now.bak (timestamp before .bak), but the restore step incorrectly uses kubekey.bak-$now (timestamp after .bak). Because the filenames do not match, the original APT/YUM source configurations fail to restore after package installation.

Which issue(s) this PR fixes:

Fixes #

Special notes for reviewers:

Please verify that:
- In `builtin/core/roles/native/repository/tasks/install_package.yaml`, both the Debian and RHEL branches now use `repository.iso` for the local source detection.
- In `builtin/capkk/roles/init/init-os/tasks/init_repository.yaml`, the backup and restore filenames are now consistent for both APT and YUM flows.

Does this PR introduced a user-facing change?

Fixed a bug where offline nodes incorrectly attempted to connect to public Ubuntu repositories instead of using the local ISO repository, causing package installation to fail in air-gapped environments.

Additional documentation, usage docs, etc.:


Signed-off-by: redscholar <blacktiledhouse@gmail.com>
@kubesphere-prow kubesphere-prow Bot added release-note kind/bug Categorizes issue or PR as related to a bug. labels May 21, 2026
@kubesphere-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: redscholar

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

@kubesphere-prow kubesphere-prow Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 21, 2026
@redscholar redscholar added lgtm Indicates that a PR is ready to be merged. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 21, 2026
@sonarqubecloud

Copy link
Copy Markdown

@ks-ci-bot ks-ci-bot merged commit 25380f5 into kubesphere:main May 21, 2026
4 checks passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the backup file naming convention for repository files, renames the ISO file check to repository.iso, and refines the processing of OS version IDs in templates. Feedback was provided regarding the use of unquoted variables containing spaces in shell commands, which could lead to execution failures. Additionally, it was suggested to convert version IDs to lowercase for better consistency and compatibility with file naming conventions.

Comment thread builtin/capkk/roles/init/init-os/tasks/init_repository.yaml
Comment thread builtin/capkk/roles/init/init-os/tasks/init_repository.yaml
kylin-{{ .os.release.VERSION_ID | replace "\"" "" | unquote | trim | lower }}{{ .sp_version | trim }}
{{- else if .os.release.ID_LIKE | unquote | eq "rhel fedora" }}
{{ .os.release.ID | replace "\"" "" | unquote | trim | lower }}{{ .os.release.VERSION_ID | trim }}
{{ .os.release.ID | replace "\"" "" | unquote | trim | lower }}{{ .os.release.VERSION_ID | replace "\"" "" | unquote | trim }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For consistency with the Kylin implementation (line 26) and to ensure compatibility with lowercase filenames commonly used for ISO images, the VERSION_ID should be converted to lowercase. This also removes an unnecessary double space after the lower filter.

          {{ .os.release.ID | replace "\"" "" | unquote | trim | lower }}{{ .os.release.VERSION_ID | replace "\"" "" | unquote | trim | lower }}

{{ .os.release.ID | replace "\"" "" | unquote | trim | lower }}{{ .os.release.VERSION_ID | replace "\"" "" | unquote | trim }}
{{- else }}
{{ .os.release.ID | replace "\"" "" | unquote | trim | lower }}-{{ .os.release.VERSION_ID | trim }}
{{ .os.release.ID | replace "\"" "" | unquote | trim | lower }}-{{ .os.release.VERSION_ID | replace "\"" "" | unquote | trim }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The VERSION_ID should be converted to lowercase for consistency and to avoid potential mismatches with lowercase filenames.

          {{ .os.release.ID | replace "\"" "" | unquote | trim | lower }}-{{ .os.release.VERSION_ID | replace "\"" "" | unquote | trim | lower }}

@redscholar redscholar deleted the iso_install_failed branch May 21, 2026 06:26
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. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants