OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#49718] Reduce noise generated by Nextcloud synchronization.
Pavel Balashou2b7718235256
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rbindex f95b53c6141..9333d3b02f2 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rb@@ -62,7 +62,8 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen "104"Util.error(:error, "Insufficient privileges")when "105"- Util.error(:error, "Failed to remove user from group")+ message = Nokogiri::XML(response.body).xpath('/ocs/meta/message').text+ Util.error(:error, "Failed to remove user from group: #{message}")endwhen Net::HTTPMethodNotAllowedUtil.error(:not_allowed)diff --git a/modules/storages/app/services/storages/group_folder_properties_sync_service.rb b/modules/storages/app/services/storages/group_folder_properties_sync_service.rbindex 08f7d19570c..22e21287a85 100644--- a/modules/storages/app/services/storages/group_folder_properties_sync_service.rb+++ b/modules/storages/app/services/storages/group_folder_properties_sync_service.rb@@ -254,7 +254,11 @@ class Storages::GroupFolderPropertiesSyncService@requests.remove_user_from_group_command.call(user:)- .on_failure(&failure_handler('remove_user_from_group_command', { user: }))+ .on_failure do |service_result|+ ::OpenProject.logger.warn(+ "Nextcloud user #{user} has not been removed from Nextcloud group #{@group}: '#{service_result.errors.log_message}'"+ )+ endenddef hide_inactive_project_foldersdiff --git a/modules/storages/app/workers/storages/manage_nextcloud_integration_cron_job.rb b/modules/storages/app/workers/storages/manage_nextcloud_integration_cron_job.rbindex 6df63e019e0..9bae7389044 100644--- a/modules/storages/app/workers/storages/manage_nextcloud_integration_cron_job.rb+++ b/modules/storages/app/workers/storages/manage_nextcloud_integration_cron_job.rb@@ -34,7 +34,6 @@ class Storages::ManageNextcloudIntegrationCronJob < Cron::CronJobself.cron_expression = '*/5 * * * *'def perform- result = Storages::NextcloudStorage.sync_all_group_folders- raise 'Synchronization is being progressed by another process' if result == false+ Storages::NextcloudStorage.sync_all_group_foldersendenddiff --git a/modules/storages/app/workers/storages/manage_nextcloud_integration_events_job.rb b/modules/storages/app/workers/storages/manage_nextcloud_integration_events_job.rbindex b7fe3c9235e..11a342db13f 100644--- a/modules/storages/app/workers/storages/manage_nextcloud_integration_events_job.rb+++ b/modules/storages/app/workers/storages/manage_nextcloud_integration_events_job.rb@@ -43,6 +43,6 @@ class Storages::ManageNextcloudIntegrationEventsJob < ApplicationJobdef performresult = Storages::NextcloudStorage.sync_all_group_folders- raise 'Synchronization is being progressed by another process' if result == false+ self.class.debounce if result == falseendenddiff --git a/modules/storages/spec/common/peripherals/storage_requests_spec.rb b/modules/storages/spec/common/peripherals/storage_requests_spec.rbindex 513894f389f..227963043bc 100644--- a/modules/storages/spec/common/peripherals/storage_requests_spec.rb+++ b/modules/storages/spec/common/peripherals/storage_requests_spec.rb@@ -528,6 +528,35 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doexpect(result).to be_successexpect(result.message).to eq("User has been removed from group")end++ context 'when Nextcloud reponds with 105 code in the response body' do+ let(:expected_response_body) do+ <<~XML+ <?xml version="1.0"?>+ <ocs>+ <meta>+ <status>failure</status>+ <statuscode>105</statuscode>+ <message>Not viable to remove user from the last group you are SubAdmin of</message>+ <totalitems></totalitems>+ <itemsperpage></itemsperpage>+ </meta>+ <data/>+ </ocs>+ XML+ end++ it 'responds with a failure and parses message from the xml response' do+ result = subject+ .remove_user_from_group_command+ .call(user: origin_user_id)+ expect(result).to be_failure+ expect(result.errors.log_message).to eq(+ "Failed to remove user from group: " \+ "Not viable to remove user from the last group you are SubAdmin of"+ )+ end+ endenddescribe '#create_folder_command' dodiff --git a/modules/storages/spec/services/storages/group_folder_properties_sync_service_spec.rb b/modules/storages/spec/services/storages/group_folder_properties_sync_service_spec.rbindex 13fe0a4707e..9e64b3efe73 100644--- a/modules/storages/spec/services/storages/group_folder_properties_sync_service_spec.rb+++ b/modules/storages/spec/services/storages/group_folder_properties_sync_service_spec.rb@@ -650,12 +650,17 @@ RSpec.describe Storages::GroupFolderPropertiesSyncService, webmock: true doendit 'sets project folders properties, but does not remove inactive user from group' do+ allow(OpenProject.logger).to receive(:warn)expect(project_storage1.project_folder_id).to be_nilexpect(project_storage2.project_folder_id).to eq('123')- expect do- described_class.new(storage).call- end.to raise_error(RuntimeError, /remove_user_from_group_command was called with/)+ described_class.new(storage).call++ expect(OpenProject.logger).to have_received(:warn) do |msg, _|+ expect(msg).to eq "Nextcloud user Darth Maul has not been removed from Nextcloud group " \+ "OpenProject: 'Failed to remove user from group: Not viable to remove " \+ "user from the last group you are SubAdmin of'"+ endexpect(request_stubs).to all have_been_requestedproject_storage1.reloaddiff --git a/modules/storages/spec/workers/storages/manage_nextcloud_integration_cron_job_spec.rb b/modules/storages/spec/workers/storages/manage_nextcloud_integration_cron_job_spec.rbindex f65b03d002b..afe209c767f 100644--- a/modules/storages/spec/workers/storages/manage_nextcloud_integration_cron_job_spec.rb+++ b/modules/storages/spec/workers/storages/manage_nextcloud_integration_cron_job_spec.rb@@ -41,9 +41,9 @@ RSpec.describe Storages::ManageNextcloudIntegrationCronJob, type: :job dosubjectend- it 'fails itself when sync has been started by another process' do+ it 'works out silently without doing anything when sync has been started by another process' doallow(Storages::NextcloudStorage).to receive(:sync_all_group_folders).and_return(false)- expect { subject }.to raise_error('Synchronization is being progressed by another process')+ subjectendendenddiff --git a/modules/storages/spec/workers/storages/manage_nextcloud_integration_events_job_spec.rb b/modules/storages/spec/workers/storages/manage_nextcloud_integration_events_job_spec.rbindex c5b07c17a2a..107fd418517 100644--- a/modules/storages/spec/workers/storages/manage_nextcloud_integration_events_job_spec.rb+++ b/modules/storages/spec/workers/storages/manage_nextcloud_integration_events_job_spec.rb@@ -77,9 +77,13 @@ RSpec.describe Storages::ManageNextcloudIntegrationEventsJob, type: :job dosubjectend- it 'fails itself when sync has been started by another process' do+ it 'debounces itself when sync has been started by another process' doallow(Storages::NextcloudStorage).to receive(:sync_all_group_folders).and_return(false)- expect { subject }.to raise_error('Synchronization is being progressed by another process')+ allow(described_class).to receive(:debounce)++ subject++ expect(described_class).to have_received(:debounce).onceendendend