nautobot-app-golden-config
nautobot-app-golden-config copied to clipboard
Golden Config Jobs no longer detects repository types
Environment
- Python version: 3.11.9
- Nautobot version: 2.2.3
- nautobot-golden-config version: 2.0.4
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
- Enable any kind of Job from Golden Configuration
- Launch the job
- It finish with no errors, but it doesn't sync with the repos.
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.