Open mantis-toboggan-md opened 11 months ago
There appears to be quite a few issues with the "Edit as YAML" button for the Pod form. Most of these problems have to deal with design intricacies of incorporating a Workload (Pod) into a form primarily designed for Workload Resources (Deployments, ReplicaSet, StatefulSets, etc.) ^1.
Clicking "Edit as YAML" generates an invalid pod spec while both creating and editing a pod. This issue seems to trace back to the form's inception ^2. As mentioned in the issue description, the root cause lies in the form's expectation of data shaped as spec.template.spec
instead of spec
, but I don't think the change to resolve this will be as simple as modifying the workload mixin.
To address this problem in the form, we currently mutate the shape of spec
just before saving, allowing the pod to save properly ^3.
I'm considering several approaches to tackle this issue:
Mutate value
in shell/edit/workload/index.vue
willSaveWorkload
hook located under shell/edit/workload/mixins/workload.js
value
will break existing form fieldsExpose a Slot in CruResource for the YAML Editor
value
directly to the yaml editorI'm not sold on either approach at the moment and I think this problem requires more thought and design before moving forward to fix it. I'll continue to investigate and will follow up with more details as I learn more.
To reproduce:
Result: The pod now has
spec.template.spec.containers
defined instead ofspec.containers
and creation fails.Additional Context
spec.template.spec.containers
would be correct for a workload. There appear to be some shenanigans going on behind-the-scenes with pod creation/editing in order to use the same form as workloads. https://github.com/rancher/dashboard/blob/master/shell/edit/workload/mixins/workload.js#L181-L202