Skip to content
Snippets Groups Projects

Rails: Introduce/support kubernetes error type in reconciliation API

Merged Hunar Khanna requested to merge hkhanna2_introduce_error_type_20231017 into master

Issue: #428624 (closed)

What does this MR do and why?

  • Adds support for new error type kubernetes
  • Update relevant specs to verify support

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

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 Hunar Khanna

Merge request reports

Merged results pipeline #1061855021 passed

Pipeline: GitLab

#1061856314

    Pipeline: GitLab

    #1061856309

      Pipeline: GitLab

      #1061856307

        Merged results pipeline passed for d4454ea3

        Approval is optional

        Merged by Chad WoolleyChad Woolley 1 year ago (Nov 6, 2023 5:03am UTC)

        Merge details

        • Changes merged into master with 3df0c57c (commits were squashed).
        • Deleted the source branch.
        • Auto-merge enabled

        Pipeline #1061902120 failed

        Pipeline failed for 3df0c57c on master

        Test coverage 66.69% from 0 jobs
        10 environments impacted.

        Activity

        Filter activity
        • Approvals
        • Assignees & reviewers
        • Comments (from bots)
        • Comments (from users)
        • Commits & branches
        • Edits
        • Labels
        • Lock status
        • Mentions
        • Merge request status
        • Tracking
        • Hunar Khanna changed milestone to %16.6

          changed milestone to %16.6

        • assigned to @hkhanna2

        • Hunar Khanna changed title from Draft: Rails: Introduce/support error type in reconciliation API to Draft: Rails: Introduce/support kubernetes error type in reconciliation API

          changed title from Draft: Rails: Introduce/support error type in reconciliation API to Draft: Rails: Introduce/support kubernetes error type in reconciliation API

        • Hunar Khanna added 1 commit

          added 1 commit

          Compare with previous version

        • A deleted user added backend label

          added backend label

        • Contributor

          Allure report

          allure-report-publisher generated test report!

          e2e-test-on-gdk: :white_check_mark: test report for 794b97b1

          expand test summary
          +-----------------------------------------------------------------------+
          |                            suites summary                             |
          +------------------+--------+--------+---------+-------+-------+--------+
          |                  | passed | failed | skipped | flaky | total | result |
          +------------------+--------+--------+---------+-------+-------+--------+
          | Verify           | 32     | 0      | 0       | 0     | 32    | ✅     |
          | Govern           | 48     | 0      | 0       | 0     | 48    | ✅     |
          | Create           | 40     | 0      | 6       | 0     | 46    | ✅     |
          | Plan             | 55     | 0      | 0       | 0     | 55    | ✅     |
          | Data Stores      | 22     | 0      | 0       | 0     | 22    | ✅     |
          | Monitor          | 4      | 0      | 0       | 0     | 4     | ✅     |
          | Package          | 0      | 0      | 1       | 0     | 1     | ➖     |
          | Framework sanity | 0      | 0      | 1       | 0     | 1     | ➖     |
          | Manage           | 0      | 0      | 1       | 0     | 1     | ➖     |
          +------------------+--------+--------+---------+-------+-------+--------+
          | Total            | 201    | 0      | 9       | 0     | 210   | ✅     |
          +------------------+--------+--------+---------+-------+-------+--------+
          Edited by Ghost User
        • mentioned in issue #428624 (closed)

        • Hunar Khanna changed the description

          changed the description

        • 🤖 GitLab Bot 🤖 resolved all threads

          resolved all threads

        • requested review from @cwoolley-gitlab

          • Resolved by Chad Woolley

            @hkhanna2 praise thanks for drying up the specs some.

            Here's a patch that cleans up the spec even more.

            The general idea behind this refactor is "don't declare fixtures in scopes where they are not used", which is a good general idea, but not a hard rule if it makes things convoluted/complex. But in this case we can do it and it's cleaner and more expressive, IMO.

            The main changes in this are:

            1. Don't implicitly test the "applier" case as the default value for error_type, remove the default and push it down only to the contexts where it's needed/used.
            2. Introduce a context under the valid case to be explicit about the "applier" type. This helps the tests serve as documentation.
            3. In the invalid contexts, we only need to specify error_type where it's needed/used. In one of them we can now just override error_type instead of the whole error details.
            4. Use the constants for the values rather than hardcoding them. Type safety is good, it will show errors in the tests if they are changed. Now if we could only have enum types ;)
            Index: ee/spec/lib/remote_development/workspaces/reconcile/input/params_validator_spec.rb
            IDEA additional info:
            Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
            <+>UTF-8
            ===================================================================
            diff --git a/ee/spec/lib/remote_development/workspaces/reconcile/input/params_validator_spec.rb b/ee/spec/lib/remote_development/workspaces/reconcile/input/params_validator_spec.rb
            --- a/ee/spec/lib/remote_development/workspaces/reconcile/input/params_validator_spec.rb	(revision 6ff3de5ee961f7fdd154d8242bf0522fe8f04311)
            +++ b/ee/spec/lib/remote_development/workspaces/reconcile/input/params_validator_spec.rb	(date 1697693080099)
            @@ -6,7 +6,6 @@
               include ResultMatchers
             
               let(:update_type) { "full" }
            -  let(:error_type) { "applier" }
               let(:workspace_error_details) do
                 {
                   error_type: error_type,
            @@ -41,16 +40,20 @@
                   end
                 end
             
            -    it_behaves_like 'success result'
            -
                 context 'when error_details nil' do
                   let(:workspace_error_details) { nil }
             
            +      it_behaves_like 'success result'
            +    end
            +
            +    context 'when error_type is "applier"' do
            +      let(:error_type) { RemoteDevelopment::Workspaces::Reconcile::ErrorType::APPLIER }
            +
                   it_behaves_like 'success result'
                 end
             
                 context 'when error_type is "kubernetes"' do
            -      let(:error_type) { "kubernetes" }
            +      let(:error_type) { RemoteDevelopment::Workspaces::Reconcile::ErrorType::KUBERNETES }
             
                   it_behaves_like 'success result'
                 end
            @@ -85,6 +88,7 @@
             
                 context 'for update_type' do
                   context 'when not "partial" or "full"' do
            +        let(:error_type) { RemoteDevelopment::Workspaces::Reconcile::ErrorType::KUBERNETES }
                     let(:update_type) { "INVALID UPDATE TYPE" }
             
                     it_behaves_like 'err result', expected_error_details:
            @@ -105,12 +109,7 @@
                   end
             
                   context 'when error_type has an invalid value' do
            -        let(:workspace_error_details) do
            -          {
            -            error_type: "unknown",
            -            error_message: "something has gone wrong"
            -          }
            -        end
            +        let(:error_type) { 'invalid error type' }
             
                     it_behaves_like 'err result', expected_error_details:
                       %(property '/workspace_agent_infos/0/error_details/error_type' is not one of: ["applier", "kubernetes"])

            diff.patch

        • Hunar Khanna marked this merge request as ready

          marked this merge request as ready

        • Hunar Khanna added 1 commit

          added 1 commit

          Compare with previous version

        • Hunar Khanna added 699 commits

          added 699 commits

          Compare with previous version

        • Hunar Khanna added 316 commits

          added 316 commits

          Compare with previous version

        • Loading
        • Loading
        • Loading
        • Loading
        • Loading
        • Loading
        • Loading
        • Loading
        • Loading
        • Loading
        Please register or sign in to reply
        Loading