It is narrated from Ibn Umar (may Allah be pleased with them both) that Umar (may Allah be pleased with him) made a vow to perform i'tikaf (seclusion) in the Mosque al-Haram during the period of ignorance. He asked the Prophet ﷺ, so the Prophet ﷺ instructed him to fulfill his i'tikaf in Islam.
Hadith Referenceمسند الإمام الشافعي / كتاب النذور / 1041
Hadith Takhrijاخرجه البخاري، الاعتكاف، باب من لم ير عليه اذا اعتكف، صومًا (2042) ، (2043) ومسلم، الأيمان ، باب نذر الكافر، وما يفعل فيه اذا اسلم (1656)۔