influxdata / influxdb-operator

The Kubernetes operator for InfluxDB and the TICK stack.
Apache License 2.0
27 stars 6 forks source link

Implement OwnerReferences to simplify garbage collection #15

Open gianarb opened 6 years ago

gianarb commented 6 years ago

As @stefanprodan suggested on twitter we should implement Owner reference metadata to automatically manage garbage collection.

// ObjectMeta is metadata that all persisted resources must have, which includes all objects
// users must create.
type ObjectMeta struct {
    // Name must be unique within a namespace. Is required when creating resources, although
    // some resources may allow a client to request the generation of an appropriate name
    // automatically. Name is primarily intended for creation idempotence and configuration
    // definition.
    // Cannot be updated.
    // More info: http://kubernetes.io/docs/user-guide/identifiers#names
    // +optional
    Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`

    // List of objects depended by this object. If ALL objects in the list have
    // been deleted, this object will be garbage collected. If this object is managed by a controller,
    // then an entry in this list will point to this controller, with the controller field set to true.
    // There cannot be more than one managing controller.
    // +optional
    // +patchMergeKey=uid
    // +patchStrategy=merge
    OwnerReferences []OwnerReference `json:"ownerReferences,omitempty" patchStrategy:"merge" patchMergeKey:"uid" protobuf:"bytes,13,rep,name=ownerReferences"`