From e4c833a5e23e4e41d4b3406c78bcb71ee8b02533 Mon Sep 17 00:00:00 2001 From: Ashvin Sharma Date: Fri, 19 Sep 2025 01:42:58 +0530 Subject: [PATCH 1/4] Mark desired_config_generator_version ignore for deletion This column will be deleted in milestone 18.6, and hence ignored for rails according to the docs. https://docs.gitlab.com/development/database/avoiding_downtime_in_migrations/#dropping-columns Changelog: other EE: true --- ee/app/models/remote_development/workspace.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ee/app/models/remote_development/workspace.rb b/ee/app/models/remote_development/workspace.rb index ae3b77e0763b1b..e17ab491a8eb69 100644 --- a/ee/app/models/remote_development/workspace.rb +++ b/ee/app/models/remote_development/workspace.rb @@ -26,6 +26,8 @@ class Workspace < ApplicationRecord has_one :workspace_agentk_state, inverse_of: :workspace, class_name: "RemoteDevelopment::WorkspaceAgentkState" has_one :workspace_token, inverse_of: :workspace, class_name: "RemoteDevelopment::WorkspaceToken" + ignore_column :desired_config_generator_version, remove_with: '18.7', remove_after: '2025-11-15' + validates :user, presence: true validates :agent, presence: true validates :personal_access_token, presence: true -- GitLab From 05c40359efdb374c2f3c92b3477ce54c17bf7e0d Mon Sep 17 00:00:00 2001 From: Ashvin Sharma Date: Fri, 19 Sep 2025 03:17:54 +0530 Subject: [PATCH 2/4] Remove not null constraint on desired_config_generator_version --- ..._generator_version_column_workspace_table.rb | 17 +++++++++++++++++ db/schema_migrations/20250918211812 | 1 + db/structure.sql | 1 - 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20250918211812_drop_not_null_constraint_desired_config_generator_version_column_workspace_table.rb create mode 100644 db/schema_migrations/20250918211812 diff --git a/db/migrate/20250918211812_drop_not_null_constraint_desired_config_generator_version_column_workspace_table.rb b/db/migrate/20250918211812_drop_not_null_constraint_desired_config_generator_version_column_workspace_table.rb new file mode 100644 index 00000000000000..0af67ae9504fcf --- /dev/null +++ b/db/migrate/20250918211812_drop_not_null_constraint_desired_config_generator_version_column_workspace_table.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class DropNotNullConstraintDesiredConfigGeneratorVersionColumnWorkspaceTable < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + milestone '18.5' + + def up + remove_check_constraint :workspaces, 'check_35e31ca320' + end + + def down + add_check_constraint :workspaces, 'desired_config_generator_version IS NOT NULL', 'check_35e31ca320' + end +end diff --git a/db/schema_migrations/20250918211812 b/db/schema_migrations/20250918211812 new file mode 100644 index 00000000000000..2326bfe176f9d9 --- /dev/null +++ b/db/schema_migrations/20250918211812 @@ -0,0 +1 @@ +e7a623ceec66a0e46ee71e98b198c58ade04d4bbcb1794a013f525f6e1ac79ee \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 7c6f11ac89b52d..b7e38a762cbf1e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -28413,7 +28413,6 @@ CREATE TABLE workspaces ( CONSTRAINT check_15543fb0fa CHECK ((char_length(name) <= 64)), CONSTRAINT check_157d5f955c CHECK ((char_length(namespace) <= 64)), CONSTRAINT check_2b401b0034 CHECK ((char_length(deployment_resource_version) <= 64)), - CONSTRAINT check_35e31ca320 CHECK ((desired_config_generator_version IS NOT NULL)), CONSTRAINT check_72fee08424 CHECK ((char_length(project_ref) <= 256)), CONSTRAINT check_77d1a2ff50 CHECK ((char_length(processed_devfile) <= 65535)), CONSTRAINT check_8a0ab61b6b CHECK ((char_length(url_query_string) <= 256)), -- GitLab From 1366b2dd11f4d48c5665543ee0acf0f6669301fe Mon Sep 17 00:00:00 2001 From: Ashvin Sharma Date: Fri, 19 Sep 2025 03:18:22 +0530 Subject: [PATCH 3/4] Remove all code references of desired_config_generator_version --- .../remote_development/workspace_type.rb | 6 +--- ee/app/models/remote_development/workspace.rb | 5 +-- .../desired_config_generator_version.rb | 10 ------ .../remote_development/workspace_type_spec.rb | 2 +- .../backfill_workspace_agentk_states_spec.rb | 6 ++-- .../input/actual_state_calculator_spec.rb | 4 +-- .../reconcile/main_integration_spec.rb | 4 +-- .../remote_development/workspace_spec.rb | 36 ++++++++----------- 8 files changed, 21 insertions(+), 52 deletions(-) delete mode 100644 ee/lib/remote_development/workspace_operations/desired_config_generator_version.rb diff --git a/ee/app/graphql/types/remote_development/workspace_type.rb b/ee/app/graphql/types/remote_development/workspace_type.rb index 9e617c20503a58..e8e39a012dc393 100644 --- a/ee/app/graphql/types/remote_development/workspace_type.rb +++ b/ee/app/graphql/types/remote_development/workspace_type.rb @@ -32,7 +32,7 @@ class WorkspaceType < ::Types::BaseObject field :desired_state, GraphQL::Types::String, null: false, description: 'Desired state of the workspace.' - field :desired_state_updated_at, Types::TimeType, + field :desired_state_updated_at, Types::TimeType, # rubocop:disable GraphQL/ExtractType -- We don't want to extract this to a type null: false, description: 'Timestamp of the last update to the desired state.' # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/409772 - Make this a type:enum @@ -87,10 +87,6 @@ class WorkspaceType < ::Types::BaseObject field :deployment_resource_version, GraphQL::Types::Int, null: true, description: 'Version of the deployment resource for the workspace.' - field :desired_config_generator_version, GraphQL::Types::Int, # rubocop:disable GraphQL/ExtractType -- We don't want to extract this to a type, its purpose is different than other 'desired' fields - experiment: { milestone: '17.6' }, - null: false, description: 'Version of the desired config generator for the workspace.' - field :workspaces_agent_config_version, GraphQL::Types::Int, experiment: { milestone: '17.6' }, null: false, description: 'Version of the associated WorkspacesAgentConfig for the workspace.' diff --git a/ee/app/models/remote_development/workspace.rb b/ee/app/models/remote_development/workspace.rb index e17ab491a8eb69..5d2739849b6a0f 100644 --- a/ee/app/models/remote_development/workspace.rb +++ b/ee/app/models/remote_development/workspace.rb @@ -15,9 +15,6 @@ class Workspace < ApplicationRecord belongs_to :agent, class_name: "Clusters::Agent", foreign_key: "cluster_agent_id", inverse_of: :workspaces belongs_to :personal_access_token, inverse_of: :workspace - attribute :desired_config_generator_version, - default: ::RemoteDevelopment::WorkspaceOperations::DesiredConfigGeneratorVersion::LATEST_VERSION - has_many :workspace_variables, class_name: "RemoteDevelopment::WorkspaceVariable", inverse_of: :workspace # Currently we only support :environment type for user provided variables has_many :user_provided_workspace_variables, -> { @@ -31,7 +28,7 @@ class Workspace < ApplicationRecord validates :user, presence: true validates :agent, presence: true validates :personal_access_token, presence: true - validates :desired_config_generator_version, presence: true + validates :workspaces_agent_config_version, presence: true, if: -> do agent&.unversioned_latest_workspaces_agent_config end diff --git a/ee/lib/remote_development/workspace_operations/desired_config_generator_version.rb b/ee/lib/remote_development/workspace_operations/desired_config_generator_version.rb deleted file mode 100644 index 1c88b0040f8bf6..00000000000000 --- a/ee/lib/remote_development/workspace_operations/desired_config_generator_version.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -module RemoteDevelopment - module WorkspaceOperations - module DesiredConfigGeneratorVersion - VERSION_3 = 3 - LATEST_VERSION = VERSION_3 - end - end -end diff --git a/ee/spec/graphql/types/remote_development/workspace_type_spec.rb b/ee/spec/graphql/types/remote_development/workspace_type_spec.rb index 25a6d95bf5b52e..bc30285423dba8 100644 --- a/ee/spec/graphql/types/remote_development/workspace_type_spec.rb +++ b/ee/spec/graphql/types/remote_development/workspace_type_spec.rb @@ -10,7 +10,7 @@ cluster_agent created_at deployment_resource_version - desired_config_generator_version + desired_state desired_state_updated_at devfile diff --git a/ee/spec/lib/ee/gitlab/background_migration/backfill_workspace_agentk_states_spec.rb b/ee/spec/lib/ee/gitlab/background_migration/backfill_workspace_agentk_states_spec.rb index 6267522e73fd87..3706c96871a474 100644 --- a/ee/spec/lib/ee/gitlab/background_migration/backfill_workspace_agentk_states_spec.rb +++ b/ee/spec/lib/ee/gitlab/background_migration/backfill_workspace_agentk_states_spec.rb @@ -27,8 +27,7 @@ url: "workspace-url", deployment_resource_version: "v1", personal_access_token_id: personal_access_token.id, - workspaces_agent_config_version: agent_config_version.id, - desired_config_generator_version: 3 + workspaces_agent_config_version: agent_config_version.id ) end @@ -51,8 +50,7 @@ url: "workspace-url", deployment_resource_version: "v1", personal_access_token_id: personal_access_token.id, - workspaces_agent_config_version: agent_config_version.id, - desired_config_generator_version: 3 + workspaces_agent_config_version: agent_config_version.id ) end diff --git a/ee/spec/lib/remote_development/workspace_operations/reconcile/input/actual_state_calculator_spec.rb b/ee/spec/lib/remote_development/workspace_operations/reconcile/input/actual_state_calculator_spec.rb index 8f30d8b71cb1ad..bcfa7793fa9810 100644 --- a/ee/spec/lib/remote_development/workspace_operations/reconcile/input/actual_state_calculator_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/reconcile/input/actual_state_calculator_spec.rb @@ -48,9 +48,7 @@ instance_double( "RemoteDevelopment::Workspace", # rubocop:disable RSpec/VerifiedDoubleReference -- We're using the quoted version so we can use fast_spec_helper id: 1, name: 'name', namespace: 'namespace', agent: agent, - actual_state: previous_actual_state, - desired_config_generator_version: - ::RemoteDevelopment::WorkspaceOperations::DesiredConfigGeneratorVersion::LATEST_VERSION + actual_state: previous_actual_state ) end diff --git a/ee/spec/lib/remote_development/workspace_operations/reconcile/main_integration_spec.rb b/ee/spec/lib/remote_development/workspace_operations/reconcile/main_integration_spec.rb index efadbca16eaa7f..779eb8f8374d30 100644 --- a/ee/spec/lib/remote_development/workspace_operations/reconcile/main_integration_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/reconcile/main_integration_spec.rb @@ -713,9 +713,7 @@ let(:nonexistent_workspace) do instance_double( "RemoteDevelopment::Workspace", # rubocop:disable RSpec/VerifiedDoubleReference -- We're using the quoted version so we can use fast_spec_helper - id: 1, name: 'x', namespace: 'x', agent: agent, - desired_config_generator_version: - ::RemoteDevelopment::WorkspaceOperations::DesiredConfigGeneratorVersion::LATEST_VERSION + id: 1, name: 'x', namespace: 'x', agent: agent ) end diff --git a/ee/spec/models/remote_development/workspace_spec.rb b/ee/spec/models/remote_development/workspace_spec.rb index d4a545e0ff9d5b..a8f9d020833882 100644 --- a/ee/spec/models/remote_development/workspace_spec.rb +++ b/ee/spec/models/remote_development/workspace_spec.rb @@ -43,14 +43,6 @@ body: "", headers: {}) end - describe "default values" do - it "has correct default values" do - expect(workspace.desired_config_generator_version).to eq( - RemoteDevelopment::WorkspaceOperations::DesiredConfigGeneratorVersion::LATEST_VERSION - ) - end - end - describe "associations" do context "for has_many" do it { is_expected.to have_many(:workspace_variables) } @@ -68,9 +60,9 @@ it "has correct relation setup" do is_expected .to belong_to(:agent) - .class_name("Clusters::Agent") - .with_foreign_key(:cluster_agent_id) - .inverse_of(:workspaces) + .class_name("Clusters::Agent") + .with_foreign_key(:cluster_agent_id) + .inverse_of(:workspaces) end end @@ -179,20 +171,20 @@ it "triggers internal event with new label on new record" do expect { workspace.update!(desired_state: states_module::RUNNING) } .to trigger_internal_events("track_started_workspaces") - .with(user: user, project: project, additional_properties: { - label: "new" - }) - .and increment_usage_metrics("counts.count_total_workspaces_started") + .with(user: user, project: project, additional_properties: { + label: "new" + }) + .and increment_usage_metrics("counts.count_total_workspaces_started") end it "triggers internal event with existing label on existing record" do workspace.save!(desired_state: "Stopped") expect { workspace.update!(desired_state: states_module::RUNNING) } .to trigger_internal_events("track_started_workspaces") - .with(user: user, project: project, additional_properties: { - label: "existing" - }) - .and increment_usage_metrics("counts.count_total_workspaces_started") + .with(user: user, project: project, additional_properties: { + label: "existing" + }) + .and increment_usage_metrics("counts.count_total_workspaces_started") end end @@ -202,7 +194,7 @@ it "does not trigger the event and metric" do expect { workspace.update!(desired_state: states_module::STOPPED) } .to not_trigger_internal_events("track_started_workspaces") - .and not_increment_usage_metrics('counts.count_total_workspaces_started') + .and not_increment_usage_metrics('counts.count_total_workspaces_started') end end @@ -214,7 +206,7 @@ it "does not trigger the event" do expect { workspace.update!(name: "workspace_new_name") } .to not_trigger_internal_events("track_started_workspaces") - .and not_increment_usage_metrics('counts.count_total_workspaces_started') + .and not_increment_usage_metrics('counts.count_total_workspaces_started') end end end @@ -412,7 +404,7 @@ before do allow(workspace) .to receive(:workspaces_count_for_current_user_and_agent) - .and_return(workspaces_count_for_current_user_and_agent) + .and_return(workspaces_count_for_current_user_and_agent) end describe "when quotas are not exceeded" do -- GitLab From 7242aa65030eef7cfbcf69208dcab97e6332326b Mon Sep 17 00:00:00 2001 From: Ashvin Sharma Date: Fri, 19 Sep 2025 03:54:40 +0530 Subject: [PATCH 4/4] Update GraphQL documentation --- doc/api/graphql/reference/_index.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/api/graphql/reference/_index.md b/doc/api/graphql/reference/_index.md index 0fc24cc661f221..5bb0ad01a00ca1 100644 --- a/doc/api/graphql/reference/_index.md +++ b/doc/api/graphql/reference/_index.md @@ -46372,7 +46372,6 @@ Represents a remote development workspace. | `clusterAgent` | [`ClusterAgent!`](#clusteragent) | Kubernetes agent associated with the workspace. | | `createdAt` | [`Time!`](#time) | Timestamp of when the workspace was created. | | `deploymentResourceVersion` | [`Int`](#int) | Version of the deployment resource for the workspace. | -| `desiredConfigGeneratorVersion` {{< icon name="warning-solid" >}} | [`Int!`](#int) | **Introduced** in GitLab 17.6. **Status**: Experiment. Version of the desired config generator for the workspace. | | `desiredState` | [`String!`](#string) | Desired state of the workspace. | | `desiredStateUpdatedAt` | [`Time!`](#time) | Timestamp of the last update to the desired state. | | `devfile` | [`String!`](#string) | Source YAML of the devfile used to configure the workspace. | -- GitLab