hard-dependencies: enable to set 'hard' links between artifacts

Registered by idan Narotzki

Enable admin or owner to set hard dependency between artifacts.

- Why we want to add this feature? The drive to make the change:

In cases in which one artifact depends on another.
let's say artifact A depends on artifact B. So far, we didn't have a good way to prevent artifact B deletion. Artifact B deletion might cause artifact A to lose critical info.

Usage example for it: SNAPSHOTS for Image artifact.
If we want to support snapshots, saving everytime all the image is very storage (and memory ) consuming.

- Solution: Hard dependency

Hard-dependency feature come to solve this problem: setting hard dependency from A to B, will prevent artifact B deletion.
So, any time there is a request to delete artifact x, glare checks if other artifacts depend on artifact x. Only if no artifact depends on it - artifact x will be deleted.

So, for the snapshots example, with hard-dependency, only the diff can be saved.

- how: <More technical details than the high level overview of `solution` if needed.>

   DB prespective:
   * Adding Table: add "glare_hard_dependencies"
                                  with 3 columns: artifact_source, artifact_origin, artifact_target.
      The idea: for row such as (artifact_source= art1_id,artifact_origin= art2_id,artifact_target=art3_id)
      it means that artifact1
      depends on artifact3, via artifact2 i.e. art2 depends on art3, and art2 depends on art1.

   APIs prespective:
      Add 4 APIs:
      1. set_hard_dependencies - Set hard dependency between the artifacts.
      2. delete_hard_dependencies - Delete hard dependencies between source art to the target art
      3. get_hard_dependencies - Get all artifact_id's hard dependencies.
      4. get_hard_dependencies_children(for internal usage) - get all the dependencies children of
           artifact_id. E.G. for graph: art1->art2->art3,
           the children for art3 are art2 and art1. This suggest that we must not delete art3 artifact.

       Note: cyclic hard_dependencies are not allowed, and will be enforced setting hard dependency (setting hard_dependency will
        be result in BadRequest response)

 - impacts:
   Delete API: additional code will be added, to prevent deleting artifacts, which are hard dependency
   targets.

- How to use this feature from client prespective: <Cli usage example/story>

$ openstack set_hard_dependencies source_artifact_id target_artifact__id
$ openstack delete_hard_dependencies source_artifact_id target_artifact__id
$ openstack get_hard_dependencies artifact_id

- link: https://review.openstack.org/#/c/521377/9

Blueprint information

Status:
Started
Approver:
None
Priority:
High
Drafter:
idan Narotzki
Direction:
Needs approval
Assignee:
idan Narotzki
Definition:
Review
Series goal:
None
Implementation:
Good progress
Milestone target:
None
Started by
Mike Fedosin

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.