This is a theme the scriptures return to time and again:
"My son, do not despise the LORD’s discipline, and do not resent his rebuke,
because the LORD disciplines those he loves, as a father the son he delights in" (Prov 3:11-12).
So:
"Endure hardship as discipline; God is treating you as his children. For what children are not disciplined by their father? If you are not disciplined—and everyone undergoes discipline—then you are not legitimate, not true sons and daughters at all. Moreover, we have all had human fathers who disciplined us and we respected them for it. How much more should we submit to the Father of spirits and live! They disciplined us for a little while as they thought best; but God disciplines us for our good, in order that we may share in his holiness. No discipline seems pleasant at the time, but painful. Later on, however, it produces a harvest of righteousness and peace for those who have been trained by it" (Heb 12:7-11).
For Jesus says, "Those whom I love I rebuke and discipline. So be earnest and repent. Here I am! I stand at the door and knock. If anyone hears my voice and opens the door, I will come in and eat with that person, and they with me" (Rev 3:19-20).
It's all the rage today to say, "God's not mad at you!" No, he really might be. But that's OK. When I am angry with my children over their behavior, I don't love them any less; I just want to correct their behavior. When God is angry with us over our behavior, he does not love us any less. He wants us to "repent and live" (Ez 18:32).
It is a glorious act of grace that God should choose to adopt us as his own children. He has said that we will be co-heirs with Christ. But that also means he will treat us as any good father will treat his erring children. His correction is part of his grace. He wants the best from us because that is the best for us. So we should respond to the grace of his discipline by quickly repenting and learning from our mistakes, to embrace growing up into the image of Christ.