Closed apast0r closed 3 months ago
Appears to be due to an unintended change in the Job().name
value in Nautobot 2.2.3. We'll see about restoring the pre-2.2.3 behavior.
Hi @glennmatthews , thanks for the quick response.
Leaving aside the change to the Job().name
function, Why not move the logic to each Job definition?
The Job should know which type of repo to use.
Replace this:
def get_repo_types_for_job(job_name):
"""Logic to determine which repo_types are needed based on job + plugin settings."""
repo_types = []
if constant.ENABLE_BACKUP and job_name == "nautobot_golden_config.jobs.BackupJob":
repo_types.extend(["backup_repository"])
if constant.ENABLE_INTENDED and job_name == "nautobot_golden_config.jobs.IntendedJob":
repo_types.extend(["jinja_repository", "intended_repository"])
if constant.ENABLE_COMPLIANCE and job_name == "nautobot_golden_config.jobs.ComplianceJob":
repo_types.extend(["intended_repository", "backup_repository"])
if "All" in job_name:
repo_types.extend(["backup_repository", "jinja_repository", "intended_repository"])
return repo_types
Whit this:
class BackupJob(GoldenConfigJobMixin, FormEntry):
"""Job to to run the backup job."""
repo_types = ["backup_repository"]
class IntendedJob(GoldenConfigJobMixin, FormEntry):
"""Job to to run generation of intended configurations."""
repo_types = ["jinja_repository", "intended_repository"]
class ComplianceJob(GoldenConfigJobMixin, FormEntry):
"""Job to to run the compliance engine."""
repo_types = ["intended_repository", "backup_repository"]
class AllGoldenConfig(GoldenConfigJobMixin):
"""Job to to run all three jobs against a single device."""
device = ObjectVar(model=Device, required=True)
debug = BooleanVar(description="Enable for more verbose debug logging")
repo_types = ["backup_repository", "jinja_repository", "intended_repository"]
class AllDevicesGoldenConfig(GoldenConfigJobMixin, FormEntry):
"""Job to to run all three jobs against multiple devices."""
repo_types = ["backup_repository", "jinja_repository", "intended_repository"]
Then change this line:
gitrepo_types = list(set(get_repo_types_for_job(job.name)))
To this:
gitrepo_types = job.repo_types.copy()
Sounds sensible to me. My priority was to unblock existing deployments but I agree that that looks like a desirable refactor.
Forwarding back to golden-config to be fixed there instead.
Environment
Expected Behavior
When a Job is launched, it should detect which kind of repos to sync.
Observed Behavior
When a Job is launched, it can't detect any kind of repo:
Steps to Reproduce