Page MenuHomeClusterLabs Projects

OCF_OUTPUT_FORMAT is set inappropriately
Open, NormalPublic

Description

Each time a new pcmk__output_t object is created, it sets the OCF_OUTPUT_FORMAT environment variable. This is problematic for at least two reasons:

  1. The environment variable is set based on the most recently created output object. So for example, if we had a log object and a text object, the order in which they're created determines the value of the environment variable.
  2. This approach doesn't seem to align with the intent of OCF_OUTPUT_FORMAT. The environment variable is supposed to tell an OCF resource agent which format to use for any output that it generates. But a resource agent isn't coupled to any pcmk__output_t object that may (or may not exist). So IMO it doesn't make sense to set the variable based on a pcmk__output_t object.

Also note that no ClusterLabs-provided resource agents actually check OCF_OUTPUT_FORMAT yet.

Ref:

Event Timeline

nrwahl2 triaged this task as Normal priority.Dec 19 2023, 2:24 AM
nrwahl2 created this task.
nrwahl2 created this object with edit policy "Restricted Project (Project)".

The original intent was that this would be used with tools that call resource agents. An example use case would be crm_resource --show-metadata; if an agent supports text output to show metadata in a human-friendly fashion, crm_resource could show metadata in text or xml as requested.

The assumption was that the tool would only have one output object (for the format requested by the user). Since that isn't the case, setting OCF_OUTPUT_FORMAT should be done separately by the tools that need it, instead of when creating the output object. This could potentially be a new output object function to avoid having to check the format directly.

We don't need to set OCF_OUTPUT_FORMAT when invoking resource agents from the cluster itself.