Did the problem start immediately after upgrading to Windows 10? Does it just open and sit open? Or does it open and close, open and close, over and over again?
Are there any errors (yellow or red error icons) shown in Device Manager?
Typically, a malfunctioning drive tray means 1 of 2 things. (1) A loose cable, or (2), the drive is failing. So I would open the computer case and make sure the power and data cables are securely fastened on both ends of the cables.