You are right that for any carry trade to be profitable, cost of funding or leverage cost using repo has to be lower than the investment yields (in this case yields on sovereign bonds). However, for a more detailed explanation, let's start from basics as to why this happens and how does it usually ends.
If an economy is struggling, central bank through monetary policies attempt to increase money supply. For example, they reduce Fed Fund rate/over night repo rates and introduce other measures of quantitative easing. As a result, money is available for borrowing at cheaper rates in the financial system.
what happens then?
With easy money supply at lower cost, financial institutions can now borrow this money and invest. They can invest in equities, infrastructure, real investments as well as bond markets. Idea is to increase investment and stimulate economy thereby resulting in growth.
What happened here?
Some bond traders made use of cheap money and increased leverage, and invested in purchase of sovereign bonds (longer duration like 5 year or 10yr) that would have often 100s of basis point spread .. (i.e. if repo is 3% then may be 10 year govt bonds were 4%). A trader will borrow at 3% and invest in 4% for as long as it can, thus pocketing 1% (referred to as carry)
How does it end?
If too many people are purchasing same asset (lets say 10yr bond), then price of bond rises and its interest rate reduces. Thus a 4% bond may become 3.35% and therefore profit will reduce. Alternatively, Central bank can reduce liquidity through open market operations or increase over night rate outrightly.
In either case, profit from carry will reduce to the extent that its no more worth time and effort on a risk adjusted basis, and the trade ends eventually.