CIA director Petraeus resigns over extramarital affair