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

cleanup PR: reflect SELinux policy in RTE DS and report Progressing condition message #1058

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

shajmakh
Copy link
Member

@shajmakh shajmakh commented Oct 25, 2024

Cleanup PR to enhance trouble shooting. Please see the commits for additional info.

Copy link
Contributor

openshift-ci bot commented Oct 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: shajmakh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 25, 2024
Copy link
Member

@ffromani ffromani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea to expose the selinux policy in use but

  1. logging unconditionally will spam the logs
  2. logs are good only for developers, and we have a way to infer it anyway checking the daemonset, there's 1:1 mapping between security context constraint and selinux policy in use.

What about adding an annotation to the RTE daemonset, which the NROP owns anyway?

@shajmakh shajmakh changed the title rte: log if custom SELinux context is used cleanup PR: reflect SELinux policy in RTE DS and report Progressing condition message Oct 29, 2024
@shajmakh
Copy link
Member Author

/hold
under testing

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 29, 2024
@@ -129,6 +129,13 @@ func DaemonSetHashAnnotation(ds *appsv1.DaemonSet, cmHash string) {
template.Annotations[hash.ConfigMapAnnotation] = cmHash
}

func DaemonSetAnnotation(ds *appsv1.DaemonSet, annotKey string, annotValue string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be an overkill, but let's roll with it for now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add it under the spec annotations; or inject a controller event (shown in the operator CR events) which policy is being used. If it doesn't make a difference why do you think this is an overkill?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding a new function in pkg/objectupdate/rte seems overkilly to me, but not enough to change course just yet

@@ -206,80 +210,81 @@ func (r *NUMAResourcesOperatorReconciler) reconcileResourceAPI(ctx context.Conte
return false, ctrl.Result{}, "", nil
}

func (r *NUMAResourcesOperatorReconciler) reconcileResourceMachineConfig(ctx context.Context, instance *nropv1.NUMAResourcesOperator, trees []nodegroupv1.Tree) (bool, ctrl.Result, string, error) {
func (r *NUMAResourcesOperatorReconciler) reconcileResourceMachineConfig(ctx context.Context, instance *nropv1.NUMAResourcesOperator, trees []nodegroupv1.Tree) (bool, ctrl.Result, string, string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we abuse the error instead of adding a new return value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can, progressing condition never produces a real error anyway, but I don't think it is right to abuse it because it'll create a confusion on the reconciliation result.
my take is that we can define a struct to group the common values returned by the substeps used in the reconciliation procedure. OR if we want to keep it as similar to the current state we can create another type to store additional info (includes and error and a string for msg) and replace the returned error

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning a new struct seems the best approach, but this needs a larger refactoring. I'll attempt something in my #1032

@shajmakh
Copy link
Member Author

note: the RTE annotation addition/removal is still buggy

@shajmakh shajmakh changed the title cleanup PR: reflect SELinux policy in RTE DS and report Progressing condition message WIP: cleanup PR: reflect SELinux policy in RTE DS and report Progressing condition message Oct 30, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 30, 2024
When using legacy SELinux context, set that annotation to the RTE DS annotations to make it easy to identify which
policy is being considered.

Signed-off-by: Shereen Haj <[email protected]>
So far when controller update is in progress it's either because RTEs
are not yet ready or MCPs are not yet updated. One can learn that from
examining the controller logs. This PR gives another option to reflect
 this info by reporting the extra info under the condition message both
in the controller logs and in the operator `Status`.

Signed-off-by: Shereen Haj <[email protected]>
Even if the MCP was not updated the controller will still be reporting
it under the operator status. Due to previous adjustments, we are now
seeing all MCPs under the status.

This is wrong however and should change in next commit.

Signed-off-by: Shereen Haj <[email protected]>
So far the operator status was having the mcps set even if they are not
updated. Fix this to reflect the MCPs only if they are updated while
wait for the rest to get reconciled.

Signed-off-by: Shereen Haj <[email protected]>
Add controller tests to verify that when the annotation is set in the
NROP CR it is also reflected under the RTE annotations and when it's
deleted it also vanishes from the DS annotations.

Signed-off-by: Shereen Haj <[email protected]>
Labels and annotations and rarely set but the problem with the old code was that
new sets are added on top of what exists in the current sets either
update the value or add a new key:value pair. However, the case where
the key:value pair is not found in the new set doesn't make a difference
in the new map state and if the key is found in the current map it will
still exist in the updated one, while the required is to omit it.
Apart from the API validations, the controller doesn't validate the
labels set nor the annotations.

Signed-off-by: Shereen Haj <[email protected]>
@shajmakh shajmakh changed the title WIP: cleanup PR: reflect SELinux policy in RTE DS and report Progressing condition message cleanup PR: reflect SELinux policy in RTE DS and report Progressing condition message Oct 30, 2024
@openshift-ci openshift-ci bot removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Oct 30, 2024
@shajmakh
Copy link
Member Author

/hold
rebase on top of #1032 when merged

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants