From eaa109f2b7401f490fb47256eedd64092fdc5b9e Mon Sep 17 00:00:00 2001 From: rahul sawra Date: Wed, 29 Mar 2023 13:54:01 +0530 Subject: [PATCH 1/3] add a new field that reports errors in case resource was incompatible --- config/crds/workload.kcp.io_synctargets.yaml | 4 ++++ config/root-phase0/apiexport-workload.kcp.io.yaml | 2 +- .../apiresourceschema-synctargets.workload.kcp.io.yaml | 6 +++++- .../synctargetexports/synctargetcompatible_reconcile.go | 1 + sdk/apis/workload/v1alpha1/synctarget_types.go | 5 +++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/config/crds/workload.kcp.io_synctargets.yaml b/config/crds/workload.kcp.io_synctargets.yaml index d14aaa03ccd..80e257d758c 100644 --- a/config/crds/workload.kcp.io_synctargets.yaml +++ b/config/crds/workload.kcp.io_synctargets.yaml @@ -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 diff --git a/config/root-phase0/apiexport-workload.kcp.io.yaml b/config/root-phase0/apiexport-workload.kcp.io.yaml index 61b01805907..e31ab314547 100644 --- a/config/root-phase0/apiexport-workload.kcp.io.yaml +++ b/config/root-phase0/apiexport-workload.kcp.io.yaml @@ -5,5 +5,5 @@ metadata: name: workload.kcp.io spec: latestResourceSchemas: - - v230109-773b219c.synctargets.workload.kcp.io + - v230329-b5e3a0e1.synctargets.workload.kcp.io status: {} diff --git a/config/root-phase0/apiresourceschema-synctargets.workload.kcp.io.yaml b/config/root-phase0/apiresourceschema-synctargets.workload.kcp.io.yaml index 22ecc2cbfa1..86d231bc104 100644 --- a/config/root-phase0/apiresourceschema-synctargets.workload.kcp.io.yaml +++ b/config/root-phase0/apiresourceschema-synctargets.workload.kcp.io.yaml @@ -2,7 +2,7 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: creationTimestamp: null - name: v230109-773b219c.synctargets.workload.kcp.io + name: v230329-b5e3a0e1.synctargets.workload.kcp.io spec: group: workload.kcp.io names: @@ -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 diff --git a/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go b/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go index cb3e7922b5b..2798a843c4b 100644 --- a/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go +++ b/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go @@ -123,6 +123,7 @@ 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() continue } diff --git a/sdk/apis/workload/v1alpha1/synctarget_types.go b/sdk/apis/workload/v1alpha1/synctarget_types.go index fa32a2fee77..a080a31ffd7 100644 --- a/sdk/apis/workload/v1alpha1/synctarget_types.go +++ b/sdk/apis/workload/v1alpha1/synctarget_types.go @@ -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 From 4071152880e1fcf8727522c71f8f30d54c37f804 Mon Sep 17 00:00:00 2001 From: rahulii Date: Wed, 29 Mar 2023 14:07:37 +0530 Subject: [PATCH 2/3] reset the field to empty --- config/crds/workload.kcp.io_synctargets.yaml | 2 +- config/root-phase0/apiexport-workload.kcp.io.yaml | 2 +- .../apiresourceschema-synctargets.workload.kcp.io.yaml | 4 ++-- .../synctargetexports/synctargetcompatible_reconcile.go | 3 +++ sdk/apis/workload/v1alpha1/synctarget_types.go | 4 ++-- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config/crds/workload.kcp.io_synctargets.yaml b/config/crds/workload.kcp.io_synctargets.yaml index 80e257d758c..136a9c9a507 100644 --- a/config/crds/workload.kcp.io_synctargets.yaml +++ b/config/crds/workload.kcp.io_synctargets.yaml @@ -199,7 +199,7 @@ spec: type: string message: description: A human readable message indicating details about - the compatibility errors This field may be empty. + the compatibility errors. This field may be empty. type: string resource: description: 'resource is the name of the resource. Note: it diff --git a/config/root-phase0/apiexport-workload.kcp.io.yaml b/config/root-phase0/apiexport-workload.kcp.io.yaml index e31ab314547..6c232461c2c 100644 --- a/config/root-phase0/apiexport-workload.kcp.io.yaml +++ b/config/root-phase0/apiexport-workload.kcp.io.yaml @@ -5,5 +5,5 @@ metadata: name: workload.kcp.io spec: latestResourceSchemas: - - v230329-b5e3a0e1.synctargets.workload.kcp.io + - v230329-eaa109f2.synctargets.workload.kcp.io status: {} diff --git a/config/root-phase0/apiresourceschema-synctargets.workload.kcp.io.yaml b/config/root-phase0/apiresourceschema-synctargets.workload.kcp.io.yaml index 86d231bc104..800a8b97f31 100644 --- a/config/root-phase0/apiresourceschema-synctargets.workload.kcp.io.yaml +++ b/config/root-phase0/apiresourceschema-synctargets.workload.kcp.io.yaml @@ -2,7 +2,7 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: creationTimestamp: null - name: v230329-b5e3a0e1.synctargets.workload.kcp.io + name: v230329-eaa109f2.synctargets.workload.kcp.io spec: group: workload.kcp.io names: @@ -194,7 +194,7 @@ spec: type: string message: description: A human readable message indicating details about - the compatibility errors This field may be empty. + the compatibility errors. This field may be empty. type: string resource: description: 'resource is the name of the resource. Note: it is diff --git a/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go b/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go index 2798a843c4b..be35c1f608e 100644 --- a/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go +++ b/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go @@ -129,6 +129,9 @@ func (e *apiCompatibleReconciler) reconcile(ctx context.Context, syncTarget *wor // 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 != "" { + syncTarget.Status.SyncedResources[i].Message = "" + } break } } diff --git a/sdk/apis/workload/v1alpha1/synctarget_types.go b/sdk/apis/workload/v1alpha1/synctarget_types.go index a080a31ffd7..e8362d8aab7 100644 --- a/sdk/apis/workload/v1alpha1/synctarget_types.go +++ b/sdk/apis/workload/v1alpha1/synctarget_types.go @@ -136,8 +136,8 @@ type ResourceToSync struct { // +kubebuilder:default=Pending // +optional State ResourceCompatibleState `json:"state,omitempty"` - - // A human readable message indicating details about the compatibility errors + + // A human readable message indicating details about the compatibility errors. // This field may be empty. // +optional Message string `json:"message,omitempty"` From c16a849da790132133af9d4e2e820356a4cf7324 Mon Sep 17 00:00:00 2001 From: rahulii Date: Fri, 31 Mar 2023 16:17:18 +0530 Subject: [PATCH 3/3] remove if --- .../synctargetexports/synctargetcompatible_reconcile.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go b/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go index be35c1f608e..e231d830102 100644 --- a/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go +++ b/pkg/reconciler/workload/synctargetexports/synctargetcompatible_reconcile.go @@ -129,9 +129,7 @@ func (e *apiCompatibleReconciler) reconcile(ctx context.Context, syncTarget *wor // 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 != "" { - syncTarget.Status.SyncedResources[i].Message = "" - } + syncTarget.Status.SyncedResources[i].Message = "" break } }