From 3feef26c5d918cfd5bf5a1c1d36426790410c885 Mon Sep 17 00:00:00 2001 From: Vishal Tak Date: Thu, 23 Nov 2023 14:52:04 +0530 Subject: [PATCH] Update only non terminated workspaces on agent update --- .../remote_development/agent_config/updater.rb | 2 +- .../agent_config/updater_spec.rb | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ee/lib/remote_development/agent_config/updater.rb b/ee/lib/remote_development/agent_config/updater.rb index 7bde5a8574746d..3c4645edcb196d 100644 --- a/ee/lib/remote_development/agent_config/updater.rb +++ b/ee/lib/remote_development/agent_config/updater.rb @@ -39,7 +39,7 @@ def self.update(value) config_from_agent_config_file.fetch(:gitlab_workspaces_proxy, {}).fetch(:namespace, 'gitlab-workspaces') if model_instance.save - model_instance.workspaces.update_all(force_include_all_resources: true) + model_instance.workspaces.without_terminated.update_all(force_include_all_resources: true) Result.ok(AgentConfigUpdateSuccessful.new({ remote_development_agent_config: model_instance })) else Result.err(AgentConfigUpdateFailed.new({ errors: model_instance.errors })) diff --git a/ee/spec/lib/remote_development/agent_config/updater_spec.rb b/ee/spec/lib/remote_development/agent_config/updater_spec.rb index e9f519e6e0edd1..53ee4d798f0764 100644 --- a/ee/spec/lib/remote_development/agent_config/updater_spec.rb +++ b/ee/spec/lib/remote_development/agent_config/updater_spec.rb @@ -78,7 +78,8 @@ .to be_ok_result(RemoteDevelopment::Messages::AgentConfigUpdateSuccessful.new( { remote_development_agent_config: config_instance } )) - expect(config_instance.workspaces).to all(have_attributes(force_include_all_resources: true)) + expect(config_instance.workspaces.without_terminated) + .to all(have_attributes(force_include_all_resources: true)) end context 'when enabled is not present in the config passed' do @@ -111,7 +112,8 @@ .to be_ok_result(RemoteDevelopment::Messages::AgentConfigUpdateSuccessful.new( { remote_development_agent_config: config_instance } )) - expect(config_instance.workspaces).to all(have_attributes(force_include_all_resources: true)) + expect(config_instance.workspaces.without_terminated) + .to all(have_attributes(force_include_all_resources: true)) end end @@ -132,7 +134,8 @@ .to be_ok_result(RemoteDevelopment::Messages::AgentConfigUpdateSuccessful.new( { remote_development_agent_config: config_instance } )) - expect(config_instance.workspaces).to all(have_attributes(force_include_all_resources: true)) + expect(config_instance.workspaces.without_terminated) + .to all(have_attributes(force_include_all_resources: true)) end end @@ -164,7 +167,8 @@ .to be_ok_result(RemoteDevelopment::Messages::AgentConfigUpdateSuccessful.new( { remote_development_agent_config: config_instance } )) - expect(config_instance.workspaces).to all(have_attributes(force_include_all_resources: true)) + expect(config_instance.workspaces.without_terminated) + .to all(have_attributes(force_include_all_resources: true)) end end end @@ -189,7 +193,8 @@ .to be_ok_result(RemoteDevelopment::Messages::AgentConfigUpdateSuccessful.new( { remote_development_agent_config: config_instance } )) - expect(config_instance.workspaces).to all(have_attributes(force_include_all_resources: true)) + expect(config_instance.workspaces.without_terminated) + .to all(have_attributes(force_include_all_resources: true)) end end @@ -210,7 +215,8 @@ .to be_ok_result(RemoteDevelopment::Messages::AgentConfigUpdateSuccessful.new( { remote_development_agent_config: config_instance } )) - expect(config_instance.workspaces).to all(have_attributes(force_include_all_resources: true)) + expect(config_instance.workspaces.without_terminated) + .to all(have_attributes(force_include_all_resources: true)) end end end -- GitLab