Unable to change to a certain username because of stale directories on filesystem
Summary
We discovered a case where the username for any account could not be changed to the username "iDanoo" because doing so resulted in a 500 error. This caused a problem for one of our users who wanted to use the name but was not able to.
Steps to reproduce
We don't know how the system ended up in a state (i.e. stale directories left on the filesystem; see below) where it started causing this problem. The stale directories where deleted manually by @stanhu and this resolved the issue.
Expected behavior
User should be able to change their username to any valid username.
Actual behavior
The user got a 500 error when they tried to change their username to iDanoo. The reason was because iDanoo existed before at some point and was then deleted, but the directories for the user were left on the filesystem. When GitLab tried to move the current username directories to the new username directories (which already existed, but were empty), the move operation failed, resulting in a 500 error.
I tried changing my username to iDanoo. The Sentry error can be seen here: https://sentry.gitlap.com/gitlab/gitlabcom/issues/10328/
The actual user ticket: https://gitlab.zendesk.com/agent/tickets/49866
Possible fixes
If the directories exist already and are empty, perhaps we should automatically just prune them. The problematic line of code can be seen on Sentry: https://sentry.gitlap.com/gitlab/gitlabcom/issues/10328/