Policy defaults, endpoints and outputs
Implementation, history and tests of the sections on the reference page Policy defaults, endpoints and outputs. Text in square brackets is added here to say what a moved sentence refers to.
Policy defaults & enforcement ordering
- Implementation:
enforce.go’sapplyDefaultQuantity[“fills any request/limit the author left unset”, in the reference’s tier 2.]oam.PolicyDefaultReporter: the workload kinds,cnpg-cluster,persistentvolumeclaimand thepvctrait embed anoam.PolicyDefaultLog; thescalertrait implements the interface itself, so that its config stays comparable [“is reported to the provenance report as apolicyentry”, in the reference’s tier 2.]oam.BuiltinDefaultReporter, embeddedoam.BuiltinDefaultLogincnpg-cluster[“is reported as abuiltinentry”, in the reference’s tier 2.]builtin_defaults.go:BuiltinDefaults()of the workload configs that keep the reshaped form, answered from the paths each parser recorded (parseFills,portFills,accessModesFilled) minus the paths the policy reported, so it is pure; the decision ofstrategy.typeisnonRWXFillsStrategyindeployment_spec.go, whichapplyNonRWXConstrainttakes too [“So is what the parser ofwebserviceandworkerfills”, in the reference’s tier 2; the sentence namedstatefulset,jobandcronjobtoo until go-kure/launcher#1629. The rawdeployment,daemonset,statefulset,jobandcronjobreport no fill.]common.go["buildResourceRequirements", in the reference’s tier 3.]builtin_defaults_generate.go: the generate-time fills, whichBuiltinDefaultsof the reshaped controller kinds (builtin_defaults.go) adds throughgenerateFillPaths. They record nothing. They answer from the config withbuiltinResourceFillsandtokenAutomountIsBuiltin, the functionsbuildResourceRequirementsandbuildPodSpecdecide by, so the report and the generated object cannot disagree [“is reported to the provenance report as abuiltinentry”, in the reference’s tier 3.]capPolicyRequestDefaults,resource_policy_defaults.go[“held to the authored limit for that resource”, in the reference’s tier 3.]enforceMaxResources(enforce.go) closes this by calling the samebuildResourceRequirementsthe generator calls, enforcing against its result, and discarding it —buildResourceRequirementsdeep-copies its maps, so this is read-only and generated output is unchanged. [“this” is the gap described in the History entry below it.]cnpgResourceList[“copies every entry ofc.Resourcesstraight onto the Cluster spec”, in the reference’s sentence onpostgresql.]common.go’sbuildResourceRequirementscall sites at the init-container and sidecar builders [“receive the same intrinsic defaults”, in the reference’s paragraph on init containers and sidecars.]enforce.go[“the sharedenforceExtraContainerhelper”, in the same paragraph.]common.go[“a dedicatedJobSpecConfig/parseJobSpec/applyJobSpec”, in the reference’s paragraph on the twelve JobSpec-level properties; all three are gone since go-kure/launcher#1629, andjobandcronjobdeep-copy their authored spec instead.]applyJobSpec(see the note above) copies every value it writes rather than assigning the config’s own pointers (copyPtrfor the scalars,DeepCopyforsuccessPolicyandpodFailurePolicy, which each own a slice of rules). A handler config outlives oneGeneratecall andGeneratemay run more than once, so an aliased pointer would leave a mutable path from the generated object back into the config — a writer through the object would change what the nextGenerateemits.
- History:
- go-kure/launcher#1181 [“an authored opt-out”, in the reference’s tier 1.]
- go-kure/launcher#1217; the apiserver refuses a request above its limit [“renders a 64Mi request, not 128Mi”, in the reference’s tier 3.]
- Prior to go-kure/launcher#251
the enforcement check ran before the intrinsic tier was computed, so an
application that omitted
spec.resourcesentirely could ship a Deployment whose 100m CPU / 128Mi memory intrinsic defaults exceeded the enforced maximum. [“the enforcement check” is the check ofoam.Policy.MaxCPU()/MaxMemory()described in the reference’s paragraph on the effective value.] - go-kure/launcher#312
["
ApplyPolicyenforces them too", in the reference’s paragraph on init containers and sidecars.] - go-kure/launcher#344
["
jobonto its ownspec", in the reference’s paragraph on the twelve JobSpec-level properties; since go-kure/launcher#1629 that paragraph is gone, becausejobandcronjobdecode the upstream spec whole.]
- Tests:
TestBuiltinDefaults_ResourceFillsAreWhatGenerationAddsandTestBuiltinDefaults_TokenAutomountderive what generation added from the authored properties, the policy’s report and the generated object, and hold the built-in report to it;TestBuiltinDefaults_ReadingChangesNothingholds that reading the report changes neither it nor the objects [“A value the author wrote or a policy default filled is never abuiltinentry”, in the reference’s tier 3.]- Both halves are pinned:
TestSchemaJobSpec_HasNoSuspendKeyon the schema,TestCronjobHandler_SuspendWritesCronJobSpecOnlyandTestJobHandler_SuspendWritesJobSpecon the generated objects. [“Both halves” are the two halves described in the reference’s paragraph “One JobSpec field is deliberately not shared:suspend”.]
Policy refusal classes
- Implementation:
enforce.go,enforcePodTemplatePolicy,enforceRenderedObjectPolicy[“one check raises it”, in the reference’s first bullet.]
- History:
- go-kure/launcher#849 [“instead of matching text”, in the reference’s first paragraph.]
Pod view of a monitoring workload object (MonitoringPodSpec)
- History:
- go-kure/launcher#974 [“finds none to scan”, in the reference’s first paragraph.]
- Tests:
- Each monitoring workload kind adds its case from its own
monitoringWorkloadmapping;TestMonitoringPodSpec_CoversEveryRegisteredWorkloadKind(pkg/oam/builtin/registry) fails on a registered kind of the operator’s API whose spec lists containers and that has no case. [“its ownmonitoringWorkloadmapping” is also “the same mapping” in the reference’s bullet “What it holds”.]
- Each monitoring workload kind adds its case from its own
Declared endpoints of a chart
- Implementation:
chartEndpoints[“One shared schema and parser”, in the reference’s first paragraph.]
- History:
- go-kure/launcher#1132
[“implement
oam.EndpointProviderfrom anendpointsproperty”, in the reference’s first paragraph.]
- go-kure/launcher#1132
[“implement
- Tests:
- the schema-parity test names
endpointsas its one exception ["helmreleasedecodes the rest as itsHelmReleaseSpec", in the reference’s bullet “Not a chart value”.]
- the schema-parity test names
Declared outputs
- History:
- go-kure/launcher#1259
[“implement
oam.OutputProvider”, in the reference’s first paragraph.]
- go-kure/launcher#1259
[“implement