# Principal bundle over another principal bundle again principal?

I want to expand upon an earlier (partially answered) question: Is a principal bundle of a principal bundle still principal?

As in said question, let $$M, P_1, P_2$$ be manifolds, let $$P_1 \overset{\pi_1}{\to} M$$ be a principal bundle corresponding to a Lie group $$G_1$$, and let $$P_2 \overset{\pi_2}{\to} M$$ correspond to a Lie group $$G_2$$. Consider the fibre bundle $$P_2 \to M$$.

In the original question it was hypothised the composition is a principal bundle with group $$G_1 \times G_2$$, but this was disproved in the comments by looking at the double cover $$S^1 \to S^1 \to pt$$ with groups $$\mathbb Z/2$$ and $$S^1$$ and noting that the combined map just has group $$S^1 \neq \mathbb Z/2 \times S^1$$.

However, $$1 \to \mathbb Z/2 \to S^1 \to S^1 \to 1$$ is exact, so my questions are:

1. When is $$P_2 \to M$$ again principal? (Intuitively I expect you might need $$G$$ is compact, or something like that.)
2. In that case, is the corresponding group always a semi-direct product of $$G_1$$ and $$G_2$$?

(This question was motivated by the physics question of whether it is sensible to apply Yang-Mills theory on the total space of the frame tangent bundle of your physical manifold instead of the manifold itself.)