Skip to content

Commit

Permalink
update by using ObjectRef
Browse files Browse the repository at this point in the history
Signed-off-by: xliuqq <[email protected]>
  • Loading branch information
xliuqq committed Sep 11, 2024
1 parent 0287b75 commit 07707f6
Showing 1 changed file with 83 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,51 @@ DataFlow 中的数据操作的亲和性,可以指定依赖任意的前置操

## 设计

> 字段改动,因此当前设计对 v1.0.1 和 v1.0.2 的 DataFlow Affinity 不兼容。
>
> - (待确定)如果不将`AffinityStrategy``RunAfter`中移出,可以兼容旧版本,语义和层级上是否合理?
当前 `AffinityStrategy`字段位于`RunAfter`字段中,仅能依赖`RunAfter`指定的数据操作。

**`AffinityStrategy`字段从`RunAfter`中分离出来**,并添加依赖的前置数据操作的字段 `DependOn *OperationRef`
- 新增 `ObjectRef`定义,表示引用的 Data Operation 信息;
- `RunAfter`使用 inline 的 `ObjectRef`

- `AffinityStrategy`字段添加依赖的前置数据操作的字段 `DependOn *OperationRef`

- 对于 Data Operation 注入亲和性时,不根据 `RunAfter` 表示的前置操作,而是根据 `AffinityStrategy`中的`DependOn`所表示的操作。
对于 Data Operation 注入亲和性时,不根据 `RunAfter` 表示的前置操作,而是根据 `AffinityStrategy`中的`DependOn`所表示的操作。

- 由用户来保证`DependOn *OperationRef` 是前置的数据操作。
- **(待确定)如果没有指定`DependOn`,使用 `RunAfter`字段表示的前置数据操作**
- 由用户来保证`DependOn *ObjectRef` 是前置的数据操作。
- **如果没有指定`DependOn`,使用 `RunAfter`字段表示的前置数据操作**

```go
type DataLoadSpec struct {
// Specifies that the preceding operation in a workflow
type ObjectRef struct {
// API version of the referent operation
// +optional
APIVersion string `json:"apiVersion,omitempty"`

// Kind specifies the type of the referent operation
// +required
// +kubebuilder:validation:Enum=DataLoad;DataBackup;DataMigrate;DataProcess
Kind string `json:"kind"`

// Name specifies the name of the referent operation
// +required
Name string `json:"name"`

// Namespace specifies the namespace of the referent operation.
// +optional
RunAfter *OperationRef `json:"runAfter,omitempty"`
Namespace string `json:"namespace,omitempty"`
}

type OperationRef struct {
ObjectRef `json:",inline"`

// Modified. move out from OperationRef.
// AffinityStrategy specifies the pod affinity strategy with the referent operation.
// +optional
AffinityStrategy *AffinityStrategy `json:"affinityStrategy,omitempty"`
AffinityStrategy AffinityStrategy `json:"affinityStrategy,omitempty"`
}

type AffinityStrategy struct {
// Added
// Specifies that the dependent preceding operation in a workflow. If not set, use `RunAfter` field.
// +optional
DependOn *OperationRef `json:"dependOn,omitempty"`
DependOn *ObjectRef `json:"dependOn,omitempty"`
// Policy one of: "", "Require", "Prefer"
// +optional
Policy AffinityPolicy `json:"policy,omitempty"`
Expand All @@ -70,6 +85,8 @@ type AffinityStrategy struct {

## 示例

### 依赖非直接前置的操作

针对示例的工作流

```mermaid
Expand All @@ -87,7 +104,7 @@ kind: DataProcess
metadata:
name: step2-trtllm-convert
# exposed affinity which will be filled in OperationStatus.
fluid.io/affinity.labels: "node.kubernetes.io/instance-type"
data-operation.fluid.io/affinity.labels: "node.kubernetes.io/instance-type"
spec:
runAfter:
kind: DataProcess
Expand Down Expand Up @@ -115,15 +132,56 @@ spec:
kind: DataLoad
name: step3-warmup-cache
namespace: default
AffinityStrategy:
# get affinity from which data operation
dependOn:
kind: DataProcess
name: step2-trtllm-convert
namespace: default
policy: Require
# Require to run on a node with the same label value as the dependent operation
requires:
- name: node.kubernetes.io/instance-type
affinityStrategy:
# get affinity from which data operation
dependOn:
kind: DataProcess
name: step2-trtllm-convert
namespace: default
policy: Require
# Require to run on a node with the same label value as the dependent operation
requires:
- name: node.kubernetes.io/instance-type
```
### 依赖直接前置的操作
示例:后一个 DataProcess 依赖前一个 DataProcess,使用同样的 GPU节点。
- `AffinityStrategy` 中的 `dependOn` 字段可以不用设置。

```mermaid
graph BT
B(DataProcess B(GPU)) --RunAfter--> A(DataProcess A(GPU))
```



```yaml
apiVersion: data.fluid.io/v1alpha1
kind: DataProcess
metadata:
name: stepA
# exposed affinity which will be filled in OperationStatus.
data-operation.fluid.io/affinity.labels: "node.kubernetes.io/instance-type"
spec:
...
apiVersion: data.fluid.io/v1alpha1
kind: DataProcess
metadata:
name: step4-infer-server
spec:
runAfter:
kind: DataProcess
name: stepA
namespace: default
affinityStrategy:
# dependOn field not set, use the runAfter indicated data operation.
policy: Require
# Require to run on a node with the same label value as the dependent operation
requires:
- name: node.kubernetes.io/instance-type
```

0 comments on commit 07707f6

Please sign in to comment.