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

improve error messages #20

Closed
4 tasks done
ssube opened this issue Jul 2, 2019 · 2 comments
Closed
4 tasks done

improve error messages #20

ssube opened this issue Jul 2, 2019 · 2 comments
Assignees
Labels
scope/visitor status/fixed issues that have been fixed and confirmed type/feature
Milestone

Comments

@ssube
Copy link
Owner

ssube commented Jul 2, 2019

The raw error messages from Ajv and diffs from deep-diff are not the most readable, but are wonderfully detailed:

{"name":"salty-dog","hostname":"cerberus","pid":23892,"level":20,"item":{"metadata":{"name":"example"},"spec":{"template":{"spec":{"containers":[{"name":"test"}]}}}},"msg":"checking item","time":"2019-07-01T14:09:15.175Z","v":0}
{"name":"kubernetes-labels","hostname":"cerberus","pid":23892,"level":40,"errors":[{"keyword":"required","dataPath":".metadata","schemaPath":"#/properties/metadata/required","params":{"missingProperty":"labels"},"message":"should have required property 'labels
'"}],"item":{"metadata":{"name":"example"},"spec":{"template":{"spec":{"containers":[{"name":"test"}]}}}},"rule":{"desc":"all resources should have labels","level":"info","name":"kubernetes-labels","select":"$","tags":["kubernetes","labels"],"check":{"type":"o
bject","required":["metadata"],"properties":{"metadata":{"type":"object","required":["labels"],"properties":{"labels":{"type":"object","additionalProperties":false,"patternProperties":{"^[-.a-z0-9]{1,63}$":{"type":"string"}}}}}}}},"msg":"rule failed on item","
time":"2019-07-01T14:09:15.175Z","v":0}                       
{"name":"salty-dog","hostname":"cerberus","pid":23892,"level":40,"count":1,"rule":{"desc":"all resources should have labels","level":"info","name":"kubernetes-labels","select":"$","tags":["kubernetes","labels"],"check":{"type":"object","required":["metadata"],
"properties":{"metadata":{"type":"object","required":["labels"],"properties":{"labels":{"type":"object","additionalProperties":false,"patternProperties":{"^[-.a-z0-9]{1,63}$":{"type":"string"}}}}}}}},"msg":"rule failed","time":"2019-07-01T14:09:15.175Z","v":0}
{"name":"salty-dog","hostname":"cerberus","pid":23892,"level":50,"count":2,"errors":[{"keyword":"required","dataPath":"","schemaPath":"#/required","params":{"missingProperty":"resources"},"message":"should have required property 'resources'"},{"keyword":"requi
red","dataPath":".metadata","schemaPath":"#/properties/metadata/required","params":{"missingProperty":"labels"},"message":"should have required property 'labels'"}],"msg":"some rules failed","time":"2019-07-01T14:09:15.175Z","v":0}

Parts:

@ssube ssube added status/planned issues that have been planned but not started type/feature scope/visitor labels Jul 2, 2019
@ssube ssube self-assigned this Jul 2, 2019
@ssube ssube added this to the v0.8 milestone Nov 2, 2019
@ssube
Copy link
Owner Author

ssube commented Nov 2, 2019

Messages are much improved, but still not quite there:

[
  "some rules failed",
  ".resources.limits should have required property 'memory' at $.spec.template.spec.containers[*] for kubernetes-resources",
  ".metadata should have required property 'labels' at $ for kubernetes-labels"
]

These explain the rule that was running and the selector used, but not which item was selected (the index). For a deployment with many containers, there's no way to tell which container failed without digging through the logs.

@ssube
Copy link
Owner Author

ssube commented Nov 3, 2019

Adding the visited item index means moving the ...check.errors.map((err) => friendlyError(ctx, err, this)) call at https://github.com/ssube/salty-dog/blob/fix/xx-build-template/src/rule/SchemaRule.ts#L60 up into visitRules, which should itself be formalized into a generic visiting method and a specific rule inner.

@ssube ssube changed the title improve error messages and diffs improve error messages Nov 10, 2019
@ssube ssube added status/fixed issues that have been fixed and confirmed and removed status/planned issues that have been planned but not started labels Nov 10, 2019
@ssube ssube closed this as completed Nov 10, 2019
@ssube ssube mentioned this issue Nov 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope/visitor status/fixed issues that have been fixed and confirmed type/feature
Projects
None yet
Development

No branches or pull requests

1 participant