Commit f4422dba authored by Douwe Maan's avatar Douwe Maan

Merge branch 'ldap-sync-no-retry' into 'master'

Improve reliability of LdapSyncWorker

First of all, Sidekiq job retries are not needed because this is a
recurring job. Second of all, we add the option to run once every
X days instead of once every day. This helps when the job takes
close to or more than 24 hours to complete.

See merge request !68
parents d6744ea8 4b76f008
......@@ -2,11 +2,14 @@ class LdapSyncWorker
include Sidekiq::Worker
include Sidetiq::Schedulable
sidekiq_options retry: false
if Gitlab.config.ldap.enabled
DAILY = Gitlab.config.ldap.schedule_sync_daily
HOUR = Gitlab.config.ldap.schedule_sync_hour
MINUTE = Gitlab.config.ldap.schedule_sync_minute
recurrence { daily.hour_of_day(HOUR).minute_of_hour(MINUTE) }
recurrence { daily(DAILY).hour_of_day(HOUR).minute_of_hour(MINUTE) }
end
def perform
......
......@@ -174,6 +174,7 @@ production: &base
# In addition to refreshing users when they log in,
# enabling this setting will refresh LDAP user membership once a day.
# Default time of the day when this will happen is at 1:30am server time.
schedule_sync_daily: 1 # Run once every X days. Default: 1, meaning 'daily'
schedule_sync_hour: 1 # Hour of the day. Value from 0-23.
schedule_sync_minute: 30 # Minute of the hour. Value from 0-59.
......
......@@ -92,6 +92,7 @@ end
Settings['ldap'] ||= Settingslogic.new({})
Settings.ldap['enabled'] = false if Settings.ldap['enabled'].nil?
Settings.ldap['sync_time'] = 3600 if Settings.ldap['sync_time'].nil?
Settings.ldap['schedule_sync_daily'] = 1 if Settings.ldap['schedule_sync_daily'].nil?
Settings.ldap['schedule_sync_hour'] = 1 if Settings.ldap['schedule_sync_hour'].nil?
Settings.ldap['schedule_sync_minute'] = 30 if Settings.ldap['schedule_sync_minute'].nil?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment