You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Patching trait fails to produce the correct output. This is under the very specific scenario of a trait definition using a parameter with a default value rather than one being specified in the trait usage in the application, using this as the value of a // +patchKey= field, AND the trait definition accessing the parameter with e.g. parameter.volumeName rather than "\(parameter.volumeName)"
To Reproduce
Steps to reproduce the behavior:
Starting in some clean working directory, copy a kubeconfig file for a working cluster and store as ./.kube/config (e.g. in WSL, copy ~/.kube/docker.config)
create a subdir ./kubevela
Extract v1.9.9 webservice.cue from cluster/github repo to ./kubevela/webservice.cue
Create a new trait ./kubevela/my-trait.cue with the following content:
"my-trait": {
type: "trait"
}
template: {
patch: spec: template: spec: {
// +patchKey=namevolumes: [{
//name: "\(parameter.volumeName)" // works whether or not default value takenname: parameter.volumeName// incorrect if default value takenhostPath: path: parameter.hostMountPath
},]
}
parameter: {
// +usage=mount path on host (default /var/run/datadog)hostMountPath: *"/etc/mydata"|string// +usage=name of host mount volume (default datadog)volumeName: *"my-default-vol"|string
}
}
Create ./repro/app.yml with the following content:
ie each volume should be a separate list item, and should have the correct name: applied.
Note that correct output can be produced either by
Change the trait definition to access the parameter.volumeName using the syntax name: "\(parameter.volumeName)" - this line is available commented out in the my-trait.cue given above.
If the explicit volumeName property is passed to the trait in the app.yml, the correct output is also produced - these lines are available commented out in the app.yml given above.
and it still works if both the above changes are made. It's only use of a default value AND using the syntax name: parameter.volumeName that causes the problem.
KubeVela Version
The lowest oamdev/vela-cli image version this works with is v1.6.2, before that the dry-run fails. Up to v1.9.11 the same output problem occurs.
Cluster information
Not particularly relevant as doing dry-run --offline, but I'm using docker k8s currently v1.29.2
Additional context
Note that if the volumeMount is not added in the component, all works fine in any of the cases of defaulting parameter value or not, and whatever syntax is used in the trait definition. - it's only when combining the described conditions with multiple items in a patched list that things start to go wrong.
This issue took several days to track down!
The text was updated successfully, but these errors were encountered:
Describe the bug
Patching trait fails to produce the correct output. This is under the very specific scenario of a trait definition using a parameter with a default value rather than one being specified in the trait usage in the application, using this as the value of a
// +patchKey=
field, AND the trait definition accessing the parameter with e.g.parameter.volumeName
rather than"\(parameter.volumeName)"
To Reproduce
Steps to reproduce the behavior:
./.kube/config
(e.g. in WSL, copy~/.kube/docker.config
)./kubevela
./kubevela/webservice.cue
./kubevela/my-trait.cue
with the following content:./repro/app.yml
with the following content:./doit.sh
with the following content:chmod 755 doit.sh
./doit.sh
to produce dryrun manifest.Expected behavior
The volumes section of the above manifest should read:
ie each volume should be a separate list item, and should have the correct
name:
applied.Note that correct output can be produced either by
Change the trait definition to access the
parameter.volumeName
using the syntaxname: "\(parameter.volumeName)"
- this line is available commented out in themy-trait.cue
given above.If the explicit
volumeName
property is passed to the trait in the app.yml, the correct output is also produced - these lines are available commented out in theapp.yml
given above.and it still works if both the above changes are made. It's only use of a default value AND using the syntax
name: parameter.volumeName
that causes the problem.KubeVela Version
The lowest oamdev/vela-cli image version this works with is v1.6.2, before that the dry-run fails. Up to v1.9.11 the same output problem occurs.
Cluster information
Not particularly relevant as doing
dry-run --offline
, but I'm using docker k8s currently v1.29.2Additional context
Note that if the volumeMount is not added in the component, all works fine in any of the cases of defaulting parameter value or not, and whatever syntax is used in the trait definition. - it's only when combining the described conditions with multiple items in a patched list that things start to go wrong.
This issue took several days to track down!
The text was updated successfully, but these errors were encountered: