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

[OCPBUGS-42396]Add variable reference for resource_requests_limits rules #12987

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xiaojiey
Copy link
Collaborator

@xiaojiey xiaojiey commented Feb 6, 2025

Description:

Add variable reference for resource_requests_limits_in_daemonset, resource_requests_limits_in_deployment and resource_requests_limits_in_statefuleset rules.

@xiaojiey xiaojiey force-pushed the resource-limites-annotations branch 2 times, most recently from 0d3d2e8 to 3fce1c1 Compare February 7, 2025 04:17
@jan-cerny jan-cerny added the OpenShift OpenShift product related. label Feb 7, 2025
@jan-cerny
Copy link
Collaborator

@xiaojiey Please fill in the PR description.

@xiaojiey xiaojiey changed the title Add variable reference for resource_requests_limits rules [WIP]Add variable reference for resource_requests_limits rules Feb 7, 2025
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Feb 7, 2025
@xiaojiey xiaojiey force-pushed the resource-limites-annotations branch 3 times, most recently from dbc3c5c to 3de9255 Compare February 8, 2025 07:28
@xiaojiey xiaojiey changed the title [WIP]Add variable reference for resource_requests_limits rules [OCPBUGS-42396]Add variable reference for resource_requests_limits rules Feb 8, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Feb 8, 2025
@xiaojiey xiaojiey force-pushed the resource-limites-annotations branch 2 times, most recently from 5359ffa to e18afde Compare February 8, 2025 07:39
@xiaojiey xiaojiey requested a review from yuumasato February 8, 2025 07:40
@BhargaviGudi
Copy link
Collaborator

Verification passed with 4.18.0-0.nightly-2025-02-19-132725 + compliance-operator from https://github.com/ComplianceAsCode/compliance-operator + PR #12987 code

$ oc get rule -o custom-columns=NAME:metadata.name,VARIABLE:metadata.annotations.compliance\\.openshift\\.io/rule-variable --no-headers | grep resource-requests-limits | grep upstream
upstream-ocp4-resource-requests-limits-in-daemonset                                          var-daemonset-limit-namespaces-exempt-regex
upstream-ocp4-resource-requests-limits-in-deployment                                         var-deployment-limit-namespaces-exempt-regex
upstream-ocp4-resource-requests-limits-in-statefulset                                        var-statefulset-limit-namespaces-exempt-regex

@xiaojiey
Copy link
Collaborator Author

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Used by openshift-ci-robot bot. label Feb 26, 2025
@xiaojiey xiaojiey force-pushed the resource-limites-annotations branch from e18afde to 9149934 Compare March 7, 2025 03:53
@xiaojiey xiaojiey force-pushed the resource-limites-annotations branch from 9149934 to 00821b0 Compare March 7, 2025 04:15
Copy link

openshift-ci bot commented Mar 7, 2025

@xiaojiey: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/4.13-images 00821b0 link true /test 4.13-images
ci/prow/4.16-images 00821b0 link true /test 4.16-images
ci/prow/4.17-images 00821b0 link true /test 4.17-images

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Copy link

codeclimate bot commented Mar 7, 2025

Code Climate has analyzed commit 00821b0 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 62.1% (0.0% change).

View more on Code Climate.

@Vincent056
Copy link
Contributor

Vincent056 commented Mar 13, 2025

There are two locations in the operator code requiring fixes in order to address this bug:

  1. First:

At line 998, the existing implementation is not correctly appending all necessary text for parsing values. This function should be updated to the following:

func listNodeFields(node parse.Node, res []string) []string {
	if node.Type() != parse.NodeNil {
		res = append(res, node.String())
	}

	if ln, ok := node.(*parse.ListNode); ok {
		for _, n := range ln.Nodes {
			res = listNodeFields(n, res)
		}
	}
	return res
}
  1. Second Issue:

The logic at this location in the same file needs to be updated so we will return a list of rendered values like https://github.com/ComplianceAsCode/compliance-operator/blob/adbd9f10adcd52c7f3d516b4705aff9b3bb86d75/pkg/profileparser/profileparser.go#L649C1-L650C1

No changes are required for the profile part; only the parsing logic needs to be adjusted as described above.

# todo : better if we can keep openshift document link for this reference,
<p>
To configure resource requests/limits for a deployement, follow the directions in
{{{ weblink(link="https://docs.openshift.com/container-platform/latest/applications/deployments/managing-deployment-processes.html#deployments-setting-resources_deployment-operations",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Used by openshift-ci-robot bot. OpenShift OpenShift product related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants