-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change worskpace project files storage path #7844
Conversation
ci-test |
ci-test build report: |
@@ -42,6 +42,10 @@ | |||
<groupId>com.google.inject.extensions</groupId> | |||
<artifactId>guice-multibindings</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-io</groupId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove it
@@ -61,6 +74,11 @@ public void setUp() throws Exception { | |||
oldWorkspacesRoot = Paths.get(workspacesRoot, "oldWorkspacesRoot").toString(); | |||
} | |||
|
|||
@AfterMethod | |||
public void tearDown() throws Exception { | |||
FileUtils.deleteDirectory(workspacesRootFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IoUtil.deleteRecursive
} | ||
|
||
public String getPathByName(String workspaceName) throws IOException { | ||
public String getPathByName(String workspaceName, String workspaceNamespace) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this method
workspaceStoredByIdLocation, | ||
StandardCopyOption.ATOMIC_MOVE); | ||
LOG.info( | ||
"Successfully workspace with id '{}' and name '{}'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this message more clear
workspaceManagerProvider | ||
.get() | ||
.getByNamespace(account.getName(), false) | ||
Lists.newArrayList( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too complex
@@ -48,7 +51,13 @@ public WorkspaceResourceUsageTracker( | |||
throws NotFoundException, ServerException { | |||
final Account account = accountManager.getById(accountId); | |||
final List<WorkspaceImpl> accountWorkspaces = | |||
workspaceManagerProvider.get().getByNamespace(account.getName(), false); | |||
Lists.newArrayList( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too complex
* Get all workspaces, and check if they are stored in workspacesMountPoint by their name, and | ||
* migrate them, so they will be stored by id | ||
*/ | ||
private void performWorkspaceLocationMigration() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to keep all the logic in a separate class.
@@ -225,7 +227,12 @@ public WorkspaceDto getByKey( | |||
// TODO add maxItems & skipCount to manager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this todo is not needed anymore
|
||
assertEquals(new HashSet<>(found), new HashSet<>(asList(workspace1, workspace2))); | ||
assertEquals(new HashSet<>(found.getItems()), new HashSet<>(asList(workspace1, workspace2))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you going to add new tests for checking the new functionality?
workspace.getId(), | ||
e.getLocalizedMessage()); | ||
} | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check if this semicolon is needed here
remover.removeTemporaryWs(); | ||
|
||
verify(workspaceDao, times(COUNT_OF_WORKSPACES)).remove(anyString()); | ||
verify(workspaceDao, times(250)).remove(anyString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be better to use constant here
ci-test |
ci-test build report: |
@@ -209,4 +231,9 @@ private void ensureExist(String path, String prop) throws IOException { | |||
} | |||
} | |||
} | |||
|
|||
/** | |||
* Get all workspaces, and check if they are stored in workspacesMountPoint by their name, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check that this comment is located in correct place.
Signed-off-by: Oleksandr Garagatyi <ogaragat@redhat.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Few minor things left.
} | ||
// | ||
// @Test | ||
// public void shouldMigrateOnlyWorkspacesWithOldLocation() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, fix commented test
workspace.getId(), | ||
e.getLocalizedMessage()); | ||
} | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkuznyetsov Please, take a look
|
||
/** | ||
* Performs migration of projects that are stored for workspace in directories, named respectively | ||
* by their names, to new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is something missing after to new
?
workspaceStoredByNameLocation, | ||
workspaceStoredByIdLocation, | ||
StandardCopyOption.ATOMIC_MOVE); | ||
LOG.info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change info level here to debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, stay with info. We need to provide this information to the user.
// migration is not needed for this workspace | ||
continue; | ||
} | ||
LOG.info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change info level here to debug and add LOG.info with a message that migration stated before the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Map<String, String> result = new HashMap<>(); | ||
|
||
for (WorkspaceImpl workspace : | ||
iterate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iterate will eager fetch all objects from a database. I'd be nice to check how many memory it will consume when a number of workspaces is like 50 000 or the same as we have on codenvy.io
.
If quite a lot then we should fetch workspace ids and names only. Something like that we've already done for another migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's unnecessary, I don't think there will ever happen a migration of significant size of workspaces, ever.
@@ -292,6 +292,11 @@ che.infra.docker.bootstrapper.installer_timeout_sec=180 | |||
# Once servers for one installer available - checks stopped. | |||
che.infra.docker.bootstrapper.server_check_period_sec=3 | |||
|
|||
# Enable to perform migration of workpace projects at Che startup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be only for che.infra.docker ? (prefix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I was not able to protect such a naming when Tyler did choose another naming technique. I don't remember that anyone was supporting me at that point. Does it seem better now?
@@ -246,6 +244,7 @@ init() { | |||
export CHE_DOCKER_IP_EXTERNAL=${HOSTNAME} | |||
fi | |||
### Necessary to allow the container to write projects to the folder | |||
export CHE_WORKSPACE_STORAGE__MASTER__PATH=/data/workspaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to duplicate the property CHE_WORKSPACE_STORAGE ?
so we have
CHE_WORKSPACE_STORAGE__MASTER__PATH=/data/workspaces
and
CHE_WORKSPACE_STORAGE="${CHE_DATA_HOST}/workspaces"
also /data should be replaced by ${CHE_DATA} property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because these are different paths?
Please change target branch of this pr to master branch. |
workspaceStoredByNameLocation, | ||
workspaceStoredByIdLocation, | ||
StandardCopyOption.ATOMIC_MOVE); | ||
LOG.info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, stay with info. We need to provide this information to the user.
entry.getKey(), | ||
entry.getValue()); | ||
} catch (IOException e) { | ||
LOG.debug( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG.error
), | ||
@NamedQuery( | ||
name = "Workspace.getByTemporaryCount", | ||
query = "SELECT COUNT(w) " + "FROM Workspace w " + "WHERE w.isTemporary = :temporary " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure we have separate index on isTemporary field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index_workspace_istemporary exists. Nevermind
private static final Logger LOG = LoggerFactory.getLogger(LocalProjectsMigrator.class); | ||
|
||
public void performMigration(String workspaceProjectsRootFolder) { | ||
LOG.debug("Starting migration of workspace project files"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's change it to info
Could we have a documentation on how to migrate ?
|
So now when a user wants to explore content of a workspace - he has to know the workspace id ? |
@slemeur no it's just the inderlying host folder name |
it needs a release note for users who have existing workspaces, notify them that migration is needed. |
In this case, no action needed from the user, everything is going to happen automatically.
Yes and no. If use specifies |
What does this PR do?
to prevent issues with workspace renaming. Applies to Docker infrastructure only.
What issues does this PR fix or reference?
should fix #3574
Changelog
Workspace projects are stored in folders, named after their workspace ID (previously, after their workspace name
Release Notes
N/A
Docs PR
N/A