Skip to content

Commit

Permalink
Make OperatorPolicy RelatedObjects optional
Browse files Browse the repository at this point in the history
Other status fields are not required, and this field was specifically
causing an issue for the new validation condition, since it does not
have any relatedObjects associated with it.

This both fixes the CRD and the behavior of the controller (so that
field is always set) so that if the CRD on the cluster is still the
old one, the controller will not get stuck.

Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
  • Loading branch information
JustinKuli committed Feb 19, 2024
1 parent f03275d commit 98f2a68
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/v1beta1/operatorpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ type OperatorPolicyStatus struct {
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty"`
// List of resources processed by the policy
// +optional
RelatedObjects []policyv1.RelatedObject `json:"relatedObjects"`
}

Expand Down
4 changes: 4 additions & 0 deletions controllers/operatorpolicy_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ func (r *OperatorPolicyReconciler) updateStatus(
}

if condChanged || relObjsChanged {
if policy.Status.RelatedObjects == nil {
policy.Status.RelatedObjects = []policyv1.RelatedObject{}
}

return r.Status().Update(ctx, policy)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ spec:
type: string
type: object
type: array
required:
- relatedObjects
type: object
type: object
served: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ spec:
type: string
type: object
type: array
required:
- relatedObjects
type: object
type: object
served: true
Expand Down

0 comments on commit 98f2a68

Please sign in to comment.