Umar (may Allah be pleased with him) took a vow in the pre-Islamic days to spend a night or a day in devotion near the Ka'bah (in the sacred mosque). He asked the Prophet ﷺ about it. He said: Observe i'tikaf (i.e. spend a night or a day near the Ka'bah) and fast.
أَنَّ عُمَرَ ؓ جَعَلَ عَلَيْهِ أَنْ يَعْتَكِفَ فِي الْجَاهِلِيَّةِ لَيْلَةً أَوْ يَوْمًا عِنْدَ الْكَعْبَةِ فَسَأَلَ النَّبِيَّ ﷺ فَقَالَ اعْتَكِفْ وَصُمْ