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 0000000000000000000000000000000000000000..0af67ae9504fcfcf4615e55c56b02f850de48470 --- /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 0000000000000000000000000000000000000000..2326bfe176f9d9fa003c2f362975861e618c3f2d --- /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 7c6f11ac89b52d65fd7f15f82484deb30b2c97fd..b7e38a762cbf1ec2c7f2786d63782439041802f0 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)), diff --git a/doc/api/graphql/reference/_index.md b/doc/api/graphql/reference/_index.md index 0fc24cc661f221befe540da350330e8a85ab631b..5bb0ad01a00ca110a337069a94367c8f73608a0f 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. | diff --git a/ee/app/graphql/types/remote_development/workspace_type.rb b/ee/app/graphql/types/remote_development/workspace_type.rb index 9e617c20503a58f66ce89607c3be107e0b0119a6..e8e39a012dc393c3ada174e4c7e8dfb2b993838d 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 ae3b77e0763b1b25ea7ca423d34c45dfcd915c45..5d2739849b6a0f99e6ad21b57df3fecb24d2f518 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, -> { @@ -26,10 +23,12 @@ 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 - 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 1c88b0040f8bf648ec0914507dee557228adab59..0000000000000000000000000000000000000000 --- 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 25a6d95bf5b52e61d7a94772428f5da97ad58eb5..bc30285423dba8e5442aeb057fd3ad6bab70bba7 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 6267522e73fd87de7d41ea572ee2279dc46854ce..3706c96871a4740dcc89a2f511ec2f72605800fa 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 8f30d8b71cb1ad707a46f0d26bdd441797b5826d..bcfa7793fa9810cc3f59fcbda58867877d8bf6f6 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 efadbca16eaa7f498d0c4c1e2614ead67aba1251..779eb8f8374d30b886dc9b004f2d9237eb2d71aa 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 d4a545e0ff9d5b23212498474877fc88a028302b..a8f9d020833882ff0cb103bd2bc1ea441a9e978f 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