The UN Human Rights Committee stated that detention in the course of proceedings for the control of immigration is not per se arbitrary, but the detention must be justified as reasonable, necessary and proportionate in the light of the circumstances and reassessed as it extends in time.
Source: official link