kubernetes-sigs / gcp-compute-persistent-disk-csi-driver

The Google Compute Engine Persistent Disk (GCE PD) Container Storage Interface (CSI) Storage Plugin.
Apache License 2.0
163 stars 143 forks source link

Format byte array error output from google_nvme_id as string #1761

Closed pwschuurman closed 3 months ago

pwschuurman commented 3 months ago

What type of PR is this? /kind cleanup

What this PR does / why we need it: Error message is currently being printed out as a byte array (%v). It should be printed out as a string (%s). This is done elsewhere exec.CombinedOutput() is parsed.

Current error message is formatted like:

couldn't get serial number for disk pvc-b161d218-87e9-4657-9339-a11ef1eb7a54 at device path /dev/nvme1n2: google_nvme_id failed for device "/dev/nvme1n2" with output [91 50 48 50 52 45 48 54 45 50 48 84 49 57 58 50 52 58 52 48 43 48 48 48 48 93 58 32 80 97 115 115 101 100 32 100 101 118 105 99 101 32 119 97 115 32 110 111 116 32 97 110 32 78 86 77 101 32 100 101 118 105 99 101 46 32 32 40 89 111 117 32 109 97 121 32 110 101 101 100 32 116 111 32 114 117 110 32 116 104 105 115 32 115 99 114 105 112 116 32 97 115 32 114 111 111 116 47 119 105 116 104 32 115 117 100 111 41 46 10]: exit status 1

This should be:

couldn't get serial number for disk pvc-b161d218-87e9-4657-9339-a11ef1eb7a54 at device path /dev/nvme1n2: google_nvme_id failed for device "/dev/nvme1n2" with output [2024-06-22T07:26:12+0000]: Passed device was not an NVMe device.  (You may need to run this script as root/with sudo).: exit status 1

Special notes for your reviewer: This was discovered when debugging the issue for #1760

Does this PR introduce a user-facing change?:

Improve error message when `google_nvme_id` returns a non-zero exit code
pwschuurman commented 3 months ago

/assign @Sneha-at

pwschuurman commented 3 months ago

Failure: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_gcp-compute-persistent-disk-csi-driver/1761/pull-gcp-compute-persistent-disk-csi-driver-e2e/1805435946347270144

Failed with:

/home/prow/go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/test/e2e/tests/single_zone_e2e_test.go:715

  [FAILED] CreateVolume failed with error: rpc error: code = InvalidArgument desc = CreateVolume failed: rpc error: code = InvalidArgument desc = CreateVolume failed to create single zonal disk gcepd-csi-e2e-2ee8c344-aab9-42c0-8ba2-6aaffc3d24ab: failed to insert zonal disk: unknown Insert disk error: googleapi: Error 400: Cloud KMS error when using key projects/k8s-infra-e2e-boskos-062/locations/global/keyRings/gce-pd-csi-test-ring/cryptoKeys/test-key-1c952bf4-c58c-4b41-9993-1102071d948b: Permission 'cloudkms.cryptoKeyVersions.useToEncrypt' denied on resource 'projects/k8s-infra-e2e-boskos-062/locations/global/keyRings/gce-pd-csi-test-ring/cryptoKeys/test-key-1c952bf4-c58c-4b41-9993-1102071d948b' (or it may not exist)., kmsPermissionDenied%!v(MISSING)
  Expected
      <*status.Error | 0xc00012f4d0>: 
      rpc error: code = InvalidArgument desc = CreateVolume failed: rpc error: code = InvalidArgument desc = CreateVolume failed to create single zonal disk gcepd-csi-e2e-2ee8c344-aab9-42c0-8ba2-6aaffc3d24ab: failed to insert zonal disk: unknown Insert disk error: googleapi: Error 400: Cloud KMS error when using key projects/k8s-infra-e2e-boskos-062/locations/global/keyRings/gce-pd-csi-test-ring/cryptoKeys/test-key-1c952bf4-c58c-4b41-9993-1102071d948b: Permission 'cloudkms.cryptoKeyVersions.useToEncrypt' denied on resource 'projects/k8s-infra-e2e-boskos-062/locations/global/keyRings/gce-pd-csi-test-ring/cryptoKeys/test-key-1c952bf4-c58c-4b41-9993-1102071d948b' (or it may not exist)., kmsPermissionDenied%!v(MISSING)
      {
          s: {
              s: {
                  state: {
                      NoUnkeyedLiterals: {},
                      DoNotCompare: [],
                      DoNotCopy: [],
                      atomicMessageInfo: nil,
                  },
                  sizeCache: 0,
                  unknownFields: nil,
                  Code: 3,
                  Message: "CreateVolume failed: rpc error: code = InvalidArgument desc = CreateVolume failed to create single zonal disk gcepd-csi-e2e-2ee8c344-aab9-42c0-8ba2-6aaffc3d24ab: failed to insert zonal disk: unknown Insert disk error: googleapi: Error 400: Cloud KMS error when using key projects/k8s-infra-e2e-boskos-062/locations/global/keyRings/gce-pd-csi-test-ring/cryptoKeys/test-key-1c952bf4-c58c-4b41-9993-1102071d948b: Permission 'cloudkms.cryptoKeyVersions.useToEncrypt' denied on resource 'projects/k8s-infra-e2e-boskos-062/locations/global/keyRings/gce-pd-csi-test-ring/cryptoKeys/test-key-1c952bf4-c58c-4b41-9993-1102071d948b' (or it may not exist)., kmsPermissionDenied%!v(MISSING)",
                  Details: nil,
              },
          },
      }
  to be nil
  In [It]
pwschuurman commented 3 months ago

prow-build SA has the right permissions, but the default compute SA does not: https://cloud.google.com/kms/docs/reference/permissions-and-roles#cloudkms.cryptoKeyEncrypterDecrypter

https://github.com/kubernetes/k8s.io/blob/6b127bfd9196d2ca9f04f99622a35a12e1fbb01c/infra/gcp/bash/prow/ensure-e2e-projects.sh#L84C23-L84C50

pwschuurman commented 3 months ago

/retest

mattcary commented 3 months ago

/lgtm /approve

thanks!

Sneha-at commented 3 months ago

/lgtm /approve

k8s-ci-robot commented 3 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mattcary, pwschuurman, Sneha-at

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](https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/blob/master/OWNERS)~~ [mattcary,pwschuurman] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
pwschuurman commented 3 months ago

/retest

pwschuurman commented 3 months ago

/retest