Skip to content

Commit

Permalink
Support event driven reconcilation for cache runtimes (fluid-cloudnat…
Browse files Browse the repository at this point in the history
…ive#2550)

* Support ownerReference for all EACRuntime resources

Signed-off-by: dongyun.xzh <[email protected]>

* Add detailed log for OnCreate/OnUpdate/OnDelete event

Signed-off-by: dongyun.xzh <[email protected]>

* Support ownerReference for all AlluxioRuntime resources

Signed-off-by: dongyun.xzh <[email protected]>

* Support ownerReference for all AlluxioRuntime resources

Signed-off-by: dongyun.xzh <[email protected]>

* Fix ownerReference for JindoRuntime configmaps

Signed-off-by: dongyun.xzh <[email protected]>

---------

Signed-off-by: dongyun.xzh <[email protected]>
  • Loading branch information
TrafalgarZZZ authored Feb 1, 2023
1 parent 157865c commit b495a74
Show file tree
Hide file tree
Showing 24 changed files with 158 additions and 24 deletions.
4 changes: 4 additions & 0 deletions charts/alluxio/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,7 @@
0.9.10

- Use `name.namespace` instead of full svc cluster domain

0.9.11

- Support ownerReferences for AlluxioRuntime resources
2 changes: 1 addition & 1 deletion charts/alluxio/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
name: alluxio
apiVersion: v1
description: Open source data orchestration for analytics and machine learning in any cloud.
version: 0.9.10
version: 0.9.11
home: https://www.alluxio.io/
maintainers:
- name: Adit Madan
Expand Down
9 changes: 9 additions & 0 deletions charts/alluxio/templates/config/alluxio-conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ metadata:
chart: {{ $chart }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
data:
ALLUXIO_JAVA_OPTS: |-
{{- /* Format ALLUXIO_JAVA_OPTS list to one line */}}
Expand Down
9 changes: 9 additions & 0 deletions charts/alluxio/templates/fuse/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-fuse
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
spec:
updateStrategy:
type: {{ .Values.fuse.updateStrategy.type }}
Expand Down
10 changes: 10 additions & 0 deletions charts/alluxio/templates/master/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{{- $name := include "alluxio.name" . }}
{{- $fullName := include "alluxio.fullname" . }}
{{- $chart := include "alluxio.chart" . }}
{{- $owner := $.Values.owner }}
{{- range $i := until $masterCount }}
{{- $masterName := printf "master-%v" $i }}
{{- $masterJavaOpts := printf " -Dalluxio.master.hostname=%v-%v " $fullName $masterName }}
Expand All @@ -42,6 +43,15 @@ metadata:
{{- if $isMonitored }}
monitor: {{ $metricsLabel }}
{{- end }}
ownerReferences:
{{- if $owner.enabled }}
- apiVersion: {{ $owner.apiVersion }}
blockOwnerDeletion: {{ $owner.blockOwnerDeletion }}
controller: {{ $owner.controller }}
kind: {{ $owner.kind }}
name: {{ $owner.name }}
uid: {{ $owner.uid }}
{{- end }}
spec:
ports:
- port: {{ $masterRpcPort }}
Expand Down
9 changes: 9 additions & 0 deletions charts/alluxio/templates/master/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-master
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
spec:
selector:
matchLabels:
Expand Down
9 changes: 9 additions & 0 deletions charts/alluxio/templates/worker/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ metadata:
role: alluxio-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset-placement: {{ .Values.placement }}
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
spec:
selector:
matchLabels:
Expand Down
3 changes: 3 additions & 0 deletions charts/alluxio/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,7 @@ runtimeIdentity:
namespace: default
name: xxx

owner:
enabled: false

clusterDomain: cluster.local
6 changes: 5 additions & 1 deletion charts/eac/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.1.0

- Support Kubernetes Orchestration via Fluid
- Support Kubernetes Orchestration via Fluid

0.1.1

- Support ownerReferences on EACRuntime resources
2 changes: 1 addition & 1 deletion charts/eac/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
name: eac
description: A fuse filesystem for NAS with distributed cache.
version: 0.1.0
version: 0.1.1
maintainers:
- name: Yingchun Ma
email: [email protected]
9 changes: 9 additions & 0 deletions charts/eac/templates/fuse/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: eac-fuse
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
spec:
updateStrategy:
type: {{ .Values.fuse.updateStrategy.type }}
Expand Down
9 changes: 9 additions & 0 deletions charts/eac/templates/master/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: eac-master
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
spec:
selector:
matchLabels:
Expand Down
9 changes: 9 additions & 0 deletions charts/eac/templates/worker/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: eac-worker-endpoints
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
data:
eac-worker-endpoints.json: |
{"containerendpoints":[]}
9 changes: 9 additions & 0 deletions charts/eac/templates/worker/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ metadata:
role: eac-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset-placement: {{ .Values.placement }}
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
spec:
replicas: {{ if .Values.worker.enabled -}} {{ $.Values.worker.count }} {{ else -}} 0 {{ end }}
serviceName: {{ template "eac.fullname" . }}-worker
Expand Down
3 changes: 3 additions & 0 deletions charts/eac/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,6 @@ master:
# memory: "4G"

placement: Inclusive

owner:
enabled: false
9 changes: 9 additions & 0 deletions charts/jindofsx/templates/config/jindofs-client-conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ metadata:
chart: {{ template "jindofs.chart" . }}-client
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
data:
{{- if $isSingleMaster }}
STORAGE_NAMESPACE_RPC_ADDRESS: {{ template "jindofs.fullname" . }}-master-0.{{ .Values.runtimeIdentity.namespace }}:{{ .Values.master.ports.rpc }}
Expand Down
9 changes: 9 additions & 0 deletions charts/jindofsx/templates/config/jindofs-conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ metadata:
chart: {{ template "jindofs.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
data:
jindofsx.cfg: |
[jindofsx-common]
Expand Down
9 changes: 6 additions & 3 deletions pkg/ctrl/watch/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type daemonsetEventHandler struct {

func (handler *daemonsetEventHandler) onCreateFunc(r Controller) func(e event.CreateEvent) bool {
return func(e event.CreateEvent) (onCreate bool) {
log.V(1).Info("enter daemonsetEventHandler.onCreateFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
daemonset, ok := e.Object.(*appsv1.DaemonSet)
if !ok {
log.Info("daemonset.onCreateFunc Skip", "object", e.Object)
Expand All @@ -36,13 +37,14 @@ func (handler *daemonsetEventHandler) onCreateFunc(r Controller) func(e event.Cr
return false
}

log.V(1).Info("daemonsetEventHandler.onCreateFunc", "name", daemonset.GetName(), "namespace", daemonset.GetNamespace())
log.V(1).Info("exit daemonsetEventHandler.onCreateFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
return true
}
}

func (handler *daemonsetEventHandler) onUpdateFunc(r Controller) func(e event.UpdateEvent) bool {
return func(e event.UpdateEvent) (needUpdate bool) {
log.V(1).Info("enter daemonsetEventHandler.onUpdateFunc", "name", e.ObjectNew.GetName(), "namespace", e.ObjectNew.GetNamespace())
daemonsetNew, ok := e.ObjectNew.(*appsv1.DaemonSet)
if !ok {
log.Info("daemonset.onUpdateFunc Skip", "object", e.ObjectNew)
Expand All @@ -64,13 +66,14 @@ func (handler *daemonsetEventHandler) onUpdateFunc(r Controller) func(e event.Up
return needUpdate
}

log.V(1).Info("daemonsetEventHandler.onUpdateFunc", "name", daemonsetNew.GetName(), "namespace", daemonsetNew.GetNamespace())
log.V(1).Info("exit daemonsetEventHandler.onUpdateFunc", "name", e.ObjectNew.GetName(), "namespace", e.ObjectNew.GetNamespace())
return true
}
}

func (handler *daemonsetEventHandler) onDeleteFunc(r Controller) func(e event.DeleteEvent) bool {
return func(e event.DeleteEvent) bool {
log.V(1).Info("enter daemonsetEventHandler.onDeleteFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
daemonset, ok := e.Object.(*appsv1.DaemonSet)
if !ok {
log.Info("daemonset.onDeleteFunc Skip", "object", e.Object)
Expand All @@ -81,7 +84,7 @@ func (handler *daemonsetEventHandler) onDeleteFunc(r Controller) func(e event.De
return false
}

log.V(1).Info("daemonsetEventHandler.onDeleteFunc", "name", daemonset.GetName(), "namespace", daemonset.GetNamespace())
log.V(1).Info("exit daemonsetEventHandler.onDeleteFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
return true
}
}
13 changes: 8 additions & 5 deletions pkg/ctrl/watch/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ type runtimeEventHandler struct {

func (handler *runtimeEventHandler) onCreateFunc(r Controller) func(e event.CreateEvent) bool {
return func(e event.CreateEvent) bool {
runtime, ok := e.Object.(base.RuntimeInterface)
log.V(1).Info("enter runtimeEventHandler.onCreateFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
_, ok := e.Object.(base.RuntimeInterface)
if !ok {
log.Info("runtime.onCreateFunc Skip", "object", e.Object)
return false
}

log.V(1).Info("runtimeEventHandler.onCreateFunc", "name", runtime.GetName(), "namespace", runtime.GetNamespace())
log.V(1).Info("exit runtimeEventHandler.onCreateFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
return true
}
}

func (handler *runtimeEventHandler) onUpdateFunc(r Controller) func(e event.UpdateEvent) bool {
return func(e event.UpdateEvent) (needUpdate bool) {
log.V(1).Info("enter runtimeEventHandler.onUpdateFunc", "newObj.name", e.ObjectNew.GetName(), "newObj.namespace", e.ObjectNew.GetNamespace())
runtimeNew, ok := e.ObjectNew.(base.RuntimeInterface)
if !ok {
log.Info("runtime.onUpdateFunc Skip", "object", e.ObjectNew)
Expand All @@ -40,20 +42,21 @@ func (handler *runtimeEventHandler) onUpdateFunc(r Controller) func(e event.Upda
return needUpdate
}

log.V(1).Info("runtimeEventHandler.onUpdateFunc", "name", runtimeNew.GetName(), "namespace", runtimeNew.GetNamespace())
log.V(1).Info("exit runtimeEventHandler.onUpdateFunc", "newObj.name", e.ObjectNew.GetName(), "newObj.namespace", e.ObjectNew.GetNamespace())
return true
}
}

func (handler *runtimeEventHandler) onDeleteFunc(r Controller) func(e event.DeleteEvent) bool {
return func(e event.DeleteEvent) bool {
runtime, ok := e.Object.(base.RuntimeInterface)
log.V(1).Info("enter runtimeEventHandler.onDeleteFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
_, ok := e.Object.(base.RuntimeInterface)
if !ok {
log.Info("runtime.onDeleteFunc Skip", "object", e.Object)
return false
}

log.V(1).Info("runtimeEventHandler.onDeleteFunc", "name", runtime.GetName(), "namespace", runtime.GetNamespace())
log.V(1).Info("exit runtimeEventHandler.onDeleteFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
return true
}
}
9 changes: 6 additions & 3 deletions pkg/ctrl/watch/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type statefulsetEventHandler struct {

func (handler *statefulsetEventHandler) onCreateFunc(r Controller) func(e event.CreateEvent) bool {
return func(e event.CreateEvent) (onCreate bool) {
log.V(1).Info("enter statefulsetEventHandler.onCreateFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
statefulset, ok := e.Object.(*appsv1.StatefulSet)
if !ok {
log.Info("statefulset.onCreateFunc Skip", "object", e.Object)
Expand All @@ -40,13 +41,14 @@ func (handler *statefulsetEventHandler) onCreateFunc(r Controller) func(e event.
return false
}

log.V(1).Info("statefulsetEventHandler.onCreateFunc", "name", statefulset.GetName(), "namespace", statefulset.GetNamespace())
log.V(1).Info("exit statefulsetEventHandler.onCreateFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
return true
}
}

func (handler *statefulsetEventHandler) onUpdateFunc(r Controller) func(e event.UpdateEvent) bool {
return func(e event.UpdateEvent) (needUpdate bool) {
log.V(1).Info("enter statefulsetEventHandler.onUpdateFunc", "name", e.ObjectNew.GetName(), "namespace", e.ObjectNew.GetNamespace())
statefulsetNew, ok := e.ObjectNew.(*appsv1.StatefulSet)
if !ok {
log.Info("statefulset.onUpdateFunc Skip", "object", e.ObjectNew)
Expand All @@ -68,13 +70,14 @@ func (handler *statefulsetEventHandler) onUpdateFunc(r Controller) func(e event.
return needUpdate
}

log.V(1).Info("statefulsetEventHandler.onUpdateFunc", "name", statefulsetNew.GetName(), "namespace", statefulsetNew.GetNamespace())
log.V(1).Info("exit statefulsetEventHandler.onUpdateFunc", "name", e.ObjectNew.GetName(), "namespace", e.ObjectNew.GetNamespace())
return true
}
}

func (handler *statefulsetEventHandler) onDeleteFunc(r Controller) func(e event.DeleteEvent) bool {
return func(e event.DeleteEvent) bool {
log.V(1).Info("enter statefulsetEventHandler.onDeleteFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
statefulset, ok := e.Object.(*appsv1.StatefulSet)
if !ok {
log.Info("statefulset.onDeleteFunc Skip", "object", e.Object)
Expand All @@ -85,7 +88,7 @@ func (handler *statefulsetEventHandler) onDeleteFunc(r Controller) func(e event.
return false
}

log.V(1).Info("statefulsetEventHandler.onDeleteFunc", "name", statefulset.GetName(), "namespace", statefulset.GetNamespace())
log.V(1).Info("exit statefulsetEventHandler.onDeleteFunc", "name", e.Object.GetName(), "namespace", e.Object.GetNamespace())
return true
}
}
Loading

0 comments on commit b495a74

Please sign in to comment.