Skip to content

Update multi-arch validator to check node affinity for multi-platform environments #276

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

Conversation

jaypoulz
Copy link
Contributor

@jaypoulz jaypoulz commented Jan 28, 2023

Adding a validator to image references for nodeAffinity specifications.
Will check for the following for the CSV images:

  1. Missing node affinity boundaries
  2. Incomplete node affinity boundaries (image supports more than node affinity)
  3. Extra node affinity settings that are not supported by the image data

In doing so I've built upon the work done by @camilamacedo86.

@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 Jan 28, 2023
@openshift-ci openshift-ci bot requested review from anik120 and ecordell January 28, 2023 00:10
@jaypoulz jaypoulz marked this pull request as draft January 28, 2023 00:10
@jaypoulz jaypoulz force-pushed the multi-arch-validator branch 5 times, most recently from 2653a75 to ada51af Compare January 31, 2023 20:15
@jaypoulz jaypoulz marked this pull request as ready for review January 31, 2023 20:16
@openshift-ci openshift-ci bot requested a review from joelanford January 31, 2023 20:16
@jaypoulz
Copy link
Contributor Author

/assign awgreene
I believe that an extension to this which also scans for node affinity discrepancies in the rest of the bundle is desirable, but I wanted to get this patch up for early feedback.

@jaypoulz
Copy link
Contributor Author

/unhold

@jaypoulz jaypoulz changed the title WIP: Began writing validator for nodeAffinity Update multi-arch validator with node affinity validation for multi-platform environments Jan 31, 2023
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 31, 2023
@jaypoulz jaypoulz changed the title Update multi-arch validator with node affinity validation for multi-platform environments Update multi-arch validator to check node affinity for multi-platform environments Jan 31, 2023
@jaypoulz jaypoulz force-pushed the multi-arch-validator branch from ada51af to 0345a47 Compare February 1, 2023 15:33
Copy link
Member

@gallettilance gallettilance left a comment

Choose a reason for hiding this comment

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

Looks good! Don't have much to say - everything is clear and tests are extensive.

Copy link
Member

@awgreene awgreene left a comment

Choose a reason for hiding this comment

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

Looks good, but I'd like to confirm that warnings do not prevent an operator from being published. Thanks for the contribution.

var os = make([]string, 0)

for _, e := range t.MatchExpressions {
if e.Operator != "In" {
Copy link
Member

Choose a reason for hiding this comment

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

This won't support anti-affinity, which I think is fine given the goal of this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The multiarch validator is used in the operator-framework/audit tool to produce a report on the health of operators and is also available for self-validation for operator-sdk authors. It will not block operator publishing. :)

@@ -297,12 +375,12 @@ func (data *multiArchValidator) inspectImages(images map[string][]platform) map[
if err != nil {
data.warns = append(data.warns, fmt.Errorf("unable to inspect the image (%s) : %s", k, err))

// We set the Arch and SO as error for we are able to deal witth these cases further
// We set the Arch and OS as error for we are able to deal witth these cases further
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// We set the Arch and OS as error for we are able to deal witth these cases further
// We set the Arch and OS as error for we are able to deal with these cases further

Comment on lines 418 to 428
// checkMissingSupportForOtherImages checks if any image is missing some arch or so found
// (probably the image should support the arch or SO )
func (data *multiArchValidator) checkMissingSupportForOtherImages() {
for image, plaformFromImage := range data.allOtherImages {
// (probably the image should support the arch or OS )
func (data *multiArchValidator) checkMissingSupportForOtherImages(images map[string][]platform) {
for image, platformFromImage := range images {
Copy link
Member

Choose a reason for hiding this comment

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

Note: No functional changes were made in this function other than the new argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - the function is now called twice (once for the non-manager containers, and then again for the relatedImage containers).
So it seemed simpler to me to parameterize the image list.

Comment on lines +496 to +508
// Ignore the case when the Platform.Architecture == "error" since that means
// that was not possible to inspect the image
if imageData.Architecture == "error" {
imagePlatformDataValid = false
break
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain why it is okay not to log an error here? Is it logged elsewhere when the image fails to be inspected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jaypoulz
Copy link
Contributor Author

Some notes on this PR since I've been evaluating it via the operator-sdk instructions as well as trying to run it through the operator-framework/audit tool:

The audit report is going to flag all operators as those with warnings since by default, the operator scaffolding does not provide a kube-rbac-proxy node affinity specification. I think this may need to be updated as part of operator-framework/operator-sdk#5983 (or another PR focused on providing more opinionated scaffolding). While this report is technically accurate, it does muddy the signal for the 40 or so operators in the redhat-operator-index that have otherwise been compliant as per Camila's original report. I don't think we should remove it or skip that image, but I do think that it would be good to add nodeAffinity for this image to the scaffolding so future operators don't hit this.

@jaypoulz jaypoulz force-pushed the multi-arch-validator branch 3 times, most recently from d64584e to 228bde0 Compare March 14, 2023 21:20
@jaypoulz jaypoulz force-pushed the multi-arch-validator branch from 228bde0 to d1bfcb6 Compare March 16, 2023 19:08
@jaypoulz
Copy link
Contributor Author

jaypoulz commented Apr 5, 2023

/retest

@openshift-ci
Copy link

openshift-ci bot commented Apr 5, 2023

@jaypoulz: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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/test-infra repository.

@awgreene
Copy link
Member

/approve

@openshift-ci
Copy link

openshift-ci bot commented Apr 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: awgreene, jaypoulz

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 Apr 10, 2023
@dtfranz
Copy link
Contributor

dtfranz commented Apr 10, 2023

/lgtm
Thanks for taking this on!

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 10, 2023
@openshift-merge-robot openshift-merge-robot merged commit 0ab3deb into operator-framework:master Apr 10, 2023
@jaypoulz jaypoulz deleted the multi-arch-validator branch April 12, 2023 17:15
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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants