Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add a new field that reports errors in case resource was incompatible #2930

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions config/crds/workload.kcp.io_synctargets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ spec:
on APIExport and APIResourceSchema's status. It will be empty
for core types.
type: string
message:
description: A human readable message indicating details about
the compatibility errors. This field may be empty.
type: string
resource:
description: 'resource is the name of the resource. Note: it
is worth noting that you can not ask for permissions for resource
Expand Down
2 changes: 1 addition & 1 deletion config/root-phase0/apiexport-workload.kcp.io.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ metadata:
name: workload.kcp.io
spec:
latestResourceSchemas:
- v230109-773b219c.synctargets.workload.kcp.io
- v230329-eaa109f2.synctargets.workload.kcp.io
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apis.kcp.io/v1alpha1
kind: APIResourceSchema
metadata:
creationTimestamp: null
name: v230109-773b219c.synctargets.workload.kcp.io
name: v230329-eaa109f2.synctargets.workload.kcp.io
spec:
group: workload.kcp.io
names:
Expand Down Expand Up @@ -192,6 +192,10 @@ spec:
on APIExport and APIResourceSchema's status. It will be empty
for core types.
type: string
message:
description: A human readable message indicating details about
the compatibility errors. This field may be empty.
type: string
resource:
description: 'resource is the name of the resource. Note: it is
worth noting that you can not ask for permissions for resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,15 @@ func (e *apiCompatibleReconciler) reconcile(ctx context.Context, syncTarget *wor
field.NewPath(gvr.String()), upstreamSchema, downStreamSchema, false)
if err != nil {
syncTarget.Status.SyncedResources[i].State = workloadv1alpha1.ResourceSchemaIncompatibleState
syncTarget.Status.SyncedResources[i].Message = err.Error()
davidfestal marked this conversation as resolved.
Show resolved Hide resolved
continue
}

// since version is ordered, so if the current version is comptaible, we can skip the check on other versions.
syncTarget.Status.SyncedResources[i].State = workloadv1alpha1.ResourceSchemaAcceptedState
if syncTarget.Status.SyncedResources[i].Message != "" {
davidfestal marked this conversation as resolved.
Show resolved Hide resolved
syncTarget.Status.SyncedResources[i].Message = ""
}
break
}
}
Expand Down
5 changes: 5 additions & 0 deletions sdk/apis/workload/v1alpha1/synctarget_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ type ResourceToSync struct {
// +kubebuilder:default=Pending
// +optional
State ResourceCompatibleState `json:"state,omitempty"`

// A human readable message indicating details about the compatibility errors.
// This field may be empty.
// +optional
Message string `json:"message,omitempty"`
}

type ResourceCompatibleState string
Expand Down