GoogleCloudPlatform / guest-configs

Apache License 2.0
31 stars 41 forks source link

Fix `warning: command substitution: ignored null byte in input` #50

Closed HuijingHei closed 1 year ago

HuijingHei commented 1 year ago

This is to remove safe warning when running google_nvme_id:

]# bash /usr/lib/udev/google_nvme_id -d /dev/nvme0n1
/usr/lib/udev/google_nvme_id: line 65: warning: command substitution: ignored null byte in input
ID_SERIAL_SHORT=persistent-disk-0
ID_SERIAL=Google_PersistentDisk_persistent-disk-0

]# nvme_json="$(/usr/sbin/nvme id-ns -b /dev/nvme0n1 | cut -b 384-)"
-bash: warning: command substitution: ignored null byte in input
]# nvme_json="$(/usr/sbin/nvme id-ns -b /dev/nvme0n1 | cut -b 384- | tr -d '\0')"
<no warning>

Refer to https://bugzilla.redhat.com/show_bug.cgi?id=1473642

google-oss-prow[bot] commented 1 year ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: HuijingHei Once this PR has been reviewed and has the lgtm label, please assign dorileo for approval. For more information see the Kubernetes Code Review Process.

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

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/GoogleCloudPlatform/guest-configs/blob/master/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
google-oss-prow[bot] commented 1 year ago

Hi @HuijingHei. Thanks for your PR.

I'm waiting for a GoogleCloudPlatform member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
HuijingHei commented 1 year ago

/holdon

The warning is harmless and I do not want it to delay the merge process of https://github.com/GoogleCloudPlatform/guest-configs/pull/49, but will rebase https://github.com/GoogleCloudPlatform/guest-configs/pull/49 when it is merged.

HuijingHei commented 1 year ago

Do more testing:

]# nvme_json="$(/usr/sbin/nvme id-ns -b /dev/nvme0n1 | cut -b 384- | tr -d '\0')"

]# echo $nvme_json
{"device_name":"persistent-disk-0","disk_type":"PERSISTENT"}
]# device_name="$(echo "$nvme_json" | grep device_name | sed -e 's/.*"device_name":[  \t]*"\([a-zA-Z0-9_-]\+\)".*/\1/')"
]# echo $device_name
persistent-disk-0
vorakl commented 1 year ago

@HuijingHei , as you mentioned, this warning message is harmless. It doesn't affect a status code (which is still 0 when other conditions are fine). More over, there was this warning message a long time before.

From the other perspective, having one more external tool in a pipeline brings more challenges to support it existence in every distribution we officially support.

I don't see any reason for removing the warning at the moment, and especially, by introducing one more additional tool. It could be removed, for example, using only Bash code with no external tools, like this: read nvme_json < <(/usr/sbin/nvme id-ns -b /dev/nvme0n1 | cut -b 384-)

There is a code conflict anyway, I'll put on hold, until new circumstances come up.

vorakl commented 1 year ago

/hold

HuijingHei commented 1 year ago

@vorakl thanks for your detail info, I am OK to keep as it is. Feel free to close this.