Sessions
Create, stop and end sessions, the network groups that join workspaces to an environment.
Last updated
On this page
Description and operation
General
A session is a network group. It joins a set of workspaces to one environment, so that each workspace reaches the services of the environment by name, for example postgres://db:5432. Code in a workspace runs against the real dependencies of the application, with no local set-up.
A session belongs to the person who creates it, in their personal team or in a team. Other members of the team cannot see or change it. They work in their own sessions, which can connect to the same environment.
| Part | Description | See |
|---|---|---|
| Workspaces | The workspaces created in the session. The session starts, stops and deletes them. | Workspaces |
| Sandboxes | Short-lived sandboxes that run a command against the services of the environment. | Sandboxes |
| Environment | The environment that the workspaces reach. One per session, or none. | Environment |
| Intercepts | Services of the environment whose traffic goes to a workspace of the session. | Intercepts |
Sessions let several developers work on one environment at the same time, each in their own session. See Use cases.
A session has a name: name for a personal session, team/name for a team session. Its id starts with ses-.
States
state | Meaning |
|---|---|
running | The session is in use, or ready for use. |
starting | The session is starting after a start or a wake. |
idle | The session was not used for 30 minutes. Its workspaces are stopped. |
stopped | You stopped the session. Its workspaces are stopped. |
Lifecycle
- Use. A session is in use while any of its workspaces is in use: an SSH connection, a tool request or a running sandbox. A detached process does not count.
- Idle stop. After 30 minutes without use, the session is
idleand its workspaces stop, withidle_sinceset. Its environment stops 5 minutes later, unless another awake session is connected to it. - Wake. Starting a workspace of the session, creating a workspace in it, connecting an environment or sending a hold wakes the session and its environment. A wake never starts a resource that you stopped yourself.
- Stop. Stopping a session stops all its workspaces. Their homes are kept. Starting the session starts them again.
- Time to live. The platform deletes a session that is not used for
ttl_secs(600 to 2592000). An awake session never expires. - End. Ending a session releases its intercepts and deletes its workspaces. Their snapshots and the environment remain.
Quota and limits
A running session uses 2 vCPU and 4 GB of memory from the owner's quota, and 10 GB of disk at all times. Its workspaces and its environment count separately.
| Item | Limit |
|---|---|
| Name | 1 to 40 lowercase letters, digits or -. Start with a letter, end with a letter or digit, no --. Unique for you in the team. |
| Environment | One per session, of the session's own team. |
Tasks
Create a session
Reason for the task: Start a working context for your workspaces.
Job set-up
- Access: you.
- References:
POST /v1/sessions.
Procedure
Create the session. Use
team/namefor a team session, and setenvironmentto connect one at once.from kloudlite import Kloudlitekl = Kloudlite()x = kl.sessions.create(session="dev", environment="shop")print(x["id"])import { Kloudlite } from "./index.ts";const kl = new Kloudlite();const x: any = await kl.sessions.create({ session: "dev", environment: "shop" });console.log(x.id);kl := kloudlite.New(kloudlite.Options{})x, err := kl.Sessions.Create(kloudlite.CreateSession{Session: "dev", Environment: "shop"})if err != nil { log.Fatal(err)}fmt.Println(x["id"])require_relative "kloudlite"kl = Kloudlite::Client.newputs kl.sessions.create(session: "dev", environment: "shop")["id"]var kl = new Kloudlite();System.out.println(kl.sessions().create(new Kloudlite.CreateSession().session("dev").environment("shop")));kloudlite sessions create dev --environment shop
Close-out
- Make sure that the session is in
kloudlite sessions list.
Keep a session awake
Reason for the task: Prevent an idle stop while you work outside kloudlite and the session.
Job set-up
- Access: you.
- References:
POST /v1/sessions/{id}/hold.
Procedure
Send a hold for the session, and repeat it at least every 60 seconds. The response is
204.sid = kl.sessions.get(session="dev")["id"]kl.request("POST", f"/v1/sessions/{sid}/hold")const sid: string = ((await kl.sessions.get({ session: "dev" })) as any).id;await kl.request("POST", `/v1/sessions/${sid}/hold`);s, err := kl.Sessions.Get("dev")if err != nil { log.Fatal(err)}if err := kl.Request("POST", "/v1/sessions/"+s["id"].(string)+"/hold", kloudlite.RequestOptions{}); err != nil { log.Fatal(err)}sid = kl.sessions.get(session: "dev")["id"]kl.request("POST", "/v1/sessions/#{sid}/hold")// The client returns raw JSON; read "id" with your JSON library.var s = kl.sessions().get("dev");int k = s.indexOf("\"id\":\"") + 6;kl.request("POST", "/v1/sessions/" + s.substring(k, s.indexOf('"', k)) + "/hold");kloudlite request POST /v1/sessions/$(kloudlite sessions get dev --json | jq -r .id)/hold
Close-out
- Make sure that the session's workspaces are not
stopped.
Set the time to live
Reason for the task: End a session automatically after a period without use.
Job set-up
- Access: you.
- References:
PUT /v1/sessions/{id}/ttl.
Procedure
Set
ttl_secsfrom 600 to 2592000. Set it to no value (None,null,nil) to clear it.kl.sessions.set_ttl(session="dev", ttl_secs=86400)await kl.sessions.setTtl({ session: "dev", ttlSecs: 86400 });ttl := int64(86400)if _, err := kl.Sessions.SetTTL("dev", &ttl); err != nil { log.Fatal(err)}kl.sessions.set_ttl(session: "dev", ttl_secs: 86400)kl.sessions().setTtl("dev", 86400L);kloudlite sessions set-ttl dev --ttl-secs 86400
Close-out
- Make sure that
expires_atshows a time, or no value if you cleared it.
Stop a session
Reason for the task: Release the compute of a session and keep its data.
Job set-up
- Access: you.
- References:
POST /v1/sessions/{id}/stop.
All workspaces in the session stop, and their processes end. Their homes are kept. The environment keeps running for other sessions.
Procedure
Stop the session. Use
team/namefor a team session.kl.sessions.stop(session="dev")await kl.sessions.stop({ session: "dev" });if _, err := kl.Sessions.Stop("dev"); err != nil { log.Fatal(err)}kl.sessions.stop(session: "dev")kl.sessions().stop("dev");kloudlite sessions stop --session dev
Close-out
- Make sure that the session and its workspaces show
stopped.
End a session
Reason for the task: Remove a session that you no longer need.
Job set-up
- Access: you.
- References:
DELETE /v1/sessions/{id}.
The session's intercepts are released, and its workspaces are deleted. Snapshots and the environment remain.
Procedure
Delete the session.
kl.sessions.delete(session="dev")await kl.sessions.delete({ session: "dev" });if err := kl.Sessions.Delete("dev"); err != nil { log.Fatal(err)}kl.sessions.delete(session: "dev")kl.sessions().delete("dev");kloudlite sessions delete dev
Close-out
- Make sure that the session is no longer in
kloudlite sessions list.
List sessions
Reason for the task: Find the sessions that you can use.
Job set-up
- Access: you.
- References:
GET /v1/sessions,kloudlite sessions list.
Procedure
Show the list. Pass a team to list the sessions of that team.
print(kl.sessions.list())console.log(await kl.sessions.list());list, err := kl.Sessions.List("")if err != nil { log.Fatal(err)}fmt.Println(list)p kl.sessions.listSystem.out.println(kl.sessions().list(null));kloudlite sessions list
Close-out
- Make sure that each session that you expect is listed.
Troubleshooting
| Symptom | Possible cause | Corrective action |
|---|---|---|
404 with not found | The session or workspace does not exist, or is not yours. | Check the name. Use team/name for a team. |
409 with you already have a session named dev in acme | You already have a session with this name in the team. | Use another name, or end the old session. |
409 with the session is stopped; start it with start | You stopped the session. | Run kloudlite --start. |
A workspace of the session is stopped with idle_since set | The session went idle. | Start the workspace, or send a hold. |
the session did not open within 90 s | The session needs more time, or there is no capacity. | Run the command again. If it persists, check your quota. |
403 with your access to acme is paused | A team administrator paused your access. | Ask a team administrator to restore it. |
no session picked: kloudlite sessions use | No session is selected for this team. | Run kloudlite sessions use NAME. |
no session dev; yours: and a list | --session names none of your sessions in this team. | Use a name or id from the list. |
kl-tui must be installed beside kloudlite | kl-tui is missing from the folder of kloudlite. | Reinstall kloudlite. |