Skip to content
DocsAll docs
Console

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.

PartDescriptionSee
WorkspacesThe workspaces created in the session. The session starts, stops and deletes them.Workspaces
SandboxesShort-lived sandboxes that run a command against the services of the environment.Sandboxes
EnvironmentThe environment that the workspaces reach. One per session, or none.Environment
InterceptsServices 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

stateMeaning
runningThe session is in use, or ready for use.
startingThe session is starting after a start or a wake.
idleThe session was not used for 30 minutes. Its workspaces are stopped.
stoppedYou 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 idle and its workspaces stop, with idle_since set. 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.

ItemLimit
Name1 to 40 lowercase letters, digits or -. Start with a letter, end with a letter or digit, no --. Unique for you in the team.
EnvironmentOne 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

Procedure

  1. Create the session. Use team/name for a team session, and set environment to connect one at once.

    Python
    from kloudlite import Kloudlitekl = Kloudlite()x = kl.sessions.create(session="dev", environment="shop")print(x["id"])
    TypeScript
    import { Kloudlite } from "./index.ts";const kl = new Kloudlite();const x: any = await kl.sessions.create({ session: "dev", environment: "shop" });console.log(x.id);
    Go
    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"])
    Ruby
    require_relative "kloudlite"kl = Kloudlite::Client.newputs kl.sessions.create(session: "dev", environment: "shop")["id"]
    Java
    var kl = new Kloudlite();System.out.println(kl.sessions().create(new Kloudlite.CreateSession().session("dev").environment("shop")));
    CLI
    kloudlite sessions create dev --environment shop

Close-out

  1. 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

Procedure

  1. Send a hold for the session, and repeat it at least every 60 seconds. The response is 204.

    Python
    sid = kl.sessions.get(session="dev")["id"]kl.request("POST", f"/v1/sessions/{sid}/hold")
    TypeScript
    const sid: string = ((await kl.sessions.get({ session: "dev" })) as any).id;await kl.request("POST", `/v1/sessions/${sid}/hold`);
    Go
    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)}
    Ruby
    sid = kl.sessions.get(session: "dev")["id"]kl.request("POST", "/v1/sessions/#{sid}/hold")
    Java
    // 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");
    CLI
    kloudlite request POST /v1/sessions/$(kloudlite sessions get dev --json | jq -r .id)/hold

Close-out

  1. 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

Procedure

  1. Set ttl_secs from 600 to 2592000. Set it to no value (None, null, nil) to clear it.

    Python
    kl.sessions.set_ttl(session="dev", ttl_secs=86400)
    TypeScript
    await kl.sessions.setTtl({ session: "dev", ttlSecs: 86400 });
    Go
    ttl := int64(86400)if _, err := kl.Sessions.SetTTL("dev", &ttl); err != nil {    log.Fatal(err)}
    Ruby
    kl.sessions.set_ttl(session: "dev", ttl_secs: 86400)
    Java
    kl.sessions().setTtl("dev", 86400L);
    CLI
    kloudlite sessions set-ttl dev --ttl-secs 86400

Close-out

  1. Make sure that expires_at shows 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

CAUTION

All workspaces in the session stop, and their processes end. Their homes are kept. The environment keeps running for other sessions.

Procedure

  1. Stop the session. Use team/name for a team session.

    Python
    kl.sessions.stop(session="dev")
    TypeScript
    await kl.sessions.stop({ session: "dev" });
    Go
    if _, err := kl.Sessions.Stop("dev"); err != nil {    log.Fatal(err)}
    Ruby
    kl.sessions.stop(session: "dev")
    Java
    kl.sessions().stop("dev");
    CLI
    kloudlite sessions stop --session dev

Close-out

  1. 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

CAUTION

The session's intercepts are released, and its workspaces are deleted. Snapshots and the environment remain.

Procedure

  1. Delete the session.

    Python
    kl.sessions.delete(session="dev")
    TypeScript
    await kl.sessions.delete({ session: "dev" });
    Go
    if err := kl.Sessions.Delete("dev"); err != nil {    log.Fatal(err)}
    Ruby
    kl.sessions.delete(session: "dev")
    Java
    kl.sessions().delete("dev");
    CLI
    kloudlite sessions delete dev

Close-out

  1. 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

Procedure

  1. Show the list. Pass a team to list the sessions of that team.

    Python
    print(kl.sessions.list())
    TypeScript
    console.log(await kl.sessions.list());
    Go
    list, err := kl.Sessions.List("")if err != nil {    log.Fatal(err)}fmt.Println(list)
    Ruby
    p kl.sessions.list
    Java
    System.out.println(kl.sessions().list(null));
    CLI
    kloudlite sessions list

Close-out

  1. Make sure that each session that you expect is listed.

Troubleshooting

SymptomPossible causeCorrective action
404 with not foundThe 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 acmeYou 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 startYou stopped the session.Run kloudlite --start.
A workspace of the session is stopped with idle_since setThe session went idle.Start the workspace, or send a hold.
the session did not open within 90 sThe 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 pausedA team administrator paused your access.Ask a team administrator to restore it.
no session picked: kloudlite sessions useNo 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 kloudlitekl-tui is missing from the folder of kloudlite.Reinstall kloudlite.