Skip to content

Unnecessary owner references #1358

Description

@lentzi90

What steps did you take and what happened:

  1. Create a Cluster using Metal3DataTemplate and IPPool
  2. Check the owner references on the IPAddress, IPClaim, Metal3Data, Metal3DataClaim and BareMetalHost
  3. The Metal3Data owns the IPAddress and IPClaim (and the IPClaim owns the IPAddress). The Metal3Machine owns the BareMetalHost, Metal3DataClaim and Metal3Data (and the Metal3DataClaim owns the Metal3Data).

This owner structure seems quite strange and unnecessary. Why should the Metal3Machine own the Metal3Data for example when it already owns the Metal3DataClaim? And why should it own the BareMetalHost that is most likely created by the user?

These relations makes it harder to reason about behaviors and understanding the structure.
The owner references are usually used to delete owned objects when the owner is deleted. Owning both the parent and child, like is the case with the IPClaim and IPAddress, is not necessary and can lead to surprising behaviors.

What did you expect to happen:

The owner chain should not have situations where the grand parent owns both parent and child.
We should not put owner references on objects lightly. In general they belong on objects created from or managed by the owner, that should be deleted when the owner is deleted.

Anything else you would like to add:

There may be reasons for the structure that we have, but I have not been able to find them.
The main goal with this issue is to think critically about the structure we have, and think about if/how we can improve it.

Here is a (WIP) graph of the relations:

---
title: Cluster API and Metal3 objects
---
erDiagram
    Cluster ||--|| KubeadmControlPlane : references
    Cluster ||--|| Metal3Cluster : references
    Cluster ||--o{ MachineDeployment : owns
    MachineDeployment ||--|| KubeadmConfigTemplate : references

    KubeadmControlPlane ||--|| Metal3MachineTemplate : references
    Metal3MachineTemplate ||--o| Metal3DataTemplate : references
    Metal3MachineTemplate ||--o{ Metal3Machine : spawns
    Metal3DataTemplate }o--o{ IPPool : references
    IPPool }o--|| Cluster : references
    KubeadmControlPlane ||--|{ Machine : spawns
    MachineDeployment ||--|{ Machine : spawns
    KubeadmConfigTemplate ||--o{ KubeadmConfig : spawns

    Machine ||--|| Metal3Machine : owns
    Machine ||--|| KubeadmConfig : owns
    Metal3Machine |o--o| Metal3DataClaim : owns
    Metal3Machine |o--o| Metal3Data : owns
    Metal3Machine ||--|| BareMetalHost : consumes
    Metal3DataTemplate ||--o{ Metal3Data : spawns
    Metal3DataClaim ||--|| Metal3Data : consumes
    Metal3Data |o--o{ IPClaim : owns
    Metal3Data ||--o{ IPAddress : owns

    IPPool ||--o{ IPAddress : spawns
    IPClaim ||--|| IPAddress : consumes

    %% Secrets
    Metal3Data ||--|| Secret_metadata : produces
    Metal3Data ||--|| Secret_networkdata : produces
    KubeadmConfig ||--|| Secret_userdata : produces
    Secret_userdata ||--|| BareMetalHost : configures
    Secret_metadata ||--|| BareMetalHost : configures
    Secret_networkdata ||--|| BareMetalHost : configures
Loading

Environment:

  • Cluster-api version: v1.5.3
  • Cluster-api-provider-metal3 version: v1.5.2
  • Environment (metal3-dev-env or other): other
  • Kubernetes version: (use kubectl version): v1.28.3

/kind bug

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.triage/acceptedIndicates an issue is ready to be actively worked on.

Type

Projects

Status
CAPM3 WIP

Relationships

None yet

Development

No branches or pull requests

Issue actions