While upgrades most often come, as Donna says, in the two month time span before sailing, I have seen them given six months out, and I have seen people who receive an upgrade at the check in desk. Tiz a puzzlement.
The best theory is that the reservations department of any cruise line is a large room, full of eager young representatives with powerful computers, messing around with cabin assignments. Their principal function is to make Travel Agents tear their hair out and to say NO to upgrade requests. However, over in the corner is a rickety old desk with an obsolete computer system and a rotary dial phone. It belongs to an elderly clerk who is usually out on sick leave. But when she does come into the office, occasionally she lays her knitting down on the keyboard and it strikes a random key which gives an upgrade, sometimes a wonderful upgrade, to somebody. She is known as the UPGRADE FAIRY, and no living human being has any idea how she chooses the reservations that she touches with her magic. The best thing to do is to book a guarantee for a category that you will be fully satisfied with. If you wind up in that category be happy and enjoy your cruise. And if ... just IF ... the Upgrade Fairy touches you, then congratulate yourself that you are one of the lucky ones.