CIA chief Petraeus resigns over affair