-
Notifications
You must be signed in to change notification settings - Fork 227
feat: Add missing fields to the describe output #915
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
feat: Add missing fields to the describe output #915
Conversation
Add the function * constraints * environment variables * secrets * requests and limits This can be tested as follows: Create a test cluster using KinD ```sh kind create cluster --config=cluster.yaml arkade install openfaas -a=false --function-pull-policy=IfNotPresent --wait faas-cli store deploy nodeinfo --annotation sample=true --label status=418 ``` Now deploy a sample function ```sh $ faas-cli describe nodeinfo Name: nodeinfo Status: Ready Replicas: 1 Available replicas: 1 Invocations: 0 Image: ghcr.io/openfaas/nodeinfo:latest Function process: <default> URL: http://127.0.0.1:8080/function/nodeinfo Async URL: http://127.0.0.1:8080/async-function/nodeinfo Labels faas_function : nodeinfo status : 418 Annotations sample : true prometheus.io.scrape : false Constraints <none> Environment <none> Secrets <none> Requests <none> Limits <none> ``` Now we add some more interesting values, like a secret and env variables. ```sh $ faas-cli secret create db-password --from-literal=password Creating secret: db-password. Created: 202 Accepted $ faas-cli store deploy nodeinfo --annotation sample=true --label status=418 --secret db-password --env db-user=postgres --env db-host=rds.aws.example.com Deployed. 202 Accepted. URL: http://127.0.0.1:8080/function/nodeinfo $ faas-cli describe nodeinfo Name: nodeinfo Status: Ready Replicas: 1 Available replicas: 1 Invocations: 0 Image: ghcr.io/openfaas/nodeinfo:latest Function process: <default> URL: http://127.0.0.1:8080/function/nodeinfo Async URL: http://127.0.0.1:8080/async-function/nodeinfo Labels: faas_function: nodeinfo status: 418 uid: 736815901 Annotations: prometheus.io.scrape: false sample: true Constraints: <none> Environment: <none> Secrets: - db-password Requests: <none> Limits: <none> ``` To see how multiple Secrets and the Requests and Limits are rendered, use ```yaml version: 1.0 provider: name: openfaas gateway: http://127.0.0.1:8080 functions: nodeinfo: lang: Dockerfile image: ghcr.io/openfaas/nodeinfo:latest secrets: - cache-password - db-password environment: db-host: rds.aws.example.com cache-host: redis.aws.example.com labels: status: 481 annotations: sample: "true" requests: cpu: 100m memory: 128Mi limits: cpu: 200m memory: 256Mi ``` then ```sh $ faas-cli secret create cache-password --from-literal=password Creating secret: cache-password. Created: 202 Accepted $ faas-cli deploy Deploying: nodeinfo. Deployed. 202 Accepted. URL: http://127.0.0.1:8080/function/nodeinfo $ faas-cli describe nodeinfo Name: nodeinfo Status: Ready Replicas: 1 Available replicas: 1 Invocations: 0 Image: ghcr.io/openfaas/nodeinfo:latest Function process: <default> URL: http://127.0.0.1:8080/function/nodeinfo Async URL: http://127.0.0.1:8080/async-function/nodeinfo Labels: faas_function: nodeinfo status: 481 uid: 679245186 Annotations: prometheus.io.scrape: false sample: true Constraints: <none> Environment: <none> Secrets: - cache-password - db-password Requests: CPU: 100m Memory: 128Mi Limits: CPU: 200m Memory: 256Mi ``` Signed-off-by: Lucas Roesler <[email protected]>
65bc24c
to
20f8af7
Compare
@@ -103,20 +104,11 @@ func runDescribe(cmd *cobra.Command, args []string) error { | |||
url, asyncURL := getFunctionURLs(gatewayAddress, functionName, functionNamespace) | |||
|
|||
funcDesc := schema.FunctionDescription{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were these fields deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because i just embed the FunctionStatus now instead of copying each field one-at-a-time. This will ensure that the FunctionDescription always has access to the FunctionStatus fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining.
commands/describe.go
Outdated
fmt.Fprintln(w, "URL:\t "+funcDesc.URL) | ||
fmt.Fprintln(w, "Async URL:\t "+funcDesc.AsyncURL) | ||
printMap(w, "Labels", *funcDesc.Labels) | ||
printMap(w, "Annotations", *funcDesc.Annotations) | ||
printList(w, "Constraints", funcDesc.Constraints) | ||
printMap(w, "Environment", funcDesc.EnvVars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "Environment Variables"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra length is going to force the content even wider and add a lot of empty space to the other rows, which will make it harder to read.
It is always env
or environment
in yaml specs, so I think it is pretty clear what it means here.
Environment
also aligns with the output from kubectl describe
Looks good, but we now have quite a long output. Could you update to make these only print text if there are values?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. Just want to iterate on the experience when most of the fields are empty.
This is certainly possible, but I copied the behavior from the existing implementation. There must have been a good reason for including the fields using |
I think you're right, can we add a --verbose flag, and hide some of the other fields like limits / requests / constraints when that's set to false? |
The printer object accepts a parameter to control how verbose it is. When verbose is false, empty values will be omitted from the describe output. Signed-off-by: Lucas Roesler <[email protected]>
Status: "Ready", | ||
}, | ||
verbose: false, | ||
expectedOutput: "Name:\tfiglet\nStatus:\tReady\nReplicas:\t0\nAvailable Replicas: 0\nInvocations:\t0\nImage:\topenfaas/figlet:latest\nFunction Process:\t<default>\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexellis what do you think of this? these two test cases demonstrate the kind of minimal and maximal cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done. The only thing I might suggest is making this a block quote to make it easier to read, but there are pros and cons to that too. We can merge as is, thanks for adding the tests.
return | ||
} | ||
|
||
if usage == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably not print this message, since for anyone who's not on openfaas pro, they will see this all the time, so we could just omit printing it.
Ensure that the values for maps and slices are aligned with the string values. Signed-off-by: Lucas Roesler <[email protected]>
With the latest change, I am seeing a bit of an inconsistency with the environment variable printing I'd expect it to look more like:
I'm seeing the same on secrets:
|
Add the header `Usage:` for the usage data to help it fit with the other fields better Signed-off-by: Lucas Roesler <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add the function
to the
faas-cli describe
output.Motivation and Context
Resolves Could we list secret names for functions on faas-cli describe? #913
How Has This Been Tested?
Create a test cluster using KinD
Now deploy a sample function
Now we add some more interesting values, like a secret and env variables.
To see how multiple Secrets and the Requests and Limits are rendered, use
then
Types of changes
Checklist:
git commit -s