Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion api/dataset/v1alpha1/dataset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,17 @@ type DatasetStatus struct {
// readOnly indicates whether the dataset is mounted as read-only.
ReadOnly bool `json:"readOnly,omitempty"`
LastSyncTime metav1.Time `json:"lastSyncTime,omitempty"`
// SourceType defaults to spec.source.type, unless it is a REFERENCE,
// in which case it will match the type of the original Dataset.
SourceType DatasetType `json:"sourceType,omitempty"`
}

// Dataset is the Schema for the datasets API
// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=data
// +kubebuilder:printcolumn:name="type",type=string,JSONPath=`.spec.source.type`
// +kubebuilder:printcolumn:name="type",type=string,JSONPath=`.status.sourceType`
// +kubebuilder:printcolumn:name="uri",type=string,JSONPath=`.spec.source.uri`
// +kubebuilder:printcolumn:name="phase",type=string,JSONPath=`.status.phase`
type Dataset struct {
Expand Down
7 changes: 6 additions & 1 deletion config/crd/bases/dataset.baizeai.io_datasets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.source.type
- jsonPath: .status.sourceType
name: type
type: string
- jsonPath: .spec.source.uri
Expand Down Expand Up @@ -695,6 +695,11 @@ spec:
description: readOnly indicates whether the dataset is mounted as
read-only.
type: boolean
sourceType:
description: |-
SourceType defaults to spec.source.type, unless it is a REFERENCE,
in which case it will match the type of the original Dataset.
type: string
syncRoundStatuses:
description: |-
syncRoundStatuses is a list of data sync round statuses.
Expand Down
16 changes: 15 additions & 1 deletion internal/controller/dataset/dataset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (r *DatasetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
{typ: condTypeConfigMap, rec: r.reconcileConfigMap},
{typ: condTypeJob, rec: r.reconcileJob},
{typ: condTypeJobStatus, rec: r.reconcileJobStatus},
{typ: "", rec: r.reconcileStatusType},
}
}

Expand All @@ -110,7 +111,7 @@ func (r *DatasetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
err := rr.rec(ctx, ds)
ds.Status.Conditions = kubeutils.SetCondition(ds.Status.Conditions, rr.typ, err)
if err != nil {
log.Errorf("error reconciling dataset for %s/%s: %v", ds.Namespace, ds.Name, err)
log.Errorf("error reconciling dataset(%s) for %s/%s: %v", rr.typ, ds.Namespace, ds.Name, err)
break
}
}
Expand Down Expand Up @@ -726,6 +727,19 @@ func (r *DatasetReconciler) reconcileJob(ctx context.Context, ds *datasetv1alpha
return nil
}

func (r *DatasetReconciler) reconcileStatusType(ctx context.Context, ds *datasetv1alpha1.Dataset) error {
if ds.Spec.Source.Type != datasetv1alpha1.DatasetTypeReference {
ds.Status.SourceType = ds.Spec.Source.Type
return nil
}
srcDs, err := r.getSourceDataset(ctx, ds)
if err != nil {
return err
}
ds.Status.SourceType = srcDs.Status.SourceType
return nil
}

func (r *DatasetReconciler) reconcileJobStatus(ctx context.Context, ds *datasetv1alpha1.Dataset) error {
if !supportPreload(ds) {
ds.Status.LastSyncTime = ds.CreationTimestamp
Expand Down