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

Convert Upgrader Script to Go binary #3033

Merged
merged 5 commits into from
Apr 11, 2024

Conversation

rahulbabu95
Copy link
Member

@rahulbabu95 rahulbabu95 commented Mar 26, 2024

Issue #, if available:
Upgrader project consumed by eks-a for InPlace upgrades uses an upgrader script written in shell for running the upgrade commands on the node. Ideally, we need it as a Go binary for long term maintainability, testability and general conformance with other parts of the codebase.

Description of changes:
This change converts the upgrader shell script into a Go binary along with unit tests to cover the core business logic. Manually tested by copying over the Go binary to the nodes to test if the corresponding upgrade logic is working as expected when the binary is invoked instead of the shell script.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@eks-distro-bot
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@eks-distro-bot eks-distro-bot added do-not-merge/work-in-progress size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 26, 2024
@rahulbabu95 rahulbabu95 marked this pull request as ready for review March 27, 2024 23:36
@rahulbabu95 rahulbabu95 changed the title [WIP] Convert Upgrader Script to Go binary Convert Upgrader Script to Go binary Mar 28, 2024
@rahulbabu95
Copy link
Member Author

/hold

@rahulbabu95
Copy link
Member Author

/retest

1 similar comment
@rahulbabu95
Copy link
Member Author

/retest

