add resource status to clusterpermission status - #81
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #81 +/- ##
==========================================
+ Coverage 60.71% 60.87% +0.16%
==========================================
Files 3 4 +1
Lines 756 933 +177
==========================================
+ Hits 459 568 +109
- Misses 266 320 +54
- Partials 31 45 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
the old status: status:
conditions:
- lastTransitionTime: "2025-12-08T05:13:41Z"
message: |-
Run the following command to check the ManifestWork status:
kubectl -n local-cluster get ManifestWork example-permissions-e48e3 -o yaml
reason: AppliedRBACManifestWork
status: "True"
type: AppliedRBACManifestWorkthe new status: status:
conditions:
- lastTransitionTime: "2025-12-14T13:42:34Z"
message: |-
Failed to apply manifest work
Run the following command to check the ManifestWork status:
kubectl -n local-cluster get ManifestWork example-permissions-e48e3 -o yaml
reason: AppliedManifestWorkFailed
status: "False"
type: AppliedRBACManifestWork
resourceStatus:
clusterRoleBindings:
- condition:
- lastTransitionTime: "2025-12-14T13:42:34Z"
message: 'Failed to apply manifest: ClusterRoleBinding.rbac.authorization.k8s.io
"clusterpermission-sample" is invalid: roleRef: Invalid value: rbac.RoleRef{APIGroup:"rbac.authorization.k8s.io",
Kind:"ClusterRole", Name:"clusterpermission-sample-2"}: cannot change roleRef'
reason: FailedApplyManifest
status: "False"
type: Applied
name: clusterpermission-sample
clusterRoles:
- condition:
- lastTransitionTime: "2025-12-14T13:42:34Z"
message: Apply manifest complete
reason: AppliedManifestComplete
status: "True"
type: Applied
name: clusterpermission-sample-2
roleBindings:
- condition:
- lastTransitionTime: "2025-12-14T13:42:34Z"
message: 'Failed to apply manifest: RoleBinding.rbac.authorization.k8s.io
"clusterpermission-sample" is invalid: roleRef: Invalid value: rbac.RoleRef{APIGroup:"rbac.authorization.k8s.io",
Kind:"ClusterRole", Name:"clusterpermission-sample-2"}: cannot change roleRef'
reason: FailedApplyManifest
status: "False"
type: Applied
name: clusterpermission-sample
namespace: kube-system
- condition:
- lastTransitionTime: "2025-12-14T13:42:34Z"
message: Apply manifest complete
reason: AppliedManifestComplete
status: "True"
type: Applied
name: clusterpermission-sample-2
namespace: default
roles:
- condition:
- lastTransitionTime: "2025-12-14T13:42:34Z"
message: Apply manifest complete
reason: AppliedManifestComplete
status: "True"
type: Applied
name: clusterpermission-sample-2
namespace: default
- condition:
- lastTransitionTime: "2025-12-14T13:42:34Z"
message: Apply manifest complete
reason: AppliedManifestComplete
status: "True"
type: Applied
name: clusterpermission-sample-2
namespace: kube-public |
|
/assign @qiujian16 please take a look and help review this PR. thanks. |
d2e398f to
b97ff06
Compare
| For(&workv1.ManifestWork{}). | ||
| Watches( | ||
| &workv1.ManifestWork{}, | ||
| handler.EnqueueRequestsFromMapFunc(r.findClusterPermissionForManifestWork), |
There was a problem hiding this comment.
Why not use handler.EnqueueRequestForOwner{}?
There was a problem hiding this comment.
watch manifestwork with the clusterpermission owner, request key is the manifestwork name and namespace.
| // SetupWithManager sets up the controller with the Manager. | ||
| func (r *ClusterPermissionStatusReconciler) SetupWithManager(mgr ctrl.Manager) error { | ||
| return ctrl.NewControllerManagedBy(mgr). | ||
| For(&workv1.ManifestWork{}). |
There was a problem hiding this comment.
What is the primary reconciliation subject of this controller? ManifestWork or ClusterPermission?
| if newStatus.ResourceStatus == nil { | ||
| newStatus.ResourceStatus = &cpv1alpha1.ResourceStatus{} | ||
| } | ||
| r.updateResourceStatus(newStatus.ResourceStatus, manifestWork) |
There was a problem hiding this comment.
Why the resource status is updated only when Spec.Validate is false?
There was a problem hiding this comment.
fixed that always update resorucestatus
e1b2be5 to
9d2bf30
Compare
|
@mshort55: changing LGTM is restricted to collaborators DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
a909172 to
afa304b
Compare
Signed-off-by: Zhiwei Yin <zyin@redhat.com>
afa304b to
5487504
Compare
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: elgnay, mshort55, zhiweiyin318 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
7f77607
into
open-cluster-management-io:main
update status of clusterpermission, and add resourceStatus filed to show each rbac resources status.