jobbrIO / jobbr-server

Jobbr is a non-invasive .NET JobServer
https://jobbr.readthedocs.io
GNU General Public License v3.0
50 stars 5 forks source link

JobParameters don't get updated when updating a Job #71

Closed linkdotnet closed 3 years ago

linkdotnet commented 3 years ago

When trying to update a JobParameter with the RegistryBuilder the parameter will never be updated.

Steps to reproduce

  1. Create a job without any JobParameter
    registryBuilder.Define("SampleNamespace.Job", "SampleNamespace.Job");
  2. Run Jobbr so the changes are reflected in the database
  3. Add the parameter
    registryBuilder.Define("SampleNamespace.Job", "SampleNamespace.Job")
    .WithTrigger("* * * * *").WithParameter("{ \"Dto\": \"Content\"}");
  4. Those changes are never in the Jobs-table.

Root Cause

The RegistryBuilder itself only looks if the underlying CLR type has changed. If not, no updated is performed.

var existingJob = storage.GetJobByUniqueName(jobDefinition.UniqueName);

if (existingJob == null)
{
    // Add new Job
    ...
}
else
{
    // Update existing Jobs and triggers
    if (!string.Equals(existingJob.Type, jobDefinition.ClrType, StringComparison.OrdinalIgnoreCase))
    {

In my opinion the check has to be removed as there are valid reasons behind keeping the underlying CLR-Type but changing other properties.

linkdotnet commented 3 years ago

Resolved with #72