projects/aws/upgrader/cmd/root.go Show resolved Hide resolved
var rootCmd = &cobra.Command{
Use: "upgrader",
Short: "EKS Anywhere InPlace upgrader",
Long: `Use EKS Anywhere InPlace upgrader to upgrade your nodes InPlace`,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Long: `Use EKS Anywhere InPlace upgrader to upgrade your nodes InPlace`,
Long: `Use EKS Anywhere InPlace upgrader to upgrade your nodes in place`,

projects/aws/upgrader/cmd/root.go Outdated Show resolved Hide resolved
projects/aws/upgrader/cmd/upgrade_cniplugins.go Outdated Show resolved Hide resolved
func upgradeCniPlugins(ctx context.Context) error {
upg := upgrade.NewUpgrader()
if err := upg.CniPluginsUpgrade(ctx); err != nil {
return fmt.Errorf("upgrading Cni-Plugins on the node: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("upgrading Cni-Plugins on the node: %v", err)
return fmt.Errorf("upgrading cni-plugins on the node: %v", err)

projects/aws/upgrader/upgrade/containerd_upgrade.go Outdated Show resolved Hide resolved
projects/aws/upgrader/upgrade/cniplugins_upgrade_test.go Outdated Show resolved Hide resolved
projects/aws/upgrader/upgrade/kubeadm_upgrade.go Outdated Show resolved Hide resolved
projects/aws/upgrader/upgrade/kubeadm_upgrade.go Outdated Show resolved Hide resolved
projects/aws/upgrader/upgrade/upgrade_status.go Outdated Show resolved Hide resolved
Copy link
Member

@jacobweinstock jacobweinstock left a comment

Choose a reason for hiding this comment

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

You should have code comments on all exported functions. I highly suggest you add more code comments around why things are being done the way they are, why code exists, etc.

projects/aws/upgrader/upgrade/syscalls.go Outdated Show resolved Hide resolved
"path/filepath"
"strings"

"github.com/aws/eks-anywhere-build-tooling/tools/version-tracker/pkg/util/logger"
Copy link
Member

Choose a reason for hiding this comment

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

What value does this library provide over just using the logr package directly? Also, this package has not avoided package state in its implementation. There is no reason for a logger to have package state, it's a solved problem. I recommend not using it and to make all dependencies explicit by passing them into funds and methods.

projects/aws/upgrader/cmd/upgrade_node.go Outdated Show resolved Hide resolved
projects/aws/upgrader/main.go Show resolved Hide resolved
projects/aws/upgrader/upgrade/cniplugins_upgrade.go Outdated Show resolved Hide resolved
projects/aws/upgrader/upgrade/upgrader.go Outdated Show resolved Hide resolved
projects/aws/upgrader/upgrade/syscalls.go Outdated Show resolved Hide resolved
Copy link
Member

@jaxesn jaxesn left a comment

Choose a reason for hiding this comment

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

Just reviewed the makefile changes. look pretty decent!

projects/aws/upgrader/Makefile Outdated Show resolved Hide resolved
projects/aws/upgrader/Makefile Outdated Show resolved Hide resolved
projects/aws/upgrader/Makefile Outdated Show resolved Hide resolved
projects/aws/upgrader/Makefile Outdated Show resolved Hide resolved
projects/aws/upgrader/cmd/root.go Outdated Show resolved Hide resolved
projects/aws/upgrader/cmd/upgrade.go Outdated Show resolved Hide resolved
projects/aws/upgrader/cmd/root.go Show resolved Hide resolved
projects/aws/upgrader/cmd/status.go Outdated Show resolved Hide resolved
projects/aws/upgrader/cmd/upgrade_cniplugins.go Outdated Show resolved Hide resolved
projects/aws/upgrader/cmd/upgrade_cniplugins.go Outdated Show resolved Hide resolved
var upgradeContainerdCmd = &cobra.Command{
Use: "containerd",
Short: "Upgrade containerd",
Long: "Use InPlace Upgrader upgrade containerd to upgrade containerd on the node",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Long: "Use InPlace Upgrader upgrade containerd to upgrade containerd on the node",
Long: "Use upgrade containerd command to upgrade containerd on the node",

projects/aws/upgrader/cmd/upgrade_kubelet_kubectl.go Outdated Show resolved Hide resolved
projects/aws/upgrader/cmd/upgrade_node.go Outdated Show resolved Hide resolved

upgCmpDir, err := u.upgradeComponentsDir()
if err != nil {
return fmt.Errorf("getting upgrade componenets directory: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("getting upgrade componenets directory: %v", err)
return fmt.Errorf("getting upgrade components directory: %v", err)

projects/aws/upgrader/upgrade/kubeadm_upgrade.go Outdated Show resolved Hide resolved
projects/aws/upgrader/upgrade/kubeadm_upgrade.go Outdated Show resolved Hide resolved
projects/aws/upgrader/upgrade/kubeadm_upgrade.go Outdated Show resolved Hide resolved
projects/aws/upgrader/upgrade/kubeadm_upgrade.go Outdated Show resolved Hide resolved
projects/aws/upgrader/upgrade/kubeadm_upgrade.go Outdated Show resolved Hide resolved
func (u *Upgrader) KubeletKubectlUpgrade(ctx context.Context) error {
cmpDir, err := u.upgradeComponentsKubernetesBinDir()
if err != nil {
return fmt.Errorf("getting upgrade componenets binary directory: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("getting upgrade componenets binary directory: %v", err)
return fmt.Errorf("getting upgrade components binary directory: %v", err)

projects/aws/upgrader/upgrade/kubelet_kubectl_upgrade.go Outdated Show resolved Hide resolved
projects/aws/upgrader/upgrade/kubelet_kubectl_upgrade.go Outdated Show resolved Hide resolved
@rahulbabu95 rahulbabu95 force-pushed the inplace/upgrader-go-binary branch 3 times, most recently from bd1a4aa to 2ae08ce Compare April 8, 2024 08:01
@rahulbabu95
Copy link
Member Author

/retest

@rahulbabu95 rahulbabu95 force-pushed the inplace/upgrader-go-binary branch 2 times, most recently from ee6b347 to 001c4cb Compare April 9, 2024 22:01
Signed-off-by: Rahul Ganesh <rahulgab@amazon.com>
Signed-off-by: Rahul Ganesh <rahulgab@amazon.com>
Copy link
Member

@jaxesn jaxesn left a comment

Choose a reason for hiding this comment

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

Im good with the makefile changes, thanks for the updates!

Signed-off-by: Rahul Ganesh <rahulbabu95@gmail.com>
}

cniVersionCmd := []string{"/opt/cni/bin/loopback", "--version"}
out, err := u.ExecCommand(ctx, cniVersionCmd[0], cniVersionCmd[1:]...)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed and where is it being used?

}

containerdVersionCmd := []string{"containerd", "--version"}
out, err := u.ExecCommand(ctx, containerdVersionCmd[0], containerdVersionCmd[1:]...)
Copy link
Member

Choose a reason for hiding this comment

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

Same question here. Let’s at least log the before version if we are calling it

Signed-off-by: Rahul Ganesh <rahulbabu95@gmail.com>
Signed-off-by: Rahul Ganesh <rahulbabu95@gmail.com>
@abhay-krishna
Copy link
Member

/lgtm
/approve

Copy link
Member

@abhinavmpandey08 abhinavmpandey08 left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm
/woof

@eks-distro-bot
Copy link
Collaborator

@abhinavmpandey08: dog image

In response to this:

/approve
/lgtm
/woof

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/test-infra repository.

@rahulbabu95
Copy link
Member Author

/unhold
/approve

@eks-distro-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhay-krishna, abhinavmpandey08, rahulbabu95

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:
  • OWNERS [abhay-krishna,abhinavmpandey08,rahulbabu95]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@eks-distro-bot eks-distro-bot merged commit 3f3308e into aws:main Apr 11, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants