Skip to content

Properly handle Devfile::CliError

Chad Woolley requested to merge caw-rd-add-flattener-domain-message into master

Issue: Rails: Handle devfile gem validation errors as ... (#419476 - closed)

What does this MR do and why?

Properly handle Devfile::CliError which is now raised by the devfile gem as of https://gitlab.com/gitlab-org/remote-development/devfile-gem/-/merge_requests/42+

  • Return as error message instead of allowing to raise

How to set up and validate locally

For workspace create

  1. Attempt to create a workspace with the invalid ee/spec/fixtures/remote_development/example.invalid-extra-field-devfile.yaml devfile added in this MR
  2. See that the proper error message from the CLI is displayed in the UI, e.g.: "failed to populateAndParseDevfile: invalid devfile schema. errors :\n- (root): Additional property random is not allowed\n"

For workspace reconcile

  1. Somehow cause an invalid processed_devfile in an existing workspace (directly edit in the database, add an invalid field to beginning of YAML)
  2. See that the warn error is logged
  3. Ensure that all workspaces in the reconcile request are still processed successfully and returned in rails_info, and no exception is allowed to be raised to abort the reconciliation.

Screenshots

For workspace create

See that error is now displayed in the UI:

Screenshot_2023-08-02_at_10.31.15_PM

For workspace reconcile

See warning, and subsequent FULL reconciliation with both workspaces returned successfully.

{
  "severity": "WARN",
  "time": "2023-08-03T05:49:11.868Z",
  "correlation_id": "01H6WZ2QG85AJ2MJSDMFGY8RJB",
  "meta.caller_id": "POST /api/:version/internal/kubernetes/modules/remote_development/reconcile",
  "meta.remote_ip": "172.16.123.1",
  "meta.feature_category": "remote_development",
  "meta.client_id": "ip/172.16.123.1",
  "message": "Error parsing devfile with Devfile::Parser.get_all",
  "error_type": "reconcile_devfile_parser_error",
  "workspace_name": "workspace-4-1-pirldg",
  "workspace_namespace": "gl-rd-ns-4-1-pirldg",
  "devfile_parser_error": "failed to populateAndParseDevfile: invalid devfile schema. errors :\n- (root): Additional property INVALID_KEY is not allowed\n"
}
{
  "severity": "DEBUG",
  "time": "2023-08-03T05:49:11.876Z",
  "correlation_id": "01H6WZ2QG85AJ2MJSDMFGY8RJB",
  "meta.caller_id": "POST /api/:version/internal/kubernetes/modules/remote_development/reconcile",
  "meta.remote_ip": "172.16.123.1",
  "meta.feature_category": "remote_development",
  "meta.client_id": "ip/172.16.123.1",
  "message": "Returning workspace_rails_infos",
  "agent_id": 4,
  "update_type": "full",
  "count": 2,
  "workspace_rails_infos": [
    {
      "name": "workspace-4-1-1cmygy",
      "namespace": "gl-rd-ns-4-1-1cmygy",
      "desired_state": "Stopped",
      "actual_state": "Stopped",
      "deployment_resource_version": "4195297"
    },
    {
      "name": "workspace-4-1-pirldg",
      "namespace": "gl-rd-ns-4-1-pirldg",
      "desired_state": "Running",
      "actual_state": "Stopped",
      "deployment_resource_version": "4195193"
    }
  ]
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Chad Woolley

Merge request reports