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
Make snapshots binaries removal asynchronous #3405
Conversation
@@ -401,7 +402,9 @@ protected void onMessageReceived(WorkspaceStatusEvent statusEvent) { | |||
break; | |||
|
|||
case RUNNING: | |||
onWorkspaceStarted(workspaceId); | |||
if (statusEvent.getPrevStatus() == WorkspaceStatus.STARTING) { |
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.
explain this
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.
RUNNING
may be received twice, e.g.
1. STOPPED -> STARTING -> RUNNING
2. RUNNING -> SNAPSHOTTING -> RUNNING
onWorkspaceStarted(workspaceId)
obviously related to the 1st case
@@ -825,6 +710,14 @@ void checkWorkspaceIsRunning(WorkspaceImpl workspace, String operation) throws C | |||
} | |||
} | |||
|
|||
private void removeTmpWorkspace(Workspace workspace) { |
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.
removeTmpWorkspaceQuietly?
Build # 1337 - FAILED Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/1337/ to view the results. |
@@ -59,6 +60,7 @@ public WorkspaceImpl create(WorkspaceImpl workspace) throws ConflictException, S | |||
requireNonNull(workspace, "Required non-null workspace"); | |||
try { | |||
doCreate(workspace); | |||
eventService.publish(new WorkspaceCreatedEvent(workspace)); | |||
} catch (DuplicateKeyException dkEx) { |
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 sure we should do that in DAO? In that case it will reach subscribers even before manager ends execution of method that called DAO.
public void snapshot(String workspaceId) throws NotFoundException, | ||
ConflictException, | ||
ServerException { | ||
try (@SuppressWarnings("unused") CloseableLock l = locks.acquireWriteLock(workspaceId)) { |
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 didn't know how to suppress that, thanks for tip!
LOG.info("Shutdown running workspaces, workspaces to shutdown '{}'", idsToStop.size()); | ||
ExecutorService executor = | ||
Executors.newFixedThreadPool(2 * Runtime.getRuntime().availableProcessors(), | ||
new ThreadFactoryBuilder().setNameFormat("StopEnvironmentsPool-%d") |
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 catch uncaught exceptions
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.
Exceptions won't occur, task logs all the exceptiions see below.
verify(runtimes).publishWorkspaceEvent(EventType.ERROR, | ||
workspace.getId(), | ||
e.getLocalizedMessage()); | ||
DtoFactory.newDto(WorkspaceStatusEvent.class) |
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.
You probably forgot verification here
da5e733
to
28914da
Compare
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/1340/ |
28914da
to
b495d79
Compare
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/1342/ |
@@ -633,8 +614,11 @@ void performAsyncStart(WorkspaceImpl workspace, | |||
workspace.getAttributes().put(UPDATED_ATTRIBUTE_NAME, Long.toString(currentTimeMillis())); | |||
workspaceDao.update(workspace); | |||
final String env = firstNonNull(envName, workspace.getConfig().getDefaultEnv()); | |||
|
|||
// barrier, safely doesn't allow to start the workspace twice |
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.
Can you explain about which barrier here is described?
private final StripedLocks stripedLocks; | ||
private final CheEnvironmentEngine environmentEngine; | ||
private final Map<String, WorkspaceState> workspaces; | ||
private final EventService eventsService; |
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 it is better to name variable as eventsService
here?
7741032
to
92a90c2
Compare
92a90c2
to
cb45fa1
Compare
@Nullable Boolean restore) throws NotFoundException, | ||
ServerException, | ||
ConflictException { | ||
@Nullable String envName, |
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.
fix formatting here
cb45fa1
to
c9ec4b6
Compare
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/1351/ |
What does this PR do?
WorkspaceStatusEvent.RUNNING
after workspace changes status fromSNAPSHOTTING
back toRUNNING
WorkspaceStatusEvent
with previous workspace status fieldWhat issues does this PR fix or reference?
Resolves #3314 & resolves #3258.