-
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
Changes from 7 commits
ea165e5
4d4290a
2dd371c
ccee5b0
cfc9af3
7f97478
eb7ecf6
b139a61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,8 +230,6 @@ init() { | |
sudo chown -R ${CHE_USER} ${CHE_LOGS_DIR} | ||
fi | ||
|
||
|
||
export CHE_WORKSPACE_STORAGE=/data/workspaces | ||
export CHE_DATABASE=/data/storage | ||
export CHE_TEMPLATE_STORAGE=/data/templates | ||
export CHE_WORKSPACE_AGENT_DEV=${CHE_DATA_HOST}/lib/ws-agent.tar.gz | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to duplicate the property CHE_WORKSPACE_STORAGE ? also /data should be replaced by ${CHE_DATA} property There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because these are different paths? |
||
export CHE_WORKSPACE_STORAGE="${CHE_DATA_HOST}/workspaces" | ||
export CHE_WORKSPACE_STORAGE_CREATE_FOLDERS=false | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright (c) 2012-2017 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.workspace.infrastructure.docker.local.projects; | ||
|
||
import static org.eclipse.che.api.core.Pages.iterate; | ||
|
||
import com.google.inject.Inject; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.nio.file.StandardCopyOption; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Map.Entry; | ||
import org.eclipse.che.api.core.ServerException; | ||
import org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl; | ||
import org.eclipse.che.api.workspace.server.spi.WorkspaceDao; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Performs migration of workspace project files, that are stored in old format (in directories | ||
* named after their workspace name), so they will be stored in folders named after their workspace | ||
* ID. | ||
* | ||
* @author Mykhailo Kuznietsov | ||
*/ | ||
public class LocalProjectsMigrator { | ||
|
||
private final WorkspaceDao workspaceDao; | ||
|
||
@Inject | ||
public LocalProjectsMigrator(WorkspaceDao workspaceDao) { | ||
this.workspaceDao = workspaceDao; | ||
} | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. let's change it to |
||
Map<String, String> workspaceName2id = getId2NameWorkspaceMapping(); | ||
for (Entry<String, String> entry : workspaceName2id.entrySet()) { | ||
Path workspaceStoredByNameLocation = | ||
Paths.get(workspaceProjectsRootFolder).resolve(entry.getValue()); | ||
if (!Files.exists(workspaceStoredByNameLocation)) { | ||
// migration is not needed for this workspace | ||
continue; | ||
} | ||
LOG.debug( | ||
"Performing migration of workspace with id '{}' and name '{}'", | ||
entry.getKey(), | ||
entry.getValue()); | ||
Path workspaceStoredByIdLocation = | ||
Paths.get(workspaceProjectsRootFolder).resolve(entry.getKey()); | ||
try { | ||
Files.move( | ||
workspaceStoredByNameLocation, | ||
workspaceStoredByIdLocation, | ||
StandardCopyOption.ATOMIC_MOVE); | ||
LOG.info( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. |
||
"Successfully migrated projects of workspace with id '{}' and name '{}'", | ||
entry.getKey(), | ||
entry.getValue()); | ||
} catch (IOException e) { | ||
LOG.debug( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LOG.error |
||
"Failed to migrate projects of workspace with id '{}' and name '{}'", | ||
entry.getKey(), | ||
entry.getValue()); | ||
} | ||
} | ||
} | ||
|
||
private Map<String, String> getId2NameWorkspaceMapping() { | ||
try { | ||
Map<String, String> result = new HashMap<>(); | ||
|
||
for (WorkspaceImpl workspace : | ||
iterate( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
(maxItems, skipCount) -> workspaceDao.getWorkspaces(false, maxItems, skipCount))) { | ||
result.put(workspace.getId(), workspace.getConfig().getName()); | ||
} | ||
return result; | ||
} catch (ServerException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
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?