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

fix reboot_test.go and collectEntries #2663

Merged
merged 6 commits into from
Sep 17, 2024
Merged

fix reboot_test.go and collectEntries #2663

merged 6 commits into from
Sep 17, 2024

Conversation

YZ775
Copy link
Contributor

@YZ775 YZ775 commented Sep 6, 2024

No description provided.

@YZ775 YZ775 force-pushed the fix-neco-rebooter-ci branch 10 times, most recently from 69da4f5 to 2b88b98 Compare September 9, 2024 00:07
@YZ775 YZ775 changed the title fix reboot_test and collectEntries fix reboot_test.go and collectEntries Sep 9, 2024
dctest/reboot_test.go Outdated Show resolved Hide resolved
dctest/reboot_test.go Outdated Show resolved Hide resolved
if len(rack) == 0 {
continue
}
racksTmp = append(racksTmp, rack[len(rack)-1:])
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you cut out numbers here?
In most reference points, fmt.Sprintf("rack%s", racks[0]) is used. And it making the code difficult to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to extract only rack numbers because the format of "rack" is different between application.

  • k8s label: topology.kubernetes.io/zone=rack1
  • sabakan option: sabactl machines get --rack=1

Copy link
Contributor

Choose a reason for hiding this comment

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

I know. How about extracting the number only in neco-rebooter args?
Also, does sh -c work as expected?

rebootCmd := fmt.Sprintf("yes | neco rebooter reboot-worker --rack=%s", racks[0][4:] /* extract a rack number: "rackN" -> "N" */)
execSafeAt(bootServers[0], "sh", "-c", "'"+rebootCmd+"'")

or

execSafeAt(bootServers[0], "yes", "|", "neco", "rebooter", "reboot-worker", "--rack="+racks[0][4:] /* extract a rack number: "rackN" -> "N" */)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand. and I fixed the code to extract number only in neco-rebooter command.

And, sh-c works fine.
It had been used before neco-rebooter was implemented like below.

execSafeAt(bootServers[0], "sh", "-c", "yes | neco reboot-worker "+necoRebootWorkerOptions)

@YZ775 YZ775 requested a review from masa213f September 10, 2024 08:44
Comment on lines 249 to 251
if len(racks) < 2 {
Fail("less than 2 racks are available")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

How about to use Expect() here too?

Fail(fmt.Sprintf("stdout: %s, stderr: %s, err: %v", stdout, stderr, err))
}
_, _, err = execAtWithInput(bootServers[0], podYaml, "kubectl", "apply", "-f", "-")
Expect(err).NotTo(HaveOccurred())
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. But why don't you keep the stdout and stderr?
We can pass the optionalDescription, if we want.

https://github.com/onsi/gomega/blob/7cabed651e981da0c7d0219ad7208626cef58016/gomega_dsl.go#L524

Eventually(func() error {
stdout, stderr, err := execAt(bootServers[0], "neco", "rebooter", "show-processing-group")
if err != nil {
return fmt.Errorf("stdout: %s, stderr: %s, err: %v", stdout, stderr, err)
}
if string(stdout) != "rack2\n" {
if strings.Contains(string(stdout), racks[1]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about use strings.TrimSpace?

@YZ775 YZ775 force-pushed the fix-neco-rebooter-ci branch 2 times, most recently from 637a2f9 to 5c7d2b1 Compare September 11, 2024 05:07
Copy link
Contributor

@masa213f masa213f left a comment

Choose a reason for hiding this comment

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

LGTM

@YZ775 YZ775 merged commit ecfb1fc into main Sep 17, 2024
2 checks passed
@YZ775 YZ775 deleted the fix-neco-rebooter-ci branch September 17, 2024 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants