Skip to content
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

Add stopping by idle timeout for command-line-terminal #84

Merged
merged 2 commits into from
May 27, 2020

Conversation

sleshchenko
Copy link
Member

@sleshchenko sleshchenko commented May 26, 2020

What does this PR do?

This PR adds stopping by idle timeout for command-line-terminal.

It also fixes starting/stoping immutable workspace on OpenShift 4.5. Previously it failed with error:\

workspace 'terminal-0bpuux' is immutable. To make modifications it must be deleted and recreated"

I did not investigate changes on OpenShift API side with ManagedFields, just found different and fix an issue. We must get ourselves familiar with that part of object and how it's supposed to be used..

Open it if you want to see JSON that webhook server gets

OldWorkspace

{
  "kind": "Workspace",
  "apiVersion": "workspace.che.eclipse.org/v1alpha1",
  "metadata": {
    "name": "command-line-terminal",
    "namespace": "che-workspace-controller",
    "uid": "3a9903d1-ff48-45ad-8eaf-18af733d3806",
    "resourceVersion": "267365",
    "generation": 1,
    "creationTimestamp": "2020-05-27T07:31:50Z",
    "labels": {
      "console.openshift.io/cloudshell": "true",
      "org.eclipse.che.workspace/creator": ""
    },
    "annotations": {
      "kubectl.kubernetes.io/last-applied-configuration": "...",
      "org.eclipse.che.workspace/immutable": "true"
    }
  },
  "spec": {
    "started": true,
    "devfile": {
      "apiVersion": "1.0.0",
      "metadata": {
        "name": "command-line-terminal"
      },
      "attributes": {},
      "components": [
        {
          "type": "cheEditor",
          "alias": "command-line-terminal",
          "id": "che-incubator/command-line-terminal/4.5.0"
        }
      ]
    }
  },
  "status": {
    "workspaceId": "workspace3a9903d1ff4845ad",
    "phase": "Running",
    "ideUrl": "http://workspace3a9903d1ff4845ad-command-line-terminal-4444.apps.gamore45installer27thmay.devcluster.openshift.com",
    "conditions": [
      {
        "type": "ServiceAccountReady",
        "status": "True",
        "lastTransitionTime": "2020-05-27T08:05:20Z"
      },
      {
        "type": "RoutingReady",
        "status": "True",
        "lastTransitionTime": "2020-05-27T08:05:20Z"
      },
      {
        "type": "Ready",
        "status": "True",
        "lastTransitionTime": "2020-05-27T08:05:20Z"
      },
      {
        "type": "ComponentsReady",
        "status": "True",
        "lastTransitionTime": "2020-05-27T08:05:20Z"
      }
    ]
  }
}

newWorkspace

{
  "kind": "Workspace",
  "apiVersion": "workspace.che.eclipse.org/v1alpha1",
  "metadata": {
    "name": "command-line-terminal",
    "namespace": "che-workspace-controller",
    "uid": "3a9903d1-ff48-45ad-8eaf-18af733d3806",
    "resourceVersion": "267365",
    "generation": 1,
    "creationTimestamp": "2020-05-27T07:31:50Z",
    "labels": {
      "console.openshift.io/cloudshell": "true",
      "org.eclipse.che.workspace/creator": ""
    },
    "annotations": {
      "kubectl.kubernetes.io/last-applied-configuration": "....",
      "org.eclipse.che.workspace/immutable": "true"
    },
    "managedFields": [
      {
        "manager": "che-workspace-controller",
        "operation": "Update",
        "apiVersion": "workspace.che.eclipse.org/v1alpha1",
        "time": "2020-05-27T08:05:20Z",
        "fieldsType": "FieldsV1",
        "fieldsV1": {
          "f:status": {
            ".": {},
            "f:conditions": {},
            "f:ideUrl": {},
            "f:phase": {},
            "f:workspaceId": {}
          }
        }
      },
      {
        "manager": "kubectl",
        "operation": "Update",
        "apiVersion": "workspace.che.eclipse.org/v1alpha1",
        "time": "2020-05-27T08:05:32Z",
        "fieldsType": "FieldsV1",
        "fieldsV1": {
          "f:metadata": {
            "f:annotations": {
              ".": {},
              "f:kubectl.kubernetes.io/last-applied-configuration": {},
              "f:org.eclipse.che.workspace/immutable": {}
            },
            "f:labels": {
              ".": {},
              "f:console.openshift.io/cloudshell": {}
            }
          },
          "f:spec": {
            ".": {},
            "f:devfile": {
              ".": {},
              "f:apiVersion": {},
              "f:components": {},
              "f:metadata": {
                ".": {},
                "f:name": {}
              }
            },
            "f:started": {}
          }
        }
      }
    ]
  },
  "spec": {
    "started": false,
    "devfile": {
      "apiVersion": "1.0.0",
      "metadata": {
        "name": "command-line-terminal"
      },
      "attributes": {},
      "components": [
        {
          "type": "cheEditor",
          "alias": "command-line-terminal",
          "id": "che-incubator/command-line-terminal/4.5.0"
        }
      ]
    }
  },
  "status": {
    "workspaceId": "workspace3a9903d1ff4845ad",
    "phase": "Running",
    "ideUrl": "http://workspace3a9903d1ff4845ad-command-line-terminal-4444.apps.gamore45installer27thmay.devcluster.openshift.com",
    "conditions": [
      {
        "type": "ServiceAccountReady",
        "status": "True",
        "lastTransitionTime": "2020-05-27T08:05:20Z"
      },
      {
        "type": "RoutingReady",
        "status": "True",
        "lastTransitionTime": "2020-05-27T08:05:20Z"
      },
      {
        "type": "Ready",
        "status": "True",
        "lastTransitionTime": "2020-05-27T08:05:20Z"
      },
      {
        "type": "ComponentsReady",
        "status": "True",
        "lastTransitionTime": "2020-05-27T08:05:20Z"
      }
    ]
  }
}

What issues does this PR fix or reference?

It along with eclipse-che/che-machine-exec#106 fixes eclipse-che/che#16683

Is it tested? How?

  1. Configure idle_timeout to some easy to test value, like che.workspace.idle_timeout: 59s.
  2. Start command line terminal workspace.
  3. Watch command line terminal logs.
  4. Make sure the workspace is stopped after idle timeout is reached.
    Screenshot_20200526_153602

I also tested that workspace is not stopped that activity it reported:
Screenshot_20200527_121041

@sleshchenko sleshchenko self-assigned this May 26, 2020
Copy link
Contributor

@JPinkney JPinkney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Tested locally without issues.

@sleshchenko

This comment has been minimized.

…se it (devfile#84)

Signed-off-by: Sergii Leshchenko <sleshche@redhat.com>
Signed-off-by: Sergii Leshchenko <sleshche@redhat.com>
@sleshchenko sleshchenko merged commit a359c5f into devfile:master May 27, 2020
@sleshchenko sleshchenko deleted the inactivity branch May 27, 2020 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[devworkspace] Investigate the scale-to-zero after a period of inactivity
3 participants