Solution (source code)

= Solution

The boundary consists of the spherical zone $-a\le z\le a$ and the inner cylindrical wall. On the sphere, $n=r/R$, so $n\cdot r=R$. Its area element is $R\,d\phi\,dz$, giving the flux
$$
\int_{-a}^{a}\int_0^{2\pi}R^2\,d\phi\,dz=4\pi aR^2.
$$
On the inner cylinder, the outward normal of the remaining material points \i[towards the hole]: $n=-e_\rho$. Therefore $n\cdot r=-r_0$, and $dS=r_0\,d\phi\,dz$, giving flux $-4\pi ar_0^2$. There are no planar end faces of positive area: the two surfaces meet along the rim circles. Hence
$$
\boxed{V=\frac{4\pi a}{3}(R^2-r_0^2)
=\frac{4\pi a^3}{3}=\frac{\pi h^3}{6}.}
$$
Using the cylinder's radial normal with the opposite sign would count the hole as extra material and lose the required cancellation.