Troubleshoot Definitions
This page lists the errors that can occur when you write a definition, with the cause and the fix for each. The errors fall into the following groups:
- Structure validation errors, which the validator reports. They are on this page.
- jq path errors, which occur when a path fails to parse, compile, or run. For more information, refer to Troubleshoot jq Paths.
- Accessor errors, which occur at runtime when code reads a definition that is missing a part, or when a pod cannot be matched to an instance. For more information, refer to Troubleshoot the Go Library.
- Silent mistakes, which pass validation but produce wrong behavior. They are at the end of this page.
If you are new to writing definitions, start with the tutorial. For the full field reference, refer to the Workload Definition Spec.
Structure Validation Errors
The validator runs over the whole definition. The Karta Operator runs the same validator, so these errors also appear in the Validated condition of a definition. To run the validator yourself, use kli validate.
The validator can report several errors at once. It joins them, so fix each component that the output names. One mistake can also cause more than one error. The following output shows two errors that come from one empty name:
The pod-group check applies to the older gangScheduling.podGroups format. The validator does not check that the componentName of each subgroup in the podGroup format names an existing component, so check it yourself. The kli validate command does not return the karta is nil error. For an empty file, it reports the missing fields of the root component instead.
Silent Mistakes
The following mistakes pass validation but lead to a wrong status, missing pods, or no effect. Check them first when a definition validates but behaves incorrectly.
- Using
ownerNameinstead ofownerRef. The API field isownerRef. A child that you write withownerNamedecodes with no owner set. The validator rejects it withchild component '<name>' has no owner ref, but validation runs only whereKartaValidatoris invoked. A code path that skips validation sees a silently unowned child. UseownerRef, and run the validator when you load definitions. - Expecting a
referencedComponentsfield. The structure has onlyrootComponent,childComponents, andadditionalChildKinds. There is noreferencedComponentsfield. Model owned resources as child components, and list other managed kinds underadditionalChildKinds. - Using status conditions that do not match the real API of the workload. The definition validates, but the status never resolves, because the controller never sets those condition types. Verify the condition types and the field names against the CRD source or the documentation of the workload.
- Evaluating paths against the wrong resource. Paths in
specDefinition,scaleDefinition, andstatusDefinitionrun against the workload object. Paths inpodSelectorandoptimizationInstructionsrun against pod manifests. A selector that points at a field on the workload object instead of the pod matches nothing. - Listing the kind of a defined component under
additionalChildKinds. TheadditionalChildKindsfield is only for managed kinds that are not already a child component. Duplicating a defined kind is redundant. The validator does not check for it. - Misspelling a field name. The validator does not reject unknown field names. A misspelled field passes validation and is ignored. Check the spelling of each field.
Still Stuck
- Run through the validation checklist in Step 4 of the tutorial.
- Compare your definition against the closest one in the Catalog of Definitions.
- Check the definition against a real workload with
karta-verify. Validation does not show whether a jq path resolves against a real object. For more information, refer to Define a Workload Type. - Run the offline example in the Go library quickstart to see what the uniform API reads back.