Jesus learned obedience.
Again God's foreknowledge is not compunction... you do understand that God is outside of time.
You might argue that individual salvation is not due to election out in eternity past.
But there is absolutely no way anybody is ever going to argue that Jesus HIMSELF was not elect and foreordained by the determined plan and will of God from eternity past.
As for "learning obedience", that is debatable if not outright doubtful. Jesus
has been obedient and perfectly obedient from eternity past. He was chosen for the task of redemption because He
would be obedient in the future. He is the Holy God after all.
In my opinion, what Hebrews 5:8 is intended to say is that Jesus learned and experienced
a yet greater aspect, dimension, perhaps form of obedience while in His pilgrimage here on planet earth. This is the
very reason that Jesus' Name is now glorified even more greatly than it was before!