blueprints: always set metadata when attempting to apply

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-08-23 18:48:01 +02:00
parent e70fcd1a6f
commit ca2fce8be2
1 changed files with 3 additions and 4 deletions

View File

@ -125,8 +125,6 @@ def check_blueprint_v1_file(blueprint: BlueprintFile):
)
instance.save()
if instance.last_applied_hash != blueprint.hash:
instance.metadata = asdict(blueprint.meta) if blueprint.meta else {}
instance.save()
apply_blueprint.delay(instance.pk.hex)
@ -160,7 +158,6 @@ def apply_blueprint(self: MonitoredTask, instance_pk: str):
instance.status = BlueprintInstanceStatus.SUCCESSFUL
instance.last_applied_hash = file_hash
instance.last_applied = now()
instance.save()
self.set_status(TaskResult(TaskResultStatus.SUCCESSFUL))
except (
DatabaseError,
@ -170,5 +167,7 @@ def apply_blueprint(self: MonitoredTask, instance_pk: str):
BlueprintRetrievalFailed,
) as exc:
instance.status = BlueprintInstanceStatus.ERROR
instance.save()
self.set_status(TaskResult(TaskResultStatus.ERROR).with_error(exc))
finally:
instance.metadata = asdict(importer.blueprint.metadata)
instance.save()