che icon indicating copy to clipboard operation
che copied to clipboard

WS not saving on server_che stop command

Open cifren opened this issue 9 years ago • 26 comments

When I stop the server with stop command, the WS that are still running and supposed to be saved and shutdown, do not keep their current state.

Reproduction Steps:

  1. Start server and a WS
  2. On WS apply a modification, for example edit .bashrc
  3. Stop server (don't shutdown the WS)
  4. Start the server and start the WS
  5. Watch your changes

Expected behavior:

The file should still have the modification

Observed behavior:

The WS loses the modification

Che version: nightly
OS and version: Boot2docker + win7
Docker version: 1.12.3, build 6b644ec
Che install: Docker container

Additional information:

  • Problem started happening recently, didn't happen in an older version of Che: yes
  • Problem can be reliably reproduced, doesn't happen randomly: no

cifren avatar Jan 06 '17 09:01 cifren

@cifren how do you stop the server? Just kill a container?

ghost avatar Jan 06 '17 10:01 ghost

I use this command line

docker run --rm -t $ECLIPSE_OPTIONS eclipse/che:$ECLIPSE_VERSION stop

cifren avatar Jan 06 '17 11:01 cifren

It is boot2docker - so what are the values of all options? This particular vm requires mounting in a special folder otherwise your data is lost.

TylerJewell avatar Jan 06 '17 12:01 TylerJewell

@cifren @TylerJewell this is expected behavior. If you think it is not, label it as bug.

The workspace is there, so it's not a mount issue. When che-server is stopped, we do not auto snapshot running workspaces.

ghost avatar Jan 06 '17 12:01 ghost

All my options

ECLIPSE_VERSION="nightly"
ECLIPSE_OPTIONS="-v /var/run/docker.sock:/var/run/docker.sock -v /c/Users/webide/che_nightly:/data"

Ok I would have thought that would have been the normal behavior for the server to save all WS and after shutdown the server... Or maybe a warning during the shutdown ?

cifren avatar Jan 06 '17 12:01 cifren

@cifren currently when server is stopped, workspaces are stopped without snapshotting.

ghost avatar Jan 06 '17 12:01 ghost

I thought we changed the default stop behavior in m3 to always auto snap? Are we saying that only happens if the user initiates the save not if the server is stopped? If so then I think we should change the default server config to follow the user config.

TylerJewell avatar Jan 06 '17 12:01 TylerJewell

@TylerJewell We snapshot the workspace if a workspace is stopped by a user and che properties tell server to do so. If a server is stopped, we do not snapshot running workspaces, just stop them.

ghost avatar Jan 06 '17 12:01 ghost

I consider this a bug as it is not expected behavior. The server should follow default behaviors of users. So if we snap when user stops then server stops should follow same path unless admin overrides it.

TylerJewell avatar Jan 06 '17 12:01 TylerJewell

@TylerJewell please label it as a bug then and assign to platform team.

ghost avatar Jan 06 '17 13:01 ghost

@skabashnyuk - it is reasonably expected that admins will expect server shutdown to stop all workspaces and for those workspaces to follow the default auto-snapshot setting within Che. There would then be a che.env property that would override this behavior so that a server stop would not necessarily follow the user configured action.

TylerJewell avatar Jan 06 '17 14:01 TylerJewell

@TylerJewell you want to snapshot workspaces during tomcat stop if it's configured in che.env? BTW tomcat has time limit to stop 3 minutes. After that it will be just kill -9

skabashnyuk avatar Jan 06 '17 15:01 skabashnyuk

Sorry, i could have written a better description.f

As a default behavior, when the Che (or Codenvy) server is stopped, we should respect the values set by the admin within che.env with the value CHE_WORKSPACE_AUTO__SNAPSHOT. If this value is true then a normal shutdown of Che server would be to stop each workspace and snapshot them. If false then it would be the behavior we have now.

We should allow admins a new variable, CHE_SHUTDOWN_SNAPSHOT_WORKSPACES=true/false which can ignore the other setting and provide an explicit behavior.

For che.env file:

# Che Server Auto Snapshot Override
#    When stopping the Che server, we will stop each workspace individually. These workspaces
#    may or may not be snapshot during their stop process. Default behavior is to follow the
#    setting applied to CHE_WORKSPACE_AUTO__SNAPSHOT, which is the auto behavior for end
#    users. You can set this value to override inheritance and explicitly define whether workspaces
#    should be snapshotted. Snapshotting is a time and resource intensive activity, so server 
#    shutdown can be slow if you have many running workspaces.
#CHE_SHUTDOWN_SNAPSHOT_WORKSPACES=true/false

TylerJewell avatar Jan 06 '17 19:01 TylerJewell

FYI It's potentially dangerous because we can't guarantee that all workspaces will be stopped+snapshotted in 3 minutes

skabashnyuk avatar Jan 06 '17 20:01 skabashnyuk

Or we can relay in CLI. Before stop it will stop+snapshot all workspaces and then call ws-master tomcat stop.

skabashnyuk avatar Jan 06 '17 20:01 skabashnyuk

Can you elaborate on where the 3 minute limitation came from? I woudl think that there is a shutdown procedure within Tomcat that can take as long as it requires.

TylerJewell avatar Jan 06 '17 20:01 TylerJewell

Basically we can't distinct very long stop and failed stop. To avoid situation when we can't stop tomcat we use stop method with timeout. After X minutes if tomcat process hasn't stopped it would be kill -9

skabashnyuk avatar Jan 06 '17 20:01 skabashnyuk

That explanation is clear. Maybe then we write it as a different specification (as you suggest) and we have cmd_stop() and cmd_restart() respect the the values in che.env. The downside of this scenario is that while eclipse/che-cli woudl repsect this logic, eclipse/che-server would not. So it seems unnatural.

How do we handle it with Codenvy On-Prem where we have distributed services managing the Codenvy tomcat?

TylerJewell avatar Jan 06 '17 21:01 TylerJewell

it's behaves the same as che.

skabashnyuk avatar Jan 12 '17 12:01 skabashnyuk

The more I think about this, the riskier I think it will be to handle such scenarios from within the CLI. In a Codenvy distributed scenario, or with Eclipse Che deployed on OpenShift, a "shutdown" even would have to be contained within the system itself. So we would have to develop a way to detect these events and then have various shutdown policies that the Che or Codenvy server respects, such as "time-based shutdown" or "wait for confirmation that all running workspaces have successfully stopped".

TylerJewell avatar Jan 12 '17 18:01 TylerJewell