LG fridge works for 1-2 weeks and gets warm

Our LG fridge is 6 years old and about a month ago, I noticed freezer was not getting as cold and all the ice melted. I called a technician but suddenly fridge started working again after a day so I cancelled the service call.

Fridge worked normal for 2 weeks but it is having the same symptom again. Freezer is not cold enough.

Do I need to change my defrost sensor and thermostat? Main board?

As the appliance is resetting itself, likely from the power cord being unplugged for a few minutes and then being plugged back in, the failure would most likely be the main control.