Skip to content
Snippets Groups Projects
Commit 35912d59 authored by Jacob Vosmaer (GitLab)'s avatar Jacob Vosmaer (GitLab)
Browse files

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.
parent 1ab62227
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -168,6 +168,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.
 
Loading
Loading
Loading
Loading
@@ -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?
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment