Yeah, the first is correct because the question mark is related to the sentence as a whole, not the quote within the single quotation marks. Putting the closing single quotation mark outside of the question mark would be suggesting that that quote is a question, which it isn't. But yeah, it does all look a little awkward and messy and a rewrite wouldn't go astray.