Repository navigation
Sync-DbaAvailabilityGroup: add -UseJobLastModified pass-through to Copy-DbaAgentJob - #10768
Conversation
Passed through as -UseLastModified to Copy-DbaAgentJob for the AgentJob sync only; no other object type is affected. Instead of skipping every job that already exists on a secondary (or recreating all of them with -Force), jobs are compared by definition - properties, enabled state, steps and schedules - and only those that actually differ are updated, with the primary winning when it is not older than the secondary. Jobs that differ only in enabled state are updated in place. See Copy-DbaAgentJob for the full behaviour
|
Small, clean pass-through - thanks. Three points:
This text was created by Claude and reviewed by Andreas Jordan. |
- Document that -UseJobLastModified takes precedence over -Force for jobs while -Force still applies to all other object types
- Add UseJobLastModified to the expected parameters test - Extend the Copy-DbaAgentJob mock with -UseLastModified, which the new splat now passes, and add a pass-through test
|
The requested changes have been pushed through. Please review now |
potatoqualitee
left a comment
There was a problem hiding this comment.
Blocking: the new -UseJobLastModified behavior has no required SQL-backed coverage. In ests/Sync-DbaAvailabilityGroup.Tests.ps1, the added case replaces Connect-DbaInstance, Get-DbaAgentJob, and Copy-DbaAgentJob with local functions and only asserts the captured switch. It therefore passes without executing synchronization against SQL Server. This conflicts with ests/CLAUDE.md, which requires every changed command behavior to execute the real implementation against a separately running boundary and says fabricated objects/doubles do not substitute.
Concrete gap: a real availability-group run could fail to propagate a changed job definition or preserve an identical job while this test remains green, because neither the real source/destination jobs nor Copy-DbaAgentJob run. Please add a focused integration case using real source and destination instances, invoke the real command with -UseJobLastModified (excluding unrelated object types), assert the resulting job definition/state, and clean up its fixtures. At minimum, prove that a repeated identical sync preserves the destination job ID and that a newer changed source definition propagates.
…ified Replaces the mocked pass-through test with an integration Describe that runs the real command between InstanceCopy1 and InstanceCopy2 via -Primary/-Secondary, with every object type except AgentJob excluded: - the first sync creates the job on the secondary - a repeated identical sync leaves it untouched (same job_id and date_modified) - a newer step change on the primary propagates to the secondary The existing Copy-DbaAgentJob mock keeps -UseLastModified, which the command always passes. Referencing InstanceCopy* moves the file into the COPY scenario.
potatoqualitee
left a comment
There was a problem hiding this comment.
Reviewed the exact current head. The pass-through is wired correctly, parameter/help coverage is updated, and the prior test-coverage blocker is addressed with a real SQL-backed integration path that creates the job, proves an identical repeat leaves it untouched, and proves a newer changed step propagates. This PR still needs to land after #10767 as documented. The current Actions state is action_required, not a test failure. I found no material defect in this head.
|
Thank you! |
Type of Change
Invoke-ManualPester -Path <command> -ScriptAnalyzer -Compliance)Purpose
Depends on #10767 — the help text for
-UseJobLastModifieddescribes the behavior introduced there (definition comparison, in-place enabled update). Please merge #10767 first.Sync-DbaAvailabilityGroupcallsCopy-DbaAgentJobfor the AgentJob step but has no way to pass-UseLastModifiedthrough. On an availability group that is synced regularly, that leaves two options for jobs that already exist on a secondary: skip them all (default), or drop and recreate every one of them (-Force). Neither keeps secondaries current without churning identical jobs on every run.Approach
Adds a
-UseJobLastModifiedswitch that is passed through as-UseLastModifiedtoCopy-DbaAgentJob. When set, agent jobs that already exist on a secondary are compared by definition and only updated when they differ, with the primary winning when it is not older; jobs that differ only in enabled state are updated in place.The name follows the command's existing job-scoped switch (
-DisableJobOnDestination) rather than reusing-UseLastModified, so it's clear from the parameter list that it affects the AgentJob step only and no other object type.Commands to test
Sync-DbaAvailabilityGroupwith and without-UseJobLastModified(jobs step only differs)Tests
FYI:
tests/Sync-DbaAvailabilityGroup.Tests.ps1needs"UseJobLastModified"added to the expected-parameters list in the parameter validation test.