Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic arch and os selection for the deploy cni plugin #120312

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

HirazawaUi
Copy link
Contributor

@HirazawaUi HirazawaUi commented Aug 31, 2023

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Use local-up-cluster.sh on arm64 or other arch Linux to automatically download the cni binary of the corresponding arch.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

This change will not affect our CI, it will only facilitate local debug using local-up-cluster.sh

Does this PR introduce a user-facing change?

Add download the cni binary for the corresponding arch in local-up-cluster.sh

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 31, 2023
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 31, 2023
@HirazawaUi
Copy link
Contributor Author

/test pull-kubernetes-local-e2e

@pacoxu
Copy link
Member

pacoxu commented Sep 1, 2023

/sig node network
/kind cleanup
/cc @adisky @aojea

@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. sig/network Categorizes an issue or PR as relevant to SIG Network. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Sep 1, 2023
@danwinship
Copy link
Contributor

This is not really very sig-network. It's more sig-whoever-maintains-local-up-cluster.sh

@bart0sh bart0sh added this to Triage in SIG Node PR Triage Sep 2, 2023
;;
*)
echo "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x or ppc64le." >&2
exit 1
;;
esac

GO_OUT="${KUBE_ROOT}/_output/local/bin/${host_os}/${host_arch}"
GO_OUT="${KUBE_ROOT}/_output/local/bin/${HOST_OS}/${HOST_ARCH}"
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the point of this renaming? Even if HOST_ARCH and HOST_OS are initially set, this code would not be reached if host OS or arch are not detected.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to use host os and arch values you should consider returning them from this function instead of changing global variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the point of this renaming

The reason for setting HOST_ARCH and HOST_OS as global variables is that need to be referenced in the install_cni function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we want to pass variables using return values, how about the following?

+function detect_arch {
+    local host_arch
+
+    case "$(uname -m)" in
+      x86_64*)
+        host_arch=amd64
+        ;;
+      i?86_64*)
+        host_arch=amd64
+        ;;
+
+        ......
+
+    esac
+
+  echo -n "${host_arch}"
+}
+
+function detect_os {
+    local host_os
+
+    case "$(uname -s)" in
+      Darwin)
+        host_os=darwin
+        ;;
+
+      ......
+
+    esac
+
+  echo -n "${host_os}"
+}

function detect_binary {
+    host_arch=$(detect_arch)
+    host_os=$(detect_os)
-    case "$(uname -s)" in
-      Darwin)
-        host_os=darwin
-        ;;
-      Linux)
- 
-       ......
- 
-    esac
    GO_OUT="${KUBE_ROOT}/_output/local/bin/${host_os}/${host_arch}"
}

function install_cni {
+ host_arch=$(detect_arch)
+ cni_plugin_sha=CNI_PLUGINS_${host_arch^^}_SHA256SUM
+ cni_plugin_tarball="${CNI_PLUGINS_VERSION}/cni-plugins-linux-${host_arch}-${CNI_PLUGINS_VERSION}.tgz"
  ....
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks better to me, thanks.

CNI_PLUGINS_AMD64_SHA256SUM=${CNI_PLUGINS_AMD64_SHA256SUM:-"754a71ed60a4bd08726c3af705a7d55ee3df03122b12e389fdba4bea35d7dd7e"}
CNI_PLUGINS_ARM64_SHA256SUM=${CNI_PLUGINS_ARM64_SHA256SUM:-"86c4c866a01a8073ad14f6feec74de1fd63669786850c7be47521433f9570902"}
CNI_PLUGINS_ARM64_SHA256SUM=${CNI_PLUGINS_ARM64_SHA256SUM:-"de7a666fd6ad83a228086bd55756db62ef335a193d1b143d910b69f079e30598"}
Copy link
Contributor

Choose a reason for hiding this comment

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

providing checksums without any urls looks a bit unusual to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for not being clear enough. You've removed lines with urls and checksums started to look strange because of that. Updating checksums is ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all right

@bart0sh
Copy link
Contributor

bart0sh commented Sep 2, 2023

/triage accepted
@HirazawaUi This looks like a bugfix to me. Please, correct me if I'm wrong here or change this PR's kind.

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 2, 2023
@bart0sh bart0sh moved this from Triage to Needs Reviewer in SIG Node PR Triage Sep 2, 2023
@HirazawaUi
Copy link
Contributor Author

/triage accepted @HirazawaUi This looks like a bugfix to me. Please, correct me if I'm wrong here or change this PR's kind.

I think it's a cleanup, it helps us to be able to automate the installation of Arm64 or other arch cni binaries without modifying the local-up-cluster.sh script, but it also fixes an incorrect hash value.

@bart0sh
Copy link
Contributor

bart0sh commented Sep 2, 2023

I think it's a cleanup,

Thanks. I thought that it's a fix for arm64 arch.

@aojea
Copy link
Member

aojea commented Sep 2, 2023

hack/local-up-cluster.sh is a developer only thing, there is no guarantees

@HirazawaUi
Copy link
Contributor Author

hack/local-up-cluster.sh is a developer only thing, there is no guarantees

I've encountered this issue frequently in local debugging so I want to fix it, if we don't need it, I can close this PR and just fix the wrong hash value.

@aojea
Copy link
Member

aojea commented Sep 3, 2023

I've encountered this issue frequently in local debugging so I want to fix it, if we don't need it, I can close this PR and just fix the wrong hash value.

sorry, I was trying to answer this other one comment :)

