Skip to content

fix debian can not use in v4 and version check and clean process#3093

Open
zbb88888 wants to merge 6 commits intokubesphere:mainfrom
zbb88888:dev
Open

fix debian can not use in v4 and version check and clean process#3093
zbb88888 wants to merge 6 commits intokubesphere:mainfrom
zbb88888:dev

Conversation

@zbb88888
Copy link
Copy Markdown

@zbb88888 zbb88888 commented Apr 28, 2026

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

  • debian can not use in v4x
  • delete cluster but not clean
  • version check problems
  • support make build-kk-dev in local env in development process which is useful
  • files in /etc/kubekey/scripts in not neccessary when kk create cluster, which will block creation process

Special notes for reviewers:

Does this PR introduced a user-facing change?


Additional documentation, usage docs, etc.:


@kubesphere-prow
Copy link
Copy Markdown

This PR has multiple commits, and the default merge method is: squash.
You can request commits to be merged using the label: tide/merge-method-merge

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.

@kubesphere-prow
Copy link
Copy Markdown

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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.

@kubesphere-prow
Copy link
Copy Markdown

Welcome @zbb88888! It looks like this is your first PR to kubesphere/kubekey 🎉

@kubesphere-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zbb88888
Once this PR has been reviewed and has the lgtm label, please assign zuoxuesong-worker for approval. For more information see the Kubernetes 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

@kubesphere-prow kubesphere-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 28, 2026
@sonarqubecloud
Copy link
Copy Markdown

@zbb88888 zbb88888 changed the title Dev fix debian can not use in v4 and version check and clean process Apr 28, 2026
Copy link
Copy Markdown

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

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 adds support for Debian, implements etcd version alignment and downgrade prevention, and refines the execution of pre/post-installation scripts. It also introduces a development build target in the Makefile and adds cleanup steps for residual processes during uninstallation. Feedback highlights potential issues with process termination due to Linux's 15-character name truncation in ps output and suggests using immediate assignment for Makefile variables to avoid redundant script execution.

- name: Containerd | Terminate residual runtime shim processes
ignore_errors: true
command: |
ps -eo pid=,comm= | awk '$2 == "containerd-shim-runc-v2" || $2 == "containerd-shim" { print $1 }' | xargs -r kill -9
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

On Linux, the process name in ps -o comm is truncated to 15 characters. Consequently, containerd-shim-runc-v2 (22 characters) will appear as containerd-shim, and the exact match $2 == "containerd-shim-runc-v2" will fail. This means residual shim processes might not be terminated as intended. Using pgrep -f is a more reliable approach as it matches against the full command line.

    pgrep -f "containerd-shim" | xargs -r kill -9

- name: Docker | Terminate residual runtime shim processes
ignore_errors: true
command: |
ps -eo pid=,comm= | awk '$2 == "containerd-shim-runc-v2" || $2 == "containerd-shim" { print $1 }' | xargs -r kill -9
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The use of ps -o comm with an exact match for containerd-shim-runc-v2 will fail due to the 15-character truncation limit in the Linux kernel's task name. Residual processes will not be killed. It is better to use pgrep -f to match the process by its full command line.

        pgrep -f "containerd-shim" | xargs -r kill -9

- name: DockerCompose | Terminate residual runtime shim processes
ignore_errors: true
command: |
ps -eo pid=,comm= | awk '$2 == "containerd-shim-runc-v2" || $2 == "containerd-shim" { print $1 }' | xargs -r kill -9
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The exact match for containerd-shim-runc-v2 in the awk filter will fail because ps -o comm truncates process names to 15 characters. This prevents the termination of residual shim processes. Using pgrep -f is recommended.

        pgrep -f "containerd-shim" | xargs -r kill -9

- name: Kubernetes | Terminate residual control plane and kubelet processes
ignore_errors: true
command: |
ps -eo pid=,comm= | awk '$2 == "kube-apiserver" || $2 == "kube-controller-manager" || $2 == "kube-scheduler" || $2 == "kubelet" { print $1 }' | xargs -r kill -9
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Process names longer than 15 characters, such as kube-controller-manager, are truncated in the ps -o comm output. The current awk filter uses exact matches that will fail for these processes, leaving them running after uninstallation. Using pgrep -f with a regex pattern is a more robust solution.

    pgrep -f "kube-apiserver|kube-controller-manager|kube-scheduler|kubelet" | xargs -r kill -9

Comment thread Makefile

# Set build time variables including version details
LDFLAGS := $(shell hack/version.sh)
LDFLAGS = $(shell hack/version.sh)
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

Changing LDFLAGS from immediate assignment (:=) to deferred assignment (=) causes the hack/version.sh script to be executed every time the variable is referenced. Since LDFLAGS is used in multiple targets (e.g., kk, docker-push-*), this adds unnecessary overhead to the build process. It is recommended to use := to ensure the version script runs only once.

LDFLAGS := $(shell hack/version.sh)

Comment thread Makefile
CURRENT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo dev)
SANITIZED_BRANCH ?= $(shell printf '%s' '$(CURRENT_BRANCH)' | sed -E 's/[^0-9A-Za-z.-]+/-/g; s/^-+//; s/-+$$//')
DEV_GIT_VERSION ?= v0.0.0-$(if $(SANITIZED_BRANCH),$(SANITIZED_BRANCH),dev)
DEV_LDFLAGS = $(shell GIT_VERSION=$(DEV_GIT_VERSION) hack/version.sh)
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

Similar to LDFLAGS, DEV_LDFLAGS should use immediate assignment (:=) to avoid redundant executions of the version script during a single make invocation.

DEV_LDFLAGS := $(shell GIT_VERSION=$(DEV_GIT_VERSION) hack/version.sh)

- name: Defaults | Normalize installed etcd version
set_fact:
etcd_installed_version: >-
{{- $versionOutput := .etcd_install_version.stdout | default "" | toYaml -}}
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.

etcd_install_version has been set to the YAML format via register_type on line 59.

hosts: all
vars:
etcd:
etcd_version: >-
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.

It is not recommended to override etcd.etcd_version here.
This field should preferably be defined by the user and passed in via config.yaml.
If the value is set through config.yaml or the --set parameter, it will not be overwritten.

systemctl daemon-reload
systemctl reset-failed containerd.service

- name: Docker | Terminate residual runtime shim processes
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.

This is an excellent change. In some scenarios, stopping containerd or docker does not terminate the container processes; it is necessary to stop containerd-shim.

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

Labels

do-not-merge/release-note-label-needed size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants