Closed madiTG closed 1 year ago
I'm unable to reproduce this so far.
Just to be clear, you're setting resourceMinimum
and resourceMaximum
as strings, but setting the actual requests/limits using numbers, right?
Are you running against resources in-cluster, or as local YAML files?
Here's my repro attempt: https://github.com/FairwindsOps/polaris/compare/rb/resource-range
I'm unable to reproduce this so far.
Just to be clear, you're setting
resourceMinimum
andresourceMaximum
as strings, but setting the actual requests/limits using numbers, right?Are you running against resources in-cluster, or as local YAML files?
Hello @rbren
Yes, I AM setting these as strings, I couldn't find other option in docs. Should it work only string vs string and number vs number ?
I launch polaris locally, during jenkins pipeline on yaml files.
My yaml file:
metadata:
name: app
labels:
app: app
apiVersion: build.openshift.io/v1
kind: BuildConfig
spec:
output:
to:
name: app:20230808-154210-49-app-
kind: ImageStreamTag
completionDeadlineSeconds: 1800
resources:
limits:
cpu: 2
memory: 1024Mi
requests:
cpu: 1m
memory: 8Mi
source:
git:
uri: https://gitlab/app.git
ref: app
type: Git
dockerfile: |-
#############
### build ###
#############
postCommit: {}
strategy:
type: Docker
dockerStrategy:
env:
- name: POD_APPLICATION
value: app
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
runPolicy: Serial
polaris config:
checks:
buildResourceLimits: danger
customchecks:
buildResourceLimits:
successMessage: success
failureMessage: failure
category: Resources
target: BuildConfig
schema:
'$schema': http://json-schema.org/draft-07/schema
type: object
required:
- spec
properties:
spec:
type: object
properties:
resources:
properties:
limits:
type: object
properties:
cpu:
resourceMinimum: 100m
resourceMaximum: "4"
requests:
type: object
properties:
cpu:
resourceMinimum: 1m
resourceMaximum: "1"
result:
DEBU[0000] the go template input for schema test-case resource=BuildConfig/app is: map[apiVersion:build.openshift.io/v1 kind:BuildConfig metadata:map[labels:map[app:app] name:app] spec:map[completionDeadlineSeconds:1800 output:map[to:map[kind:ImageStreamTag name:app:20230808-154210-49-app-]] postCommit:map[] resources:map[limits:map[cpu:2 memory:1024Mi] requests:map[cpu:1m memory:8Mi]] runPolicy:Serial source:map[dockerfile:#############
### build ###
############# git:map[ref:app uri:https://gitlab/app.git] type:Git] strategy:map[dockerStrategy:map[env:[map[name:POD_APPLICATION value:app] map[name:POD_NAMESPACE valueFrom:map[fieldRef:map[fieldPath:metadata.namespace]]] map[name:POD_NAME valueFrom:map[fieldRef:map[fieldPath:metadata.name]]]]] type:Docker]]]
DEBU[0000] there were 2 issue(s) validating the schema for test-case resource=BuildConfig/app: [Resource quantity 2 is not a string Resource quantity 2 is not a string]
🚀 Upload your Polaris findings to Fairwinds Insights to see remediation advice, add teammates, integrate with Slack or Jira, and more:
❯ polaris audit --log-level debug --audit-path template2 -c config2.yaml --format yaml --set-exit-code-below-score 100 --upload-insights --cluster-name=my-cluster
INFO[0000] Audit score of 0 is less than the provided minimum of 100
My cluster is perfectly fine with this object when i apply it. Maybe polaris is intended to act like this?
What happened?
Hello
When creating object in kubernetes you are allowed to set limits and requests for CPU as number f.e. 2.
When i do polaris audit vs a limit in range, but set as number it fails
What did you expect to happen?
I would expect to parse numbers and compare them in the same manner as strings
How can we reproduce this?
As written above. Check againsta a number vaule in resourceMinimum or resourceMaximum
Version
8.4.0
Search
Code of Conduct
Additional context
No response