Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Fix race condition in ReleaseSchedule
Browse files Browse the repository at this point in the history
  • Loading branch information
vfreex committed Nov 4, 2022
1 parent 3e4bbfd commit f15f3a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 0 additions & 4 deletions doozerlib/distgit.py
Expand Up @@ -1654,10 +1654,6 @@ def _should_match_upstream(self) -> bool:
# A GITLAB token env var was not provided: display a warning and fallback to default
self.logger.error(f'Fallback to default ART config: {e}')
return False
except AttributeError as e:
# Catch "'ReleaseSchedule' object has no attribute 'schedule_data'" error
self.logger.error(f'Failed getting ff date: {e}')
return False
elif self.runtime.group_config.canonical_builders_from_upstream == 'on':
return True
elif self.runtime.group_config.canonical_builders_from_upstream == 'off':
Expand Down
10 changes: 5 additions & 5 deletions doozerlib/release_schedule.py
Expand Up @@ -22,12 +22,12 @@ def __new__(cls, runtime):
# Another thread could have created the instance before the lock was acquired
# So check that the instance is still nonexistent.
if cls._instance is None:
cls._instance = super(ReleaseSchedule, cls).__new__(cls)
cls.initialize(runtime)
instance = super(ReleaseSchedule, cls).__new__(cls)
instance.initialize(runtime)
cls._instance = instance
return cls._instance

@classmethod
def initialize(cls, runtime):
def initialize(self, runtime):
if 'GITLAB_TOKEN' not in os.environ:
raise ValueError('A GITLAB_TOKEN env var must be defined')

Expand All @@ -42,7 +42,7 @@ def initialize(cls, runtime):
minor = runtime.group_config.vars['MINOR']
config_file = f'{git_data.data_dir}/schedules/{major}.{minor}.yaml'
with open(config_file) as f:
cls._instance.schedule_data = yaml.safe_load(f.read())
self.schedule_data = yaml.safe_load(f.read())

def get_ff_date(self) -> datetime:
event = next(item for item in self.schedule_data['events'] if item["name"] == "feature-freeze")
Expand Down

0 comments on commit f15f3a3

Please sign in to comment.