-
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
CHE-274 - Improve idling implementation #5512
Conversation
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/2973/ |
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 suppose there is a pending PR on codenvy repository as well ?
linked to codenvy/codenvy#2297 |
@slemeur I think there is some doc required |
added eclipse-che/che-docs#253 |
# Idle Timeout | ||
# The system will suspend the workspace and snapshot it if the end user is idle for | ||
# this length of time. Idleness is determined by the length of time that a user has | ||
# not interacted with the workspace, meaning that one of our agents has not received |
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.
One of the agents or any?
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.
removed this part
@@ -115,6 +115,14 @@ che.workspace.agent.dev.ping_timeout_error_msg=Timeout. The Che server is unable | |||
che.agent.dev.max_start_time_ms=120000 | |||
che.agent.dev.ping_delay_ms=2000 | |||
|
|||
# Idle Timeout | |||
# The system will suspend the workspace and snapshot it if the end user is idle for | |||
# this length of time. Idleness is determined by the length of time that a user has |
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 rather use amount of time
instead of length of time
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.
thx, fixed
# not interacted with the workspace, meaning that one of our agents has not received | ||
# instructions. Leaving a browser window open counts as idleness time. | ||
che.machine.ws.agent.inactive.stop.timeout.ms=3600000 | ||
stop.workspace.scheduler.period=60 |
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 prepend property name with che.
and add measurement unit as a suffix of the 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.
changed property name
# this length of time. Idleness is determined by the length of time that a user has | ||
# not interacted with the workspace, meaning that one of our agents has not received | ||
# instructions. Leaving a browser window open counts as idleness time. | ||
che.machine.ws.agent.inactive.stop.timeout.ms=3600000 |
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.
Part of a term that means single area are usually divided by underscores, e.g. che.machine.wsagent.inactive_stop_timeout_ms
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.
changed property name
import java.io.IOException; | ||
|
||
/** | ||
* Counts every request to the agent as a workspace activity |
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.
Does it count frames in case of WebSocket connection or only connection itself?
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 would only react on HTTP requests going through the filter, updated Javadoc
* @author Mihail Kuznyetsov | ||
*/ | ||
@Singleton | ||
public class LastAccessTimeFilter implements Filter { |
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.
If this class is related to wsagent let's move it to wsagent related module
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.
Moved to a separate module
* @author Mihail Kuznyetsov | ||
*/ | ||
@Singleton | ||
public class LastAccessTimeFilter implements Filter { |
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 add tests
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.
Added tests
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.
Mostly OK, but, please, add tests and take a look on my comments
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
/** | ||
* Notifies master about activity in workspace, but not more often than once per minute. |
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, correct javadocs as actual notification threshold is configurable now.
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.
Javadoc updated
* @author Anton Korneta | ||
*/ | ||
@Singleton | ||
public class WorkspaceActivityNotifier { |
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.
If this class is related to wsagent let's move it to wsagent related module
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.
Moved to separate module
import com.google.inject.Inject; | ||
|
||
/** | ||
* Stops the inactive workspaces by given expiration time. |
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.
As far as I can see this class not only stops workspaces but provides API for updating workspace activity timestamp. Can you rephrase javadocs in accordance with that?
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.
Javadoc updated
workspaceManager.updateWorkspace(workspaceId, workspace); | ||
workspaceManager.stopWorkspace(workspaceId); | ||
} catch (NotFoundException e) { | ||
LOG.info("Workspace already stopped"); |
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 ignore this exception - there is no need to log it
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/3028/ |
import com.google.inject.Inject; | ||
|
||
/** | ||
* Stops the inactive workspaces by given expiration time. Upon stopping, workspace attributes will be updated with |
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 also provides API for WS activity timestamp updates
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.
Corrected
import static org.eclipse.che.api.core.model.workspace.WorkspaceStatus.RUNNING; | ||
|
||
/** | ||
* Monitors the activity of the runtime 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.
It doesn't monitor activity itself, but rather provides API for WS activity timestamp updates
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.
Corrected
} | ||
|
||
@Test | ||
public void shouldLogExceptionUponActivityNotification() throws IOException, ServletException { |
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.
This test doesn't check logging - it ensures that an exception that can be thrown by activity call doesn't prevent the call of the chain. So, please, rename test and verify the call of the chain.
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.
fixed name
// when | ||
filter.doFilter(request, response, chain); | ||
// then | ||
verify(workspaceActivityNotifier).onActivity(); |
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, also verify the call of the chain.
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.
fixed
@ApiResponses(@ApiResponse(code = 204, message = "Activity counted")) | ||
public void active(@ApiParam(value = "Workspace id") | ||
@PathParam("wsId") String wsId) throws ForbiddenException, NotFoundException, ServerException { | ||
final WorkspaceImpl workspace = workspaceManager.getWorkspace(wsId); |
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, add tests
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.
Added WorkspaceActivityServiceTest
|
||
|
||
@Inject | ||
public WorkspaceActivityNotifier(HttpJsonRequestFactory httpJsonRequestFactory, |
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, add tests
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.
Added WorkspaceActivityNotifierTest
* @author Mihail Kuznyetsov | ||
* @author Anton Korneta | ||
*/ | ||
public class WorkspaceWebsocketMessageReceiver implements WSMessageReceiver { |
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, add tests
* @author Anton Korneta | ||
*/ | ||
@Singleton | ||
public class WorkspaceActivityManager { |
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, add tests
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.
Added WorkspaceActivityManagerTest
Build # 3037 - FAILED Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/3037/ to view the results. |
Build # 3044 - FAILED Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/3044/ to view the results. |
…rove idling implementation
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/3045/ |
…4 - Improve idling implementation
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/3052/ |
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/3054/ |
* CHE-274 - Improve idling implementation Signed-off-by: Snjezana Peco <[email protected]> * CHE-274 - Improve idling implementation * fixup! CHE-274 - Improve idling implementation * fixup! fixup! CHE-274 - Improve idling implementation * fixup! fixup! fixup! CHE-274 - Improve idling implementation * fixup! fixup! fixup! fixup! CHE-274 - Improve idling implementation * fixup! fixup! fixup! fixup! fixup! CHE-274 - Improve idling implementation * fixup! fixup! fixup! fixup! fixup! fixup! CHE-274 - Improve idling implementation * fixup! fixup! fixup! fixup! fixup! fixup! fixup! CHE-274 - Improve idling implementation * fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! CHE-274 - Improve idling implementation * fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! CHE-274 - Improve idling implementation * fixup
What does this PR do?
Enable workspace shutdown after a specified inactivity period.
What issues does this PR fix or reference?
This is a copy of PR #5386 with minor fixes
https://issues.jboss.org/browse/CHE-274
Changelog
Added workspace idling tracking, that will shutdown workspaces, which are inactive over a period of time, configured by "che.machine.ws.agent.inactive.stop.timeout.ms" property. Tracking is scheduled to perform in intervals, defined by "stop.workspace.scheduler.period" property.
Release Notes
Per default, a workspace will be stopped after one hour of inactivity.
Docs PR
eclipse-che/che-docs#253
See #5386