func (o *Operator) onDeleteArangoDeploymentReplication(obj interface{}) {
	o.Dependencies.LivenessProbe.Lock()
	defer o.Dependencies.LivenessProbe.Unlock()
	log := o.log
	apiObject, ok := obj.(*api.ArangoDeploymentReplication)
	if !ok {
		tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
		if !ok {
			log.Error().Interface("event-object", obj).Msg("unknown object from ArangoDeploymentReplication delete event")
			return
		}
		apiObject, ok = tombstone.Obj.(*api.ArangoDeploymentReplication)
		if !ok {
			log.Error().Interface("event-object", obj).Msg("Tombstone contained object that is not an ArangoDeploymentReplication")
			return
		}
	}
	log.Debug().
		Str("name", apiObject.GetObjectMeta().GetName()).
		Msg("ArangoDeploymentReplication deleted")
	ev := &Event{
		Type:                  kwatch.Deleted,
		DeploymentReplication: apiObject,
	}
	err := o.handleDeploymentReplicationEvent(ev)
	if err != nil {
		log.Warn().Err(err).Msg("Failed to handle event")
	}
}
onDeleteArangoDeploymentReplication deployment replication delete callback
package operator
import (
	replication2 "github.com/arangodb/kube-arangodb/pkg/apis/replication"
	"github.com/arangodb/kube-arangodb/pkg/logging"
	"github.com/arangodb/kube-arangodb/pkg/util/errors"
	kwatch "k8s.io/apimachinery/pkg/watch"
	"k8s.io/client-go/tools/cache"
	api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1"
	"github.com/arangodb/kube-arangodb/pkg/metrics"
	"github.com/arangodb/kube-arangodb/pkg/replication"
	"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
var (
	deploymentReplicationsCreated  = metrics.MustRegisterCounter("controller", "deployment_replications_created", "Number of deployment replications that have been created")
	deploymentReplicationsDeleted  = metrics.MustRegisterCounter("controller", "deployment_replications_deleted", "Number of deployment replications that have been deleted")
	deploymentReplicationsFailed   = metrics.MustRegisterCounter("controller", "deployment_replications_failed", "Number of deployment replications that have failed")
	deploymentReplicationsModified = metrics.MustRegisterCounter("controller", "deployment_replications_modified", "Number of deployment replication modifications")
	deploymentReplicationsCurrent  = metrics.MustRegisterGauge("controller", "deployment_replications", "Number of deployment replications currently being managed")
)
func (o *Operator) runDeploymentReplications(stop <-chan struct{}) {
	rw := k8sutil.NewResourceWatcher(
		o.log,
		o.Dependencies.CRCli.ReplicationV1().RESTClient(),
		replication2.ArangoDeploymentReplicationResourcePlural,
		o.Config.Namespace,
		&api.ArangoDeploymentReplication{},
		cache.ResourceEventHandlerFuncs{
			AddFunc:    o.onAddArangoDeploymentReplication,
			UpdateFunc: o.onUpdateArangoDeploymentReplication,
			DeleteFunc: o.onDeleteArangoDeploymentReplication,
		})
	o.Dependencies.DeploymentReplicationProbe.SetReady()
	rw.Run(stop)
}
func (o *Operator) onAddArangoDeploymentReplication(obj interface{}) {
	o.Dependencies.LivenessProbe.Lock()
	defer o.Dependencies.LivenessProbe.Unlock()
	apiObject := obj.(*api.ArangoDeploymentReplication)
	o.log.Debug().
		Str("name", apiObject.GetObjectMeta().GetName()).
		Msg("ArangoDeploymentReplication added")
	o.syncArangoDeploymentReplication(apiObject)
}
func (o *Operator) onUpdateArangoDeploymentReplication(oldObj, newObj interface{}) {
	o.Dependencies.LivenessProbe.Lock()
	defer o.Dependencies.LivenessProbe.Unlock()
	apiObject := newObj.(*api.ArangoDeploymentReplication)
	o.log.Debug().
		Str("name", apiObject.GetObjectMeta().GetName()).
		Msg("ArangoDeploymentReplication updated")
	o.syncArangoDeploymentReplication(apiObject)
}