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

fix: questions-ui.yml missing latest configuration. #29

Merged
merged 2 commits into from
Apr 16, 2024

Conversation

jvanz
Copy link
Member

@jvanz jvanz commented Apr 9, 2024

Description

The questions-ui.yml file is missing the latest configuration added: ignoreValues. This commits adds this new field in the file. As well as, configures the other fields to be hidden when user sets ignoreValue to false.

@jvanz jvanz added kind/bug Something isn't working area/ui area/policy labels Apr 9, 2024
@jvanz jvanz requested a review from kravciak April 9, 2024 14:14
@jvanz jvanz self-assigned this Apr 9, 2024
@jvanz jvanz requested a review from a team as a code owner April 9, 2024 14:14
@jvanz
Copy link
Member Author

jvanz commented Apr 9, 2024

@kravciak @aalves08 can you review this file as well? :)

@jvanz jvanz force-pushed the add-missing-field-questions-ui branch from 8a22b27 to aae18ce Compare April 9, 2024 14:16
@jvanz jvanz requested a review from aalves08 April 9, 2024 14:17
@flavio flavio mentioned this pull request Apr 10, 2024
3 tasks
Copy link
Member

@viccuad viccuad left a comment

Choose a reason for hiding this comment

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

LGTM

@kravciak
Copy link

@kravciak @aalves08 can you review this file as well? :)

taking a look now, sorry for the delay..

Copy link

@kravciak kravciak left a comment

Choose a reason for hiding this comment

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

I added suggestion for info message (ignore if you prefer yours), but I found an issue:

  • I create policy initially with some values
  • I edit policy and select Ignore values

UI does not clean hidden inputs when I select checkbox, so it produces yaml:

  settings:
    cpu:
      ignoreValues: true
    memory:
      defaultLimit: '100'
      defaultRequest: '100'
      ignoreValues: true
      maxLimit: '100'

Which results in Values cannot be true when any quantities are defined error:

2024-04-11T18:54:06.256680Z  INFO validate_settings{self=PolicyEvaluator { runtime: "wapc" } settings={"allowedHostPaths": Array [Object {"pathPrefix": String("/tmp"), "readOnly": Bool(true)}]}}:policy_log{self=EvaluationContext { policy_id: "clusterwide-do-not-share-host-paths", callback_channel: Some(...), allowed_kubernetes_resources: {} }}: policy_log: accepting settings data={}
Error: [clusterwide-crs] settings are not valid: Some("Provided settings are not valid: invalid memory settings\nignoreValues cannot be true when any quantities are defined")

artifacthub-pkg.yml Outdated Show resolved Hide resolved
artifacthub-pkg.yml Outdated Show resolved Hide resolved
artifacthub-pkg.yml Outdated Show resolved Hide resolved
artifacthub-pkg.yml Outdated Show resolved Hide resolved
questions-ui.yml Outdated Show resolved Hide resolved
questions-ui.yml Outdated Show resolved Hide resolved
questions-ui.yml Outdated Show resolved Hide resolved
questions-ui.yml Outdated Show resolved Hide resolved
@jvanz jvanz force-pushed the add-missing-field-questions-ui branch from f622788 to a0daa6d Compare April 12, 2024 11:55
@jvanz jvanz force-pushed the add-missing-field-questions-ui branch from a0daa6d to 27fd371 Compare April 15, 2024 15:26
@jvanz
Copy link
Member Author

jvanz commented Apr 15, 2024

@kravciak I just updated this PR with the change in the policy to allow the quantities together with the ignoreValues. Can you test it again?

@jvanz jvanz requested a review from kravciak April 15, 2024 19:16
@kravciak
Copy link

I set both CPU & Memory to ignoreValues and I can still create pod without requests section.

apiVersion: v1
kind: Pod
metadata:
  name: frontend
spec:
  containers:
  - name: app
    image: nginx:alpine
    resources:
      limits:
        memory: "128Mi"
        cpu: 100m

I found this in kubernetes doc:

# https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
Note: If you specify a limit for a resource, but do not specify any request, and no admission-time mechanism has applied a default request for that resource, then Kubernetes copies the limit you specified and uses it as the requested value for the resource.

It's a bit misleading considering that in README we say enforce that requests and limits are set - only limits is enforced, requests is auto-completed by kubernetes.

Otherwise it works fine.

@jvanz jvanz force-pushed the add-missing-field-questions-ui branch 4 times, most recently from 6cae077 to 67dfc50 Compare April 16, 2024 14:08
jvanz added 2 commits April 16, 2024 11:27
The questions-ui.yml file is missing the latest configuration added:
ignoreValues. This commits adds this new field in the file. As well as,
configures the other fields to be hidden when user sets ignoreValue to
false.

Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com>
Updates the README.md file mentioning that other admission controller
could mutate the request before the policy. Which can leads to confusing
result like a resource that looks first invalid get being accepted by
the policy due a previous mutation fixing the resource.

Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com>
@jvanz jvanz force-pushed the add-missing-field-questions-ui branch from 67dfc50 to 84a923c Compare April 16, 2024 14:30
@jvanz
Copy link
Member Author

jvanz commented Apr 16, 2024

It's a bit misleading considering that in README we say enforce that requests and limits are set - only limits is enforced, requests is auto-completed by kubernetes.

Yeah, this can be misleading indeed. To help clarify that, I've added a note in the README to explain to the user that others controllers (e.g. kubernetes ones) can be mutating the resource before the policy. Which is the case that you reported. I decided to not change the original sentence that you highlighted because that will happen depending of the admission controller configuration. Are you fine with that change?

@jvanz jvanz merged commit 727bcc9 into kubewarden:main Apr 16, 2024
4 checks passed
@jvanz jvanz deleted the add-missing-field-questions-ui branch April 16, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/policy area/ui kind/bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants