Repository navigation
Fix(cuex): send vela/http request headers as the template declares them - #157
Merged
Merged
Conversation
http.cue declares request headers and trailers as one string per name, but RequestVars decoded them as http.Header, a list per name. CUE refuses a list and the decoder refuses a string, so a template could set no request header at all: the call failed with "cannot unmarshal string into Go struct field DoParams.$params.request.header.X-Token of type []string". RequestVars now takes one string per name and the http.Header is built with Add, so names that differ only in case each keep their value. This matches the vela/http workflow provider, which has always taken headers this way. NewRequest builds the request a vela/http call describes, so a provider that sends it through its own client (kubevela's guarded vela/http) builds it the same way. Fixes kubevela/kubevela#7595 Signed-off-by: Brian Kane <briankane1@gmail.com>
briankane
requested review from
FogDong,
Somefive,
anoop2811,
jerrinfrancis,
jguionnet and
roguepikachu
as code owners
November 19, 2026 09:24
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #157 +/- ##
=======================================
Coverage 92.56% 92.56%
=======================================
Files 115 115
Lines 6937 6944 +7
=======================================
+ Hits 6421 6428 +7
Misses 516 516
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
NewRequest replaced the request's header map with nil when a template sets no headers, so a caller adding a header to the result panicked. Headers are now added to the map the constructor made; trailers stay nil unless set, as net/http leaves them. Signed-off-by: Brian Kane <briankane1@gmail.com>
jerrinfrancis
approved these changes
Nov 19, 2026
briankane
added a commit
to briankane/kubevela
that referenced
this pull request
Nov 19, 2026
Bump kubevela/pkg to ff99f28 (kubevela/pkg#157), which reads request headers and trailers as one string per name and exports NewRequest. guardedhttp drops its own request types and builds the request with NewRequest, keeping only its own client and response read. Headers are now added with Header.Add, so names that differ only in case (X-Tag, x-tag) each reach the request. Signed-off-by: Brian Kane <briankane1@gmail.com>
briankane
added a commit
to briankane/kubevela
that referenced
this pull request
Nov 19, 2026
vela/http's template declares request headers and trailers as one string per name, but guardedhttp decoded them into the upstream RequestVars, which takes http.Header, a list per name. CUE refuses a list and the decoder refuses a string, so a component, trait, policy or source template could set no request header at all: the call failed with "cannot unmarshal string into Go struct field DoParams.$params.request.header.X-Token of type []string". Bump kubevela/pkg to ff99f28 (kubevela/pkg#157), which reads request headers and trailers as one string per name and exports NewRequest. guardedhttp drops its own request types and builds the request with NewRequest, keeping only its own client and response read. Headers are now added with Header.Add, so names that differ only in case (X-Tag, x-tag) each reach the request. Signed-off-by: Brian Kane <briankane1@gmail.com>
briankane
added a commit
to briankane/kubevela
that referenced
this pull request
Nov 19, 2026
vela/http's template declares request headers and trailers as one string per name, but guardedhttp decoded them into the upstream RequestVars, which takes http.Header, a list per name. CUE refuses a list and the decoder refuses a string, so a component, trait, policy or source template could set no request header at all: the call failed with "cannot unmarshal string into Go struct field DoParams.$params.request.header.X-Token of type []string". Bump kubevela/pkg to ff99f28 (kubevela/pkg#157), which reads request headers and trailers as one string per name and exports NewRequest. guardedhttp drops its own request types and builds the request with NewRequest, keeping only its own client and response read. Headers are now added with Header.Add, so names that differ only in case (X-Tag, x-tag) each reach the request. Signed-off-by: Brian Kane <briankane1@gmail.com>
briankane
added a commit
to briankane/kubevela
that referenced
this pull request
Nov 19, 2026
vela/http's template declares request headers and trailers as one string per name, but guardedhttp decoded them into the upstream RequestVars, which takes http.Header, a list per name. CUE refuses a list and the decoder refuses a string, so a component, trait, policy or source template could set no request header at all: the call failed with "cannot unmarshal string into Go struct field DoParams.$params.request.header.X-Token of type []string". Bump kubevela/pkg to ff99f28 (kubevela/pkg#157), which reads request headers and trailers as one string per name and exports NewRequest. guardedhttp drops its own request types and builds the request with NewRequest, keeping only its own client and response read. Headers are now added with Header.Add, so names that differ only in case (X-Tag, x-tag) each reach the request. Signed-off-by: Brian Kane <briankane1@gmail.com>
briankane
added a commit
to briankane/kubevela
that referenced
this pull request
Nov 19, 2026
vela/http's template declares request headers and trailers as one string per name, but guardedhttp decoded them into the upstream RequestVars, which takes http.Header, a list per name. CUE refuses a list and the decoder refuses a string, so a component, trait, policy or source template could set no request header at all: the call failed with "cannot unmarshal string into Go struct field DoParams.$params.request.header.X-Token of type []string". Bump kubevela/pkg to ff99f28 (kubevela/pkg#157), which reads request headers and trailers as one string per name and exports NewRequest. guardedhttp drops its own request types and builds the request with NewRequest, keeping only its own client and response read. Headers are now added with Header.Add, so names that differ only in case (X-Tag, x-tag) each reach the request. Signed-off-by: Brian Kane <briankane1@gmail.com>
briankane
added a commit
to briankane/kubevela
that referenced
this pull request
Nov 19, 2026
vela/http's template declares request headers and trailers as one string per name, but guardedhttp decoded them into the upstream RequestVars, which takes http.Header, a list per name. CUE refuses a list and the decoder refuses a string, so a component, trait, policy or source template could set no request header at all: the call failed with "cannot unmarshal string into Go struct field DoParams.$params.request.header.X-Token of type []string". Bump kubevela/pkg to ff99f28 (kubevela/pkg#157), which reads request headers and trailers as one string per name and exports NewRequest. guardedhttp drops its own request types and builds the request with NewRequest, keeping only its own client and response read. Headers are now added with Header.Add, so names that differ only in case (X-Tag, x-tag) each reach the request. Signed-off-by: Brian Kane <briankane1@gmail.com>
briankane
added a commit
to briankane/kubevela
that referenced
this pull request
Nov 19, 2026
vela/http's template declares request headers and trailers as one string per name, but guardedhttp decoded them into the upstream RequestVars, which takes http.Header, a list per name. CUE refuses a list and the decoder refuses a string, so a component, trait, policy or source template could set no request header at all: the call failed with "cannot unmarshal string into Go struct field DoParams.$params.request.header.X-Token of type []string". Bump kubevela/pkg to ff99f28 (kubevela/pkg#157), which reads request headers and trailers as one string per name and exports NewRequest. guardedhttp drops its own request types and builds the request with NewRequest, keeping only its own client and response read. Headers are now added with Header.Add, so names that differ only in case (X-Tag, x-tag) each reach the request. Signed-off-by: Brian Kane <briankane1@gmail.com>
briankane
added a commit
to briankane/kubevela
that referenced
this pull request
Nov 19, 2026
vela/http's template declares request headers and trailers as one string per name, but guardedhttp decoded them into the upstream RequestVars, which takes http.Header, a list per name. CUE refuses a list and the decoder refuses a string, so a component, trait, policy or source template could set no request header at all: the call failed with "cannot unmarshal string into Go struct field DoParams.$params.request.header.X-Token of type []string". Bump kubevela/pkg to ff99f28 (kubevela/pkg#157), which reads request headers and trailers as one string per name and exports NewRequest. guardedhttp drops its own request types and builds the request with NewRequest, keeping only its own client and response read. Headers are now added with Header.Add, so names that differ only in case (X-Tag, x-tag) each reach the request. Signed-off-by: Brian Kane <briankane1@gmail.com>
briankane
added a commit
to kubevela/kubevela
that referenced
this pull request
Nov 20, 2026
* Chore(deps): bump kubevela/workflow and kubevela/pkg for the release-testing fixes github.com/kubevela/workflow at 82f4127ffc37d3590edca31c2d16b727fce77e69 and github.com/kubevela/pkg at 000437b6ca9351aa6afccf52fe87fa11ebd04a0f, where their fixes merged. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(utils): replace an object's lists exactly in CreateOrUpdate CreateOrUpdate unmarshalled the desired object over the live one. JSON decoding reuses existing slice elements, so a field the desired element omits kept the value of the element that held its slot before: removing a subject from a RoleBinding could leave the next subject with the removed one's fields. The unmarshal error was also checked against the wrong variable and dropped. The live object is now reset before the desired one is written over it, keeping the metadata the API server owns, and the error is returned. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(http): bound builtin and definition HTTP requests like workflow's The builtin HTTP command ran on a background context and read its whole response; vela/http in component, trait and policy definitions had no timeout at all; and the request, notification and webhook steps accepted a timeout of "0", which reached the provider as none. The builtin command now refuses a timeout that is invalid, zero, negative or over the maximum instead of silently using 3s, keeps an unset one to 3s or the maximum when that is lower, runs on its context, and refuses an oversized body. vela/http, which has no timeout parameter, times out at the maximum and refuses an oversized body. --max-workflow-http-timeout and --max-workflow-http-response-bytes set the bounds, exposed in the chart as workflow.http.maxTimeout and workflow.http.maxResponseBytes, and the controller refuses to start with either at zero or below. The three steps' timeout must be a duration with a unit, and webhook sets it inline so an invalid one fails the step. Needs kubevela/workflow with httpguard.RequestTimeout and ReadResponseBody. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): let a stored problem through an update that leaves the spec as it is The Application webhook validated every update in full, so an Application admitted before a rule existed (two traits 1.12 refuses together, say) refused every later update: a label, a publishVersion bump, an identical GitOps apply. A WorkflowStepDefinition admitted before its template had to compile did the same. When an update leaves the spec unchanged and fails, the stored object is validated too, and the errors it already has are returned as warnings instead of refusing the update. Errors are compared by path, type and detail. The checks on who is asking (annotations, definition permissions), immutable fields, a definition's revision annotation and every spec change are still enforced in full. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(definition): keep pinned and unchanged definition revisions A DefinitionRevision's hash covers the definition spec's Go struct, so a release that adds a field to a definition type changes every definition's hash with its content unchanged. A hash mismatch minted a new revision without comparing content, so upgrading cut a revision for every definition, and the garbage collector then deleted the oldest beyond the limit without checking whether an Application pins one with type@vN, so pinned Applications stopped rendering. The last revision's content is now compared whatever the hashes say. A revision an Application pins, in a component, trait, policy, workflow step or source, is kept and not counted against the limit. A new informer index, DefinitionPinIndex, maps Applications by the revisions they pin; a sharded controller reads them from the API server, as its cache holds only its own shard. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(definition): number a re-created definition's revisions from where it left off A definition's revisions go with it when it is deleted, so one created again under the same name started at v1, and an Application pinned to type@v1 rendered the new content. Where an orphaning delete left the old revisions, the new v1 collided with them and the definition's status named a revision holding the old content. A GitOps replace, which deletes and re-creates a definition unchanged, broke every pin on it. The next number is now one past the highest the name has had, kept in the definition's status, a definition-revision-numbers ConfigMap in its namespace, and the revisions still in the cluster. The record also keeps the hash of each of the newest 20 numbers, so a definition re-created with content it had takes that content's number back. Content it never had takes a new number, and a pin on a number it no longer has fails as not found instead of binding to other content. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(workflow): stop completed side-effect steps running again A workflow step's record is written to the Application's status after the step runs, and two things lost it, so completed webhook and notification steps ran again: - A reconcile could start from a cached Application older than its own last status write, missing the steps that write recorded; a stale copy from before a publishVersion restart restarted the run a second time. - The status write carries the resourceVersion, so any concurrent write to the Application (a GitOps sync, kubectl annotate) failed it with a conflict and the record was dropped. A reconcile now reads the Application from the API server when the cache has not caught up with the copy the last reconcile finished with. A status write that conflicts with a write to the Application's metadata or spec is reapplied to the live Application, up to three attempts; one whose status another writer changed, such as a workflow resume, is dropped and requeued as before, so that change is kept. A failed write no longer resets the step guard. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(query): list a resource's owned children in its namespace A child kind the tree finds by owner reference, such as a Service's EndpointSlices, was listed across the whole cluster and filtered by owner. A reader confined to namespaces, as VelaUX's project group is, cannot list cluster wide, and the forbidden list failed the parent, so the resource tree dropped every Service. A namespaced parent's children are listed in its namespace, where owner references keep them, and a child kind the reader may not list is left out instead of failing the parent. Both copies of the tree change. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(config): keep config steps and the vela-config source to the Application's namespace read-config, list-config, create-config and delete-config, and the vela-config source, took the config's namespace from the step or the binding and acted with the controller's identity in any namespace. A config outside the Application's namespace is now reached only to read a shared system config (one made in vela-system from a system-scoped template, as platform configs are) or, with the AuthenticateApplication gate on, where the Application's user may do the same. The rule is config.AccessToConfig, shared by the steps and the source. The source resolver records the consuming Application's namespace in the Go context, where no definition can set it, and vela-config's cached values are kept per namespace. The controller and the Application webhook record it too, so a component or trait that calls vela/velaconfig directly keeps to the same rule. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): enforce definition restrictions and quotas on indirect uses The restriction and quota checks read only the types an Application names inline, so a definition was not checked when it came in through an override policy's component type or trait, a step of the Workflow spec.workflow.ref names, or a module type, and a trait's conflictsWith inherited through extends was ignored. Each of these is now checked, reported at the field that brings the definition in; a trait's conflicts include those it inherits. Uses through override policies count against quotas (DefinitionUsageOf lists them) and share one budget with inline uses. Admission lets an unchanged spec through, so the controller now runs the same restriction check while it reconciles and records a RestrictionViolation condition naming each use, with a Warning event when that changes; it never fails the render. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): check definition permissions on referenced Workflows and Policies With definition permission validation on, the webhook checked only the definitions an Application names inline, not those it reaches through spec.workflow.ref, a deploy step's Policy objects or override policies, and nothing checked Workflow and Policy objects when they were written. The definitions an Application reaches are found once, by indirectReach, which now also reads the Policy objects deploy steps load. The permission check runs on each as if it were named inline, at the field that brings it in, and refuses a reference to a Workflow or Policy the requester cannot read. A validating webhook on core.oam.dev/v1alpha1 Workflows and Policies checks, on create and update, the definitions each names against the requester's permissions and the namespace restrictions, under the same feature gates. The paths are registered in Go, the chart and the debug script. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): judge the controller's writes by the Application that dispatched them The webhook accepted any write made with vela-core's own identity, which shows only that an object came through dispatch, not for which Application. That covered modules.oam.dev/install-namespace on a nested Application, and Workflow and Policy objects a component dispatches. What the controller writes is now judged for the Application that dispatched it, from the labels it stamps on everything it dispatches: install-namespace is accepted only when modules would install into that Application's namespace (where the addon renderer records it), and a Workflow or Policy object is checked against that Application's namespace restrictions, and its definition permissions as its author where that identity is trusted (AuthenticateApplication with the username stamped). Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): an addon component needs an author who may install addons An addon component makes the controller install the addon: its Application in vela-system and every resource it holds, cluster-scoped ones included. The feature gate was the only check. The Application webhook now refuses an addon component unless its author may create Applications in vela-system, which is what installing an addon takes. One the controller writes is judged for the Application that dispatched it: an addon's own Application in vela-system may still install the addons it depends on, and one dispatched from elsewhere is checked as that Application's author where the identity is trusted. The chart also restricts the addon definition to vela-system by default (definitionRestrictions.overrides.addon). Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(workflow): read a shared Workflow as the Application's author spec.workflow.ref falls back to a Workflow of that name in vela-system, so platform teams can share one across namespaces. The controller read it with its own identity, from its cache, whether or not the Application's author could. With AuthenticateApplication on, the parser asks, as the Application's author, whether they may get the Workflow the ref resolved to, once per parse, and fails the render naming the Workflow and the user when they may not. The admission check under ValidateDefinitionPermissions resolves the ref the same way. The Application reports the Workflow it ran in status.workflow.ref, and the ref field documents the lookup and the permission it needs. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(resource): set only the cpu or memory given, and test shipped definitions' renders With only cpu or only memory set, the resource trait applied both, defaulting the other to 1 cpu or 2048Mi, so an Application that set only cpu gained a 2Gi memory limit on its first edit after upgrading. Either one alone now sets just itself, in requests and limits, as a patch of its own: CUE carries a field's patch-strategy comment from every branch that declares it, taken or not. Changes like this reached users unnoticed, since each definition test asserts only the fields it names. Every successful render case of a shipped definition now has a golden file of what reaches the cluster, compared by make test-definitions and rewritten with make update-definition-goldens. TestShippedPatchStrategiesAgree fails a field declared with different patch strategies in different branches. hack/definition-render-diff.sh lists, and with -v shows, how each shipped definition renders differently from an earlier release's. Signed-off-by: Brian Kane <briankane1@gmail.com> * Feat(hack): downgrade vela-core from 1.12 to 1.11 helm rollback from 1.12 fails, and a helm upgrade to the 1.11 chart leaves a half-downgraded install: since 1.12 a hook Job applies the builtin definitions outside the release, so the 1.11 release finds definitions it no longer owns. hack/downgrade-from-1.12.sh puts the 1.11 builtins back under Helm's field manager with Helm's ownership metadata, upgrades to the 1.11 chart with the release's values and the 1.11 controller image, removes the admission webhooks only 1.12 serves (config Secrets included, which would otherwise refuse every config Secret update), and verifies all three. The 1.11 chart is applied client side, as it was written for. A run that failed part-way can be run again. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(config): adopt legacy configs before writing, and guard adopted Secrets vela config create on the name of a legacy config wrote a Config beside the legacy Secret and reported success; the Config went to Error and consumers kept reading the old value. After migration, a 1.11 CLI or VelaUX 1.9.5 edit rewrote the adopted Secret without its migration mark, splitting the config silently. UpsertConfigCR now adopts a legacy config of the name before writing, and refuses, writing nothing, one that cannot be adopted, with the reason. A validating webhook on config Secrets (selected by the velacore-config catalog label, updates only) refuses an update that removes the migration mark, or the catalog label the webhook selects on, naming the Config and the clients that can edit it. It fails closed like the Config webhook beside it. Signed-off-by: Brian Kane <briankane1@gmail.com> * Feat(config): take a template's CR for its ConfigMap when one Application controls both A ConfigTemplate stood for a legacy template ConfigMap of its name only when migration had adopted the ConfigMap into it. An addon that now installs its template as a ConfigTemplate leaves both, owned by the addon's Application, so migrating a config on that template reported a conflict and the CLI listed the ConfigMap as shadowed. TemplateStandsFor is the one rule: the ConfigMap's migrated-to names the CR, or one Application controls both. Config and template migration and the CLI's template list use it. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(request): succeed on a reply that is not JSON, and fail on a 400 The request step parsed every reply as JSON, so a successful empty or text reply was an error after the request had been made, and every retry sent the request again. The reply is kept as responseBody and parsed into response only when it is JSON. A status of 400 now fails the step as other client errors do: the check was greater than 400. Signed-off-by: Brian Kane <briankane1@gmail.com> * Docs(requiredcrds): Helm fails an upgrade only for kinds the manifest holds The package comment said helm upgrade fails outright on a missing CRD. Since a hook Job applies the builtin definitions, Helm's own check covers only kinds with an instance in the release manifest; a missing CRD of any other kind passes helm upgrade, and this check is what says why. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): stop validating an Application once its request is cancelled The Application webhook rendered every component however long that took. A large Application (about 600 components) kept it busy for some 42 seconds, most of it after the API server's 10 second webhook timeout had already failed the request, and concurrent requests stacked. Validation now runs under the request's context, which the API server cancels when it stops waiting: component parsing and the CUE schematic check look at it before each component. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): explain, and refuse up front, an earlier Application's ResourceTrackers A restore that includes ResourceTrackers creates the Application with a new uid beside trackers naming the old one. The controller refused them on every reconcile with a message that blamed garbage collection and said to delete the tracker, which its finalizer would hold. The webhook now refuses to create an Application while a ResourceTracker of its name and namespace names another uid, and the controller's refusal of an existing one says the same: what leaves such a tracker, and the two remedies, removing its uid label to take it over with its resources, or removing its finalizer and deleting it, leaving them. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helm): refuse a release another Application owns A helmchart component whose release name matched a release owned by another Application, or by another component of the same one, adopted it with a forced upgrade, so the two replaced each other's workload on every reconcile. The provider now reads the existing release's owner labels first: its own release carries on, a plain helm install is still adopted, and a release whose owner Application still exists is refused, naming the owner and release.name. A release whose owner is gone is adopted and its Secrets relabelled. A release Helm cannot read is recovered only when its Secrets' owner labels allow the same. The e2e spec expects the refusal up front. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helm): keep the Application as a release's owner under a topology namespace helmchart passed context.namespace as the Application's namespace, which under a topology policy's namespace is the target namespace, so the release was labelled for an Application that does not exist there: the provider missed the Application, installed without its user, and the resource keeper refused the release Secret. context.appNamespace is the Application's own namespace wherever the component is placed. It is in the context registry, so definitions, parameter schemas and definition tests can read it, and helmchart passes it to the provider. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helmchart): name a release after its component when only its namespace is set With release.namespace and no release.name, helmchart left the name unset: the template failed to render its release ConfigMap, and the provider named the release "release", shared by every such component in the namespace. Name and namespace now default independently, and the provider falls back to the component's name and namespace. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helm): move 1.11's hub-installed releases to where their components are placed 1.11 installed a helmchart component placed on a managed cluster on the hub, and dispatched its objects and copies of the release Secrets to the managed cluster. The first 1.12 install there failed, as Helm refuses objects without its ownership metadata, and the hub copy kept running outside any ResourceTracker. When an install fails that way, the provider marks the live objects that carry this component's labels, and no other release's annotations, with Helm's ownership metadata and removes the component's placeholder release Secrets before one retry; the post-renderer labels chart objects as managed by Helm. When a workflow run succeeds and the ResourceTracker holds a release Secret on a managed cluster, the controller uninstalls, as the Application's user, each hub release whose component is placed only elsewhere. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helm): read chart credentials and values only from the Application's namespace The Helm provider read a chart's auth Secret, and its valuesFrom Secrets and ConfigMaps, from the Application's namespace or the release namespace, which the Application chooses. Both are now read only from the Application's namespace, the default when none is named, and any other is refused, the release namespace included. A render with no Application context reads none. The controller's valuesFrom fingerprint, which rolls a release out when a source changes, resolves sources by the same rule. The valuesFrom e2e specs keep their Application in its release's namespace, so the sources are its own. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(sources): keep sensitive source fields out of the workflow context A workflow run pins every source a step reads in the workflow context, a ConfigMap, so later steps read the same value. The pin held the whole resolved value, +sensitive fields included, and every ApplicationRevision copied it into status.workflowContext. The sensitive fields of a pinned source now go to a Secret the Application owns, workflow-<app>-sources, and the context holds a pointer to each in its place, secret:<name>/pins#<source>.<path>, with the paths listed under sealed. Only those paths are followed back. A pin whose field the Secret no longer has is resolved again. ApplicationRevisions no longer keep a run's pins. A Secret of that name the Application does not control is neither read nor written. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(sources): honour +sensitive marks inside comprehensions A +sensitive mark was read only from fields written directly in a struct or list literal. One inside a list comprehension, the usual way to build a list from parameters in output:, or inside an if block was skipped, so its field was masked neither in status.sources nor in the workflow context. The marker walk now descends into the fields a comprehension adds, for and if alike, nested or not. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(auth): run as the default user when authentication.withUser is off With AuthenticateApplication on and authentication.withUser off, an Application is documented to run as the default user with the requester's groups. The webhook stamped the groups but kept an app.oam.dev/username annotation already on the object, and the controller acted as that user. In that mode the webhook removes the username, and the identity read from an Application ignores one, so those stored before are covered. With withUser on, the requester's username replaces whatever was written, as before; with the gate off, nothing changes. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(definitions): run the vela-cli step's Job where the Application is The vela-cli step's Job ran as vela-core's own service account by default, and that default also placed the Job in vela-system. The Job now always runs in the Application's namespace, as the service account it names there, default unless set. A platform Application in vela-system can still name kubevela-vela-core. The chart restricts vela-cli to vela-system by default (definitionRestrictions.overrides.vela-cli), since the step also takes an image, command, Secret and host path mounts. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(core): always deny loopback, unspecified and local-use NAT64 addresses to outbound requests The outbound HTTP guard denied the deny list and, optionally, private addresses, but not loopback, the unspecified address or the local-use NAT64 prefix. The controller's policy now always denies 127.0.0.0/8 and ::1, 0.0.0.0/8 and ::, and 64:ff9b:1::/48, on top of the deny list and the private-address setting. An address under the well-known NAT64 prefix, 64:ff9b::/96, is checked by the IPv4 address it carries (kubevela/workflow), so DNS64 to an allowed host still works. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helm): pull OCI charts through the outbound guard Chart sources over HTTP and Helm repositories went through the outbound guard, but oci:// sources used the registry client's own HTTP client. The registry client now dials through the guard and follows only the redirects it allows. A pull times out after five minutes, and a cancelled render stops waiting for it. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(terraform): read remote modules from Git objects, with the definition's own key A remote Terraform ComponentDefinition is cloned so its variables can be read into its schema. The clone was checked out before its size was checked, the SSH key Secret could be named in any namespace, and the Secret's known hosts went to one file every clone shared through an environment variable. The module is now cloned bare and only variables.tf or main.tf is read, from Git's objects, refused before reading when it is a symlink, not a file, over the size cap, or outside the module. A cache that is not a Git repository is cloned afresh. The SSH key Secret is read from the definition's namespace, and the key checks the remote against that Secret's known hosts alone. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(chart): render the configured failure policy in cert-manager mode The chart rendered every webhook failurePolicy: Ignore whenever admissionWebhooks.patch.enabled was on. That suits the default mode, where vela-core manages the serving cert and sets the configured policy once it serves, but with cert-manager nothing ever set it, so the webhooks stayed Ignore. Ignore is now rendered only when vela-core manages the cert. With cert-manager or a supplied Secret the configured policy (Fail by default) applies from the start. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(cue): refuse CUE nested too deeply before parsing it CUE's parser recurses once per level of nesting with no limit, and deep enough nesting overflows the goroutine stack, which ends the process. CUE source is now measured with CUE's scanner, which does not recurse, before anything parses it, counting chained labels (a: b: c:) and prefix operators as the levels they are, and refused past 1000 levels (shipped definitions nest at most 20), or past 10000 operations chained in one expression. The webhooks that take CUE (component, trait, policy, workflow step and source definitions, and config templates) refuse an object with any string nested that deeply, naming the field. Application admission, and Workflow objects an Application references, check the same way the step conditions and inputs and outputs the controller compiles. The template upgrade every render runs first replaces a stored template nested that deeply with one that fails with the reason, and addon CUE (templates, parameters, notes and module imports) is checked before it is parsed. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(query): never return a Secret's data from collectResources collectResources returned each matching object whole, so a query for kind Secret, including Secrets the resource tree reaches through Flux HelmReleases and Kustomizations, returned their data. It now reports a Secret by name and metadata only, never its data, stringData or the last-applied annotation that repeats them, in both copies of the query provider. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(sources): key vela-config by the Application's namespace vela-config's cache key, and the namespace its reads are checked against, was context.namespace. For a component a topology policy places in another namespace that is the placement namespace, so two Applications of one name from different namespaces placed in the same one shared an entry, and a read was checked for the wrong namespace. appNamespace joins the cache key rules (edited in place, as 1.12 has not shipped; every stamped definition is restamped), vela-config keys and checks by context.appNamespace, and the source resolver records the Application's namespace as the consumer. Source definition tests get appNamespace in their context. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(daemon): carry an exposed port's protocol to its Service The daemon component exposed its ports through a Service whose ports named no protocol, so Kubernetes took them as TCP: an exposed UDP port, such as syslog on 514, was unreachable through the Service. Each Service port now carries its container port's protocol, as the webservice component's do. A TCP port's Service is unchanged, as TCP is what the API server set before. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(application): reconcile a frozen Application when it is released vela workflow rollback freezes the Application by setting its controller requirement, restores an earlier spec and status, and releases it by restoring the requirement. A reconcile cut short by the freeze can leave the phase at rendering, and the update filter drops every update whose new phase is rendering unless the generation changed. The release only changes an annotation, so its event was dropped and the Application sat in rendering until the next resync (5m by default), which is what the multicluster rollback e2e spec times out on. A change to the controller requirement now always passes the filter. The filter is a named function so the rule can be tested. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(cuex): send vela/http request headers as the template declares them vela/http's template declares request headers and trailers as one string per name, but guardedhttp decoded them into the upstream RequestVars, which takes http.Header, a list per name. CUE refuses a list and the decoder refuses a string, so a component, trait, policy or source template could set no request header at all: the call failed with "cannot unmarshal string into Go struct field DoParams.$params.request.header.X-Token of type []string". Bump kubevela/pkg to ff99f28 (kubevela/pkg#157), which reads request headers and trailers as one string per name and exports NewRequest. guardedhttp drops its own request types and builds the request with NewRequest, keeping only its own client and response read. Headers are now added with Header.Add, so names that differ only in case (X-Tag, x-tag) each reach the request. Signed-off-by: Brian Kane <briankane1@gmail.com> --------- Signed-off-by: Brian Kane <briankane1@gmail.com>
briankane
added a commit
to kubevela/kubevela
that referenced
this pull request
Nov 20, 2026
) * Chore(deps): bump kubevela/workflow and kubevela/pkg for the release-testing fixes github.com/kubevela/workflow at 435c6fb59a23bd9f3f2cded0056520d9493ef24a, where its fixes merged. github.com/kubevela/pkg at 000437b6ca9351aa6afccf52fe87fa11ebd04a0f, where its fixes merged. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(utils): replace an object's lists exactly in CreateOrUpdate CreateOrUpdate unmarshalled the desired object over the live one. JSON decoding reuses existing slice elements, so a field the desired element omits kept the value of the element that held its slot before: removing a subject from a RoleBinding could leave the next subject with the removed one's fields. The unmarshal error was also checked against the wrong variable and dropped. The live object is now reset before the desired one is written over it, keeping the metadata the API server owns, and the error is returned. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(http): bound builtin and definition HTTP requests like workflow's The builtin HTTP command ran on a background context and read its whole response; vela/http in component, trait and policy definitions had no timeout at all; and the request, notification and webhook steps accepted a timeout of "0", which reached the provider as none. The builtin command now refuses a timeout that is invalid, zero, negative or over the maximum instead of silently using 3s, keeps an unset one to 3s or the maximum when that is lower, runs on its context, and refuses an oversized body. vela/http, which has no timeout parameter, times out at the maximum and refuses an oversized body. --max-workflow-http-timeout and --max-workflow-http-response-bytes set the bounds, exposed in the chart as workflow.http.maxTimeout and workflow.http.maxResponseBytes, and the controller refuses to start with either at zero or below. The three steps' timeout must be a duration with a unit, and webhook sets it inline so an invalid one fails the step. Needs kubevela/workflow with httpguard.RequestTimeout and ReadResponseBody. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): let a stored problem through an update that leaves the spec as it is The Application webhook validated every update in full, so an Application admitted before a rule existed (two traits 1.12 refuses together, say) refused every later update: a label, a publishVersion bump, an identical GitOps apply. A WorkflowStepDefinition admitted before its template had to compile did the same. When an update leaves the spec unchanged and fails, the stored object is validated too, and the errors it already has are returned as warnings instead of refusing the update. Errors are compared by path, type and detail. The checks on who is asking (annotations, definition permissions), immutable fields, a definition's revision annotation and every spec change are still enforced in full. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(definition): keep pinned and unchanged definition revisions A DefinitionRevision's hash covers the definition spec's Go struct, so a release that adds a field to a definition type changes every definition's hash with its content unchanged. A hash mismatch minted a new revision without comparing content, so upgrading cut a revision for every definition, and the garbage collector then deleted the oldest beyond the limit without checking whether an Application pins one with type@vN, so pinned Applications stopped rendering. The last revision's content is now compared whatever the hashes say. A revision an Application pins, in a component, trait, policy, workflow step or source, is kept and not counted against the limit. A new informer index, DefinitionPinIndex, maps Applications by the revisions they pin; a sharded controller reads them from the API server, as its cache holds only its own shard. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(definition): number a re-created definition's revisions from where it left off A definition's revisions go with it when it is deleted, so one created again under the same name started at v1, and an Application pinned to type@v1 rendered the new content. Where an orphaning delete left the old revisions, the new v1 collided with them and the definition's status named a revision holding the old content. A GitOps replace, which deletes and re-creates a definition unchanged, broke every pin on it. The next number is now one past the highest the name has had, kept in the definition's status, a definition-revision-numbers ConfigMap in its namespace, and the revisions still in the cluster. The record also keeps the hash of each of the newest 20 numbers, so a definition re-created with content it had takes that content's number back. Content it never had takes a new number, and a pin on a number it no longer has fails as not found instead of binding to other content. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(workflow): stop completed side-effect steps running again A workflow step's record is written to the Application's status after the step runs, and two things lost it, so completed webhook and notification steps ran again: - A reconcile could start from a cached Application older than its own last status write, missing the steps that write recorded; a stale copy from before a publishVersion restart restarted the run a second time. - The status write carries the resourceVersion, so any concurrent write to the Application (a GitOps sync, kubectl annotate) failed it with a conflict and the record was dropped. A reconcile now reads the Application from the API server when the cache has not caught up with the copy the last reconcile finished with. A status write that conflicts with a write to the Application's metadata or spec is reapplied to the live Application, up to three attempts; one whose status another writer changed, such as a workflow resume, is dropped and requeued as before, so that change is kept. A failed write no longer resets the step guard. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(query): list a resource's owned children in its namespace A child kind the tree finds by owner reference, such as a Service's EndpointSlices, was listed across the whole cluster and filtered by owner. A reader confined to namespaces, as VelaUX's project group is, cannot list cluster wide, and the forbidden list failed the parent, so the resource tree dropped every Service. A namespaced parent's children are listed in its namespace, where owner references keep them, and a child kind the reader may not list is left out instead of failing the parent. Both copies of the tree change. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(config): keep config steps and the vela-config source to the Application's namespace read-config, list-config, create-config and delete-config, and the vela-config source, took the config's namespace from the step or the binding and acted with the controller's identity in any namespace. A config outside the Application's namespace is now reached only to read a shared system config (one made in vela-system from a system-scoped template, as platform configs are) or, with the AuthenticateApplication gate on, where the Application's user may do the same. The rule is config.AccessToConfig, shared by the steps and the source. The source resolver records the consuming Application's namespace in the Go context, where no definition can set it, and vela-config's cached values are kept per namespace. The controller and the Application webhook record it too, so a component or trait that calls vela/velaconfig directly keeps to the same rule. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): enforce definition restrictions and quotas on indirect uses The restriction and quota checks read only the types an Application names inline, so a definition was not checked when it came in through an override policy's component type or trait, a step of the Workflow spec.workflow.ref names, or a module type, and a trait's conflictsWith inherited through extends was ignored. Each of these is now checked, reported at the field that brings the definition in; a trait's conflicts include those it inherits. Uses through override policies count against quotas (DefinitionUsageOf lists them) and share one budget with inline uses. Admission lets an unchanged spec through, so the controller now runs the same restriction check while it reconciles and records a RestrictionViolation condition naming each use, with a Warning event when that changes; it never fails the render. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): check definition permissions on referenced Workflows and Policies With definition permission validation on, the webhook checked only the definitions an Application names inline, not those it reaches through spec.workflow.ref, a deploy step's Policy objects or override policies, and nothing checked Workflow and Policy objects when they were written. The definitions an Application reaches are found once, by indirectReach, which now also reads the Policy objects deploy steps load. The permission check runs on each as if it were named inline, at the field that brings it in, and refuses a reference to a Workflow or Policy the requester cannot read. A validating webhook on core.oam.dev/v1alpha1 Workflows and Policies checks, on create and update, the definitions each names against the requester's permissions and the namespace restrictions, under the same feature gates. The paths are registered in Go, the chart and the debug script. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): judge the controller's writes by the Application that dispatched them The webhook accepted any write made with vela-core's own identity, which shows only that an object came through dispatch, not for which Application. That covered modules.oam.dev/install-namespace on a nested Application, and Workflow and Policy objects a component dispatches. What the controller writes is now judged for the Application that dispatched it, from the labels it stamps on everything it dispatches: install-namespace is accepted only when modules would install into that Application's namespace (where the addon renderer records it), and a Workflow or Policy object is checked against that Application's namespace restrictions, and its definition permissions as its author where that identity is trusted (AuthenticateApplication with the username stamped). Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): an addon component needs an author who may install addons An addon component makes the controller install the addon: its Application in vela-system and every resource it holds, cluster-scoped ones included. The feature gate was the only check. The Application webhook now refuses an addon component unless its author may create Applications in vela-system, which is what installing an addon takes. One the controller writes is judged for the Application that dispatched it: an addon's own Application in vela-system may still install the addons it depends on, and one dispatched from elsewhere is checked as that Application's author where the identity is trusted. The chart also restricts the addon definition to vela-system by default (definitionRestrictions.overrides.addon). Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(workflow): read a shared Workflow as the Application's author spec.workflow.ref falls back to a Workflow of that name in vela-system, so platform teams can share one across namespaces. The controller read it with its own identity, from its cache, whether or not the Application's author could. With AuthenticateApplication on, the parser asks, as the Application's author, whether they may get the Workflow the ref resolved to, once per parse, and fails the render naming the Workflow and the user when they may not. The admission check under ValidateDefinitionPermissions resolves the ref the same way. The Application reports the Workflow it ran in status.workflow.ref, and the ref field documents the lookup and the permission it needs. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(resource): set only the cpu or memory given, and test shipped definitions' renders With only cpu or only memory set, the resource trait applied both, defaulting the other to 1 cpu or 2048Mi, so an Application that set only cpu gained a 2Gi memory limit on its first edit after upgrading. Either one alone now sets just itself, in requests and limits, as a patch of its own: CUE carries a field's patch-strategy comment from every branch that declares it, taken or not. Changes like this reached users unnoticed, since each definition test asserts only the fields it names. Every successful render case of a shipped definition now has a golden file of what reaches the cluster, compared by make test-definitions and rewritten with make update-definition-goldens. TestShippedPatchStrategiesAgree fails a field declared with different patch strategies in different branches. hack/definition-render-diff.sh lists, and with -v shows, how each shipped definition renders differently from an earlier release's. Signed-off-by: Brian Kane <briankane1@gmail.com> * Feat(hack): downgrade vela-core from 1.12 to 1.11 helm rollback from 1.12 fails, and a helm upgrade to the 1.11 chart leaves a half-downgraded install: since 1.12 a hook Job applies the builtin definitions outside the release, so the 1.11 release finds definitions it no longer owns. hack/downgrade-from-1.12.sh puts the 1.11 builtins back under Helm's field manager with Helm's ownership metadata, upgrades to the 1.11 chart with the release's values and the 1.11 controller image, removes the admission webhooks only 1.12 serves (config Secrets included, which would otherwise refuse every config Secret update), and verifies all three. The 1.11 chart is applied client side, as it was written for. A run that failed part-way can be run again. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(config): adopt legacy configs before writing, and guard adopted Secrets vela config create on the name of a legacy config wrote a Config beside the legacy Secret and reported success; the Config went to Error and consumers kept reading the old value. After migration, a 1.11 CLI or VelaUX 1.9.5 edit rewrote the adopted Secret without its migration mark, splitting the config silently. UpsertConfigCR now adopts a legacy config of the name before writing, and refuses, writing nothing, one that cannot be adopted, with the reason. A validating webhook on config Secrets (selected by the velacore-config catalog label, updates only) refuses an update that removes the migration mark, or the catalog label the webhook selects on, naming the Config and the clients that can edit it. It fails closed like the Config webhook beside it. Signed-off-by: Brian Kane <briankane1@gmail.com> * Feat(config): take a template's CR for its ConfigMap when one Application controls both A ConfigTemplate stood for a legacy template ConfigMap of its name only when migration had adopted the ConfigMap into it. An addon that now installs its template as a ConfigTemplate leaves both, owned by the addon's Application, so migrating a config on that template reported a conflict and the CLI listed the ConfigMap as shadowed. TemplateStandsFor is the one rule: the ConfigMap's migrated-to names the CR, or one Application controls both. Config and template migration and the CLI's template list use it. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(request): succeed on a reply that is not JSON, and fail on a 400 The request step parsed every reply as JSON, so a successful empty or text reply was an error after the request had been made, and every retry sent the request again. The reply is kept as responseBody and parsed into response only when it is JSON. A status of 400 now fails the step as other client errors do: the check was greater than 400. Signed-off-by: Brian Kane <briankane1@gmail.com> * Docs(requiredcrds): Helm fails an upgrade only for kinds the manifest holds The package comment said helm upgrade fails outright on a missing CRD. Since a hook Job applies the builtin definitions, Helm's own check covers only kinds with an instance in the release manifest; a missing CRD of any other kind passes helm upgrade, and this check is what says why. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): stop validating an Application once its request is cancelled The Application webhook rendered every component however long that took. A large Application (about 600 components) kept it busy for some 42 seconds, most of it after the API server's 10 second webhook timeout had already failed the request, and concurrent requests stacked. Validation now runs under the request's context, which the API server cancels when it stops waiting: component parsing and the CUE schematic check look at it before each component. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(webhook): explain, and refuse up front, an earlier Application's ResourceTrackers A restore that includes ResourceTrackers creates the Application with a new uid beside trackers naming the old one. The controller refused them on every reconcile with a message that blamed garbage collection and said to delete the tracker, which its finalizer would hold. The webhook now refuses to create an Application while a ResourceTracker of its name and namespace names another uid, and the controller's refusal of an existing one says the same: what leaves such a tracker, and the two remedies, removing its uid label to take it over with its resources, or removing its finalizer and deleting it, leaving them. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helm): refuse a release another Application owns A helmchart component whose release name matched a release owned by another Application, or by another component of the same one, adopted it with a forced upgrade, so the two replaced each other's workload on every reconcile. The provider now reads the existing release's owner labels first: its own release carries on, a plain helm install is still adopted, and a release whose owner Application still exists is refused, naming the owner and release.name. A release whose owner is gone is adopted and its Secrets relabelled. A release Helm cannot read is recovered only when its Secrets' owner labels allow the same. The e2e spec expects the refusal up front. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helm): keep the Application as a release's owner under a topology namespace helmchart passed context.namespace as the Application's namespace, which under a topology policy's namespace is the target namespace, so the release was labelled for an Application that does not exist there: the provider missed the Application, installed without its user, and the resource keeper refused the release Secret. context.appNamespace is the Application's own namespace wherever the component is placed. It is in the context registry, so definitions, parameter schemas and definition tests can read it, and helmchart passes it to the provider. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helmchart): name a release after its component when only its namespace is set With release.namespace and no release.name, helmchart left the name unset: the template failed to render its release ConfigMap, and the provider named the release "release", shared by every such component in the namespace. Name and namespace now default independently, and the provider falls back to the component's name and namespace. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helm): move 1.11's hub-installed releases to where their components are placed 1.11 installed a helmchart component placed on a managed cluster on the hub, and dispatched its objects and copies of the release Secrets to the managed cluster. The first 1.12 install there failed, as Helm refuses objects without its ownership metadata, and the hub copy kept running outside any ResourceTracker. When an install fails that way, the provider marks the live objects that carry this component's labels, and no other release's annotations, with Helm's ownership metadata and removes the component's placeholder release Secrets before one retry; the post-renderer labels chart objects as managed by Helm. When a workflow run succeeds and the ResourceTracker holds a release Secret on a managed cluster, the controller uninstalls, as the Application's user, each hub release whose component is placed only elsewhere. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helm): read chart credentials and values only from the Application's namespace The Helm provider read a chart's auth Secret, and its valuesFrom Secrets and ConfigMaps, from the Application's namespace or the release namespace, which the Application chooses. Both are now read only from the Application's namespace, the default when none is named, and any other is refused, the release namespace included. A render with no Application context reads none. The controller's valuesFrom fingerprint, which rolls a release out when a source changes, resolves sources by the same rule. The valuesFrom e2e specs keep their Application in its release's namespace, so the sources are its own. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(sources): keep sensitive source fields out of the workflow context A workflow run pins every source a step reads in the workflow context, a ConfigMap, so later steps read the same value. The pin held the whole resolved value, +sensitive fields included, and every ApplicationRevision copied it into status.workflowContext. The sensitive fields of a pinned source now go to a Secret the Application owns, workflow-<app>-sources, and the context holds a pointer to each in its place, secret:<name>/pins#<source>.<path>, with the paths listed under sealed. Only those paths are followed back. A pin whose field the Secret no longer has is resolved again. ApplicationRevisions no longer keep a run's pins. A Secret of that name the Application does not control is neither read nor written. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(sources): honour +sensitive marks inside comprehensions A +sensitive mark was read only from fields written directly in a struct or list literal. One inside a list comprehension, the usual way to build a list from parameters in output:, or inside an if block was skipped, so its field was masked neither in status.sources nor in the workflow context. The marker walk now descends into the fields a comprehension adds, for and if alike, nested or not. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(auth): run as the default user when authentication.withUser is off With AuthenticateApplication on and authentication.withUser off, an Application is documented to run as the default user with the requester's groups. The webhook stamped the groups but kept an app.oam.dev/username annotation already on the object, and the controller acted as that user. In that mode the webhook removes the username, and the identity read from an Application ignores one, so those stored before are covered. With withUser on, the requester's username replaces whatever was written, as before; with the gate off, nothing changes. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(definitions): run the vela-cli step's Job where the Application is The vela-cli step's Job ran as vela-core's own service account by default, and that default also placed the Job in vela-system. The Job now always runs in the Application's namespace, as the service account it names there, default unless set. A platform Application in vela-system can still name kubevela-vela-core. The chart restricts vela-cli to vela-system by default (definitionRestrictions.overrides.vela-cli), since the step also takes an image, command, Secret and host path mounts. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(core): always deny loopback, unspecified and local-use NAT64 addresses to outbound requests The outbound HTTP guard denied the deny list and, optionally, private addresses, but not loopback, the unspecified address or the local-use NAT64 prefix. The controller's policy now always denies 127.0.0.0/8 and ::1, 0.0.0.0/8 and ::, and 64:ff9b:1::/48, on top of the deny list and the private-address setting. An address under the well-known NAT64 prefix, 64:ff9b::/96, is checked by the IPv4 address it carries (kubevela/workflow), so DNS64 to an allowed host still works. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(helm): pull OCI charts through the outbound guard Chart sources over HTTP and Helm repositories went through the outbound guard, but oci:// sources used the registry client's own HTTP client. The registry client now dials through the guard and follows only the redirects it allows. A pull times out after five minutes, and a cancelled render stops waiting for it. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(terraform): read remote modules from Git objects, with the definition's own key A remote Terraform ComponentDefinition is cloned so its variables can be read into its schema. The clone was checked out before its size was checked, the SSH key Secret could be named in any namespace, and the Secret's known hosts went to one file every clone shared through an environment variable. The module is now cloned bare and only variables.tf or main.tf is read, from Git's objects, refused before reading when it is a symlink, not a file, over the size cap, or outside the module. A cache that is not a Git repository is cloned afresh. The SSH key Secret is read from the definition's namespace, and the key checks the remote against that Secret's known hosts alone. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(chart): render the configured failure policy in cert-manager mode The chart rendered every webhook failurePolicy: Ignore whenever admissionWebhooks.patch.enabled was on. That suits the default mode, where vela-core manages the serving cert and sets the configured policy once it serves, but with cert-manager nothing ever set it, so the webhooks stayed Ignore. Ignore is now rendered only when vela-core manages the cert. With cert-manager or a supplied Secret the configured policy (Fail by default) applies from the start. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(cue): refuse CUE nested too deeply before parsing it CUE's parser recurses once per level of nesting with no limit, and deep enough nesting overflows the goroutine stack, which ends the process. CUE source is now measured with CUE's scanner, which does not recurse, before anything parses it, counting chained labels (a: b: c:) and prefix operators as the levels they are, and refused past 1000 levels (shipped definitions nest at most 20), or past 10000 operations chained in one expression. The webhooks that take CUE (component, trait, policy, workflow step and source definitions, and config templates) refuse an object with any string nested that deeply, naming the field. Application admission, and Workflow objects an Application references, check the same way the step conditions and inputs and outputs the controller compiles. The template upgrade every render runs first replaces a stored template nested that deeply with one that fails with the reason, and addon CUE (templates, parameters, notes and module imports) is checked before it is parsed. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(query): never return a Secret's data from collectResources collectResources returned each matching object whole, so a query for kind Secret, including Secrets the resource tree reaches through Flux HelmReleases and Kustomizations, returned their data. It now reports a Secret by name and metadata only, never its data, stringData or the last-applied annotation that repeats them, in both copies of the query provider. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(sources): key vela-config by the Application's namespace vela-config's cache key, and the namespace its reads are checked against, was context.namespace. For a component a topology policy places in another namespace that is the placement namespace, so two Applications of one name from different namespaces placed in the same one shared an entry, and a read was checked for the wrong namespace. appNamespace joins the cache key rules (edited in place, as 1.12 has not shipped; every stamped definition is restamped), vela-config keys and checks by context.appNamespace, and the source resolver records the Application's namespace as the consumer. Source definition tests get appNamespace in their context. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(daemon): carry an exposed port's protocol to its Service The daemon component exposed its ports through a Service whose ports named no protocol, so Kubernetes took them as TCP: an exposed UDP port, such as syslog on 514, was unreachable through the Service. Each Service port now carries its container port's protocol, as the webservice component's do. A TCP port's Service is unchanged, as TCP is what the API server set before. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(application): reconcile a frozen Application when it is released vela workflow rollback freezes the Application by setting its controller requirement, restores an earlier spec and status, and releases it by restoring the requirement. A reconcile cut short by the freeze can leave the phase at rendering, and the update filter drops every update whose new phase is rendering unless the generation changed. The release only changes an annotation, so its event was dropped and the Application sat in rendering until the next resync (5m by default), which is what the multicluster rollback e2e spec times out on. A change to the controller requirement now always passes the filter. The filter is a named function so the rule can be tested. Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix(cuex): send vela/http request headers as the template declares them vela/http's template declares request headers and trailers as one string per name, but guardedhttp decoded them into the upstream RequestVars, which takes http.Header, a list per name. CUE refuses a list and the decoder refuses a string, so a component, trait, policy or source template could set no request header at all: the call failed with "cannot unmarshal string into Go struct field DoParams.$params.request.header.X-Token of type []string". Bump kubevela/pkg to ff99f28 (kubevela/pkg#157), which reads request headers and trailers as one string per name and exports NewRequest. guardedhttp drops its own request types and builds the request with NewRequest, keeping only its own client and response read. Headers are now added with Header.Add, so names that differ only in case (X-Tag, x-tag) each reach the request. Signed-off-by: Brian Kane <briankane1@gmail.com> --------- Signed-off-by: Brian Kane <briankane1@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
vela/httpcould not send a request header.http.cuedeclaresrequest.headerandrequest.traileras one string per name, butRequestVarsdecoded them ashttp.Header, a list per name. CUE refuses a list and the decoder refuses a string, so any call setting a header failed:RequestVarsnow takes one string per name, as the template declares, and thehttp.Headeris built withAdd, so names that differ only in case (X-Tag,x-tag) each keep their value. This matches the workflowvela/httpprovider'sparseHeaders.NewRequest(ctx, RequestVars)is exported, so a provider sending the request through its own client builds it the same way. kubevela's guardedvela/http(component, trait, policy and source templates) moves to it on the bump.The same commit is already on the new
release-1.11(v1.11.2) andrelease-1.9(v1.9.3) branches, cut from the commits kubevela 1.11 and 1.10 pin, so those lines take the fix without moving onto main.Fixes kubevela/kubevela#7595
How has this code been tested
TestDoSendsRequestHeadersandTestDoSendsCaseVariantHeadersrender a template through the real compiler against a local HTTP server; the first fails before the change with the error above, the second with only one of the two values arriving.TestNewRequestcovers the exported builder.go test ./cue/...passes (envtest 1.37.0) on main,release-1.11andrelease-1.9; golangci-lint clean. kubevela master, release-1.12, 1.11 and 1.10 build and pass./pkg/cue/...against it.Behaviour changes in this PR
API change for importers:
RequestVars.Request.Headerand.Trailerare nowmap[string]string, nothttp.Header. Neither form could be set from CUE before, so no template changes. A Go caller buildingRequestVarsby hand passes one string per name, or callsNewRequestinstead of settingreq.Headeritself.Summary by cubic
Fixes
vela/httpso request headers and trailers can be sent. The CUE template declares one string per header name, butRequestVarsdecoded them ashttp.Header, a list per name, so any template setting a header failed with an unmarshal error and no header arrived.RequestVarsnow matches the template (map[string]string), thehttp.Headeris built withAddso names differing only in case each keep their value, andNewRequestis exported so providers sending through their own client build the request the same way.NewRequestkeeps the header map usable when a template sets no headers, so a caller adding a header to the result no longer panics. For Go importers,RequestVars.Request.Headerand.Trailerare nowmap[string]string; pass one string per name or useNewRequestinstead of settingreq.Headerdirectly. The fix is also cut ontorelease-1.11(v1.11.2) andrelease-1.9(v1.9.3).Fixes kubevela/kubevela#7595
Written for commit b2d0e29. Summary will update on new commits.