TITLE: Does $\nabla g=\omega(\cdot) g$ imply $\nabla$ is metric w.r.t a conformal rescaling of $g$?
QUESTION [5 upvotes]: This is a cross-post.
Let $E$ be  a smooth vector bundle over a manifold $M$, where $\text{rank}(E) > 1,\dim M > 1$. Suppose that $E$ is equipped with a metric $g$ and an affine connection $\nabla$, such that $\nabla_X g=\omega (X) g$ for every $X \in \Gamma(TM)$. (Here $\omega$ is a one form).
Must $\omega$ be closed? 
Clearly, $\nabla$ is metric-compatible ($\nabla g=0$) iff $\omega=0$. 
Moreover,  $\omega=d\phi$ is exact if and only if $\nabla s=0$ where $s=e^{-\phi}g$, i.e. $\nabla$ is metric w.r.t a positive conformal rescaling of $g$. 
 So, an alternative formulation of the question is the following:

Suppose that $\nabla g=\omega (\cdot) g$ for some  $\omega \in \Omega^1(M)$. Must $\nabla$ be metric w.r.t a local conformal rescalings of $g$? 

Differentiating $\nabla g=\omega (\cdot) g$, we get $R(X,Y)g=d\omega(X,Y)g$, so if $\nabla$ is flat then $\omega$ is closed. 

I required $\text{rank}(E) > 1$, since if the rank is $1$, $\nabla g$ can always be written as $\omega (\cdot) g$ for a suitable $\omega$, so the assumption always holds, but I think that $d\omega=0$ does not always hold. Maybe this can be used to construct a counter example of higher rank by taking a direct sum of line bundles.

REPLY [7 votes]: The answer is 'no'.  For example, just take $M$ to be $\mathbb{R}^n$ (for $n>1$), and $E = M\times \mathbb{R}^r$ for some $r>1$.  Let $\omega$ be any $1$-form on $M$, and define a connection $\nabla$ on $E$ by setting
$$
\nabla e_i = -\tfrac{1}{2} \omega\otimes e_i
$$
where $e_i$ for $1\le i\le r$ is some basis for the sections of $E$ over $M$.  Then, if $e^i$ are the dual basis of $E^*$, the metric
$$
g = (e^1)^2 + \cdots + (e^r)^2
$$
satisfies $\nabla g = \omega\otimes g$.  
Note: We extend the connection $\nabla$ as a connection on $E^*$ by the usual rule:  I.e., we require that
$$
\nabla (e_1\otimes e^1 + \cdots + e_r\otimes e^r) = 0.
$$