kubernetes: Fix message formatting in AttachDetach controller on VA status error

What happened?

Attachdetach Controller records events on a PVC when errors occur:

The message is logged with Eventf, however a single string is passed to the messageFmt argument. This treats a message (which may potentially contain format characters that should be treated literally) as a format string. This can result in incorrectly formatted messages, depending on the error message. This is problematic for CSI, as error messages are propagated up from the CSI driver, and presented on a VolumeAttachment resource as a status message. This can result in an event with special characters being replaced by !!(MISSING).

What did you expect to happen?

Expected error message to be printed as string literal, not format string.

How can we reproduce it (as minimally and precisely as possible)?

Reproduction requires configuring a CSI driver to emit a particular error message that includes special characters interpreted as golang string format characters on ControllerPublish RPC.

Anything else we need to know?

No response

Kubernetes version

1.30

Cloud provider

GCP

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, …) and versions (if applicable)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

@Karthik-K-N sure, i’ll keep in mind.

I believe we should fix all the locations where Eventf is used.

Agreed.

I am interested to work on this and will raise a PR for the same

@Shilpa-Gokul Thanks! If you can audit other Eventf calls for volume/storage, that would be appreciated as well (anywhere that Eventf is called with only 4 parameters is suspect).