This looks like a bugfix to me

@aojea
Copy link
Member

aojea commented Sep 3, 2023

pull-kubernetes-local-e2e — Job failed.                     BaseSHA:34aaf2b972c95c7a3591d8d49c798dba348ee5c9

this job is failing on network problems, most probablt related to this PR

@HirazawaUi
Copy link
Contributor Author

pull-kubernetes-local-e2e — Job failed.                     BaseSHA:34aaf2b972c95c7a3591d8d49c798dba348ee5c9

this job is failing on network problems, most probablt related to this PR

I'm looking at this error, but according to my local tests, it existed before this PR was submitted.

@@ -1146,15 +1146,18 @@ function tolerate_cgroups_v2 {
}

function install_cni {
cni_plugin_sha=CNI_PLUGINS_${CNI_TARGETARCH^^}_SHA256SUM
Copy link
Contributor

Choose a reason for hiding this comment

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

This is backward incompatible I think. It practically means ignoring CNI_TARGETARCH environment variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The CNI_TARGETARCH variable is expected to be deleted and replaced by the host_arch

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, and this would break developers workflows if they set CNI_TARGETARCH.
Even if we consider doing this we should at least mention it in release notes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given the addition of the ability to automatically recognize the Arch of the CNI binary, I would prefer to remove CNI_TARGETARCH and add release note.

Copy link
Contributor

@bart0sh bart0sh Sep 7, 2023

Choose a reason for hiding this comment

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

I'd suggest to avoid breaking backwards compatibility. In this case it means only do automatic recognition when CNI_TARGETARCH is not set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All right

@aojea
Copy link
Member

aojea commented Sep 3, 2023

I'm looking at this error, but according to my local tests, it existed before this PR was submitted.

You are absolutely right, https://testgrid.k8s.io/conformance-all#local-up-cluster,%20master%20(dev) , this job has failing for a long time on these tests
cc: @dims

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Sep 4, 2023
@bart0sh
Copy link
Contributor

bart0sh commented Sep 12, 2023

/priority important-longterm
/lgtm
/assign @liggitt

@k8s-ci-robot k8s-ci-robot added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 12, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 12, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 37f71a617644c9ed39a911184ca1354fa88e6848

@bart0sh bart0sh moved this from Needs Reviewer to Needs Approver in SIG Node PR Triage Sep 12, 2023
@liggitt
Copy link
Member

liggitt commented Sep 12, 2023

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: HirazawaUi, liggitt

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 12, 2023
@k8s-ci-robot k8s-ci-robot merged commit 921fd1b into kubernetes:master Sep 12, 2023
15 checks passed
SIG Node PR Triage automation moved this from Needs Approver to Done Sep 12, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Sep 12, 2023
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

7 participants