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

refactor(lvm): continue refactoring of lvm command calling convention #261

Conversation

kro-cat
Copy link
Contributor

@kro-cat kro-cat commented Oct 8, 2023

The number of this branch refers to pull request #250.

Why is this PR required? What issue does it fix?:
The calling convention of lvm commands in pkg/lvm/lvm_util.go should all follow the same format, following issue #247. This reduces the impact of unforseen (non-critical) warnings being printed to the STDERR output stream, which CombinedOutput mixes with STDOUT.

What this PR does?:
Refactor all occurrences of Commands using CombinedOutput with an lvm command to use RunCommandSplit, a function which splits the STDERR and STDOUT streams into separate return values. Additionally, RunCommandSplit prints any STDERR messages to the log as a warning so that these messages aren't lost.

Additionally, this PR refactors some changes in ci/ci-test.sh that were added in pull #250. During ci tests of these changes, I found that the tests were failing for an unknown reason. A small patch has been applied to ci/ci-test.sh which may help resolve that issue on some machines.

Does this PR require any upgrade changes?:
Most likely not.

If the changes in this PR are manually verified, list down the scenarios covered::
No manual verification. The refactors in this PR are a follow-up to issue #247.

Any additional information for your reviewer? :
This PR is a continuation of pull request #250.

Checklist:

  • Fixes Issue with JSON decode on vgs combined stream ouput #247
  • PR Title follows the convention of <type>(<scope>): <subject>
  • Has the change log section been updated? -- A change log has not been provided for this PR at this time.
  • Commit has unit tests
  • Commit has integration tests
  • (Optional) Are upgrade changes included in this PR? If not, mention the issue/PR to track:
  • (Optional) If documentation changes are required, which issue on https://github.com/openebs/openebs-docs is used to track them:

Env vars LVM_SYSTEMID and LVM_CONFIG are used to describe a potentially
foreign lvm system on the kubernetes host. The lvm system is only meant
to be foreign to the lvm-localpv containers.

Due to the way the ci tests are written, the kubernetes host and the
lvm-localpv conatiners must have identical lvm configurations or ci
tests might fail.

The variables LVM_SYSTEMID and LVM_CONFIG have been renamed to
FOREIGN_LVM_SYSTEMID and FOREIGN_LVM_CONFIG, respectively. This is
helpful when determining their roles at a glance.

A secondary change was made to the foreign pv creation: the lvm option
`--config` has been used in place of `--systemid` to hopefully minimize
unintended side effects of using the same lvm config (with the exception
of the system id) during volume group creation.

Signed-off-by: kro <33235324+kro-cat@users.noreply.github.com>
The LVM system may sometimes produce non-critical warnings which are
written to STDERR without formatting. Combining STDERR with STDIN may
cause failures when the output is being formatted or otherwise
interpreted.

Following pull openebs#250, it's been requested that all lvm commands be
refactored to use a split output in order to resolve this issue under
non-tested scenarios. See issue openebs#247.

The definition for RunCommandSplit has been moved above all uses of the
function, and any Command using CombinedOutput and an lvm command (s.a.:
lvs, vgs, lvcreate, &c.) has been refactored to instead use
RunCommandSplit to obtain the command's output.

If anything is written to STDERR by the lvm commands, RunCommandSplit
prints the message to the log as a warning.

Signed-off-by: kro <33235324+kro-cat@users.noreply.github.com>
@Abhinandan-Purkait Abhinandan-Purkait merged commit 9e0ac5b into openebs:develop Oct 18, 2023
5 checks passed
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.

Issue with JSON decode on vgs combined stream ouput
3 participants