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

when restart deployment kube-ovn-controller the kubectl ko log loss #2508

Merged
merged 2 commits into from Mar 20, 2023

Conversation

changluyi
Copy link
Collaborator

What type of this PR

Examples of user facing changes:

  • Features
  • Bug fixes
  • Docs
  • Tests

Which issue(s) this PR fixes:

Fixes #(issue-number)

@changluyi changluyi added the test automation tests label Mar 17, 2023
@changluyi changluyi force-pushed the restart_kube_ovn_controller_show_log branch from 9771134 to afe4eca Compare March 17, 2023 09:08
restartCmd := fmt.Sprintf("kubectl rollout restart deployment %s -n kube-system", name)
_, err := exec.Command("bash", "-c", restartCmd).CombinedOutput()
framework.ExpectNoError(err, fmt.Sprintf("restart %s failed", name))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The code patch adds a new function RestartSystemDeployment that restarts a Kubernetes deployment in the kube-system namespace. The function takes two arguments: the name of the deployment to restart and a boolean flag to enable logging.

There are a few potential issues with this code:

  1. The function assumes that kubectl and kubectl ko are installed on the system where the code is running. It may be better to check for these dependencies and provide more informative error messages if they are not found.

  2. The function logs the output of the kubectl ko log command, but it does not check the exit status of the command. If the command fails, the function will continue executing and attempt to restart the deployment anyway.

  3. The function uses CombinedOutput() to capture the output of the kubectl commands, which means that both stdout and stderr will be combined into a single byte slice. This may make it harder to parse the output of the commands later on.

  4. The function does not return any values or provide any feedback to the caller about whether the deployment was successfully restarted or not.

To address these issues, you could consider:

  1. Adding checks for the presence of kubectl and kubectl ko, and returning an error if they are not found.

  2. Checking the exit status of the kubectl ko log command, and returning an error if it fails.

  3. Using separate StdoutPipe() and StderrPipe() methods to capture the stdout and stderr streams separately.

  4. Returning an error from the function if the deployment restart fails, or providing some other way for the caller to determine whether the restart was successful or not.

@zhangzujian
Copy link
Member

kube-ovn-controller also logs to the file /var/log/kube-ovn/kube-ovn-controller.log. We can collect logs from this file on each node.

Printing kube-ovn-controller logs during the e2e running will mess up the ginkgo output. We should collect and print the logs after the e2e completes.

@changluyi changluyi merged commit 416cc77 into master Mar 20, 2023
@changluyi changluyi deleted the restart_kube_ovn_controller_show_log branch March 20, 2023 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test automation tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants