-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Devfile Parser should not set default values when flattening is true
#1067
Comments
…ening See [1] for more context [1] devfile/api#1067 Signed-off-by: Armel Soro <asoro@redhat.com>
Just to clarify, my comment about this scenario potentially being a bug applied to the unflattening scenario. The intentions were to always preserve backward compatibility wherever possible in our apis and library so if we do not set default values at all, we will be forcing clients set them: #545 (comment). What you're proposing is a behavioural change and will impact other clients and will require further discussion |
Thanks for clarifying, @kim-tsao! Indeed, if we agree this is a bug applied to the unflattering scenario, then it would make sense to set default values in all cases. |
@rm3l , I'll have to do some more investigation to make sure our parent override scenarios do not break. In addition, we discussed this in today's team call and agreed that if we do make a breaking change that it might be best to do so now when we don't have many clients adopting the 2.2 updates. Impacts to pre-2.2 boolean properties were minimal too, since |
I'll also look into your suggestion to allow clients to skip setting default values as a way to avoid breaking changes |
Thanks, Kim! |
@rm3l, I have a PR ready. Please verify if this is the behaviour you're looking for, thanks! |
@kim-tsao I can confirm the changes in devfile/library#169 work fine for us, by using the new |
This includes the fix for [1], which provides a way not to set default values automatically [1] devfile/api#1067
This includes the fix for [1], which provides a way not to set default values automatically [1] devfile/api#1067
…nShift components (#6654) * Add sample Devfile with multiple autoBuild/deployByDefault combinations It will be used for integration tests. * Add helper function to update a given Devfile Command Group This will allow supporting cases where we need to run a custom command, but this is not implemented yet on odo (cases with 'odo dev --debug' and 'odo deploy'). In this case, this helper will allow updating the Devfile for example to unmark the current default command as non-default, and mark the custom one as default. * Add test cases for 'odo dev' * Add test cases for 'odo deploy' * Add test cases for 'odo build-images' 'odo build-images' should build all images regardless of the 'autoBuild' property. * Display the spinner when creating or updating Kubernetes resources This helps understand what resources are being patched. * Handle deployByDefault on K8s and OpenShift components * Add 'devfile.GetImageComponentsToPush' functions that returns the list of image components to auto-create See devfile/api#852 (comment) for more context. * Handle automatic image component creation for 'odo dev' on Kubernetes * Handle automatic image component creation for 'odo dev' on Podman * Handle automatic image and K8s/OpenShift component creation for 'odo deploy' * Bump Devfile library to the latest commit at this time (c1b23d2) This includes the fix for [1], which provides a way not to set default values automatically [1] devfile/api#1067 * Do not set default values when parsing a Devfile See [1] for the rationale [1] https://github.com/redhat-developer/odo/issues/5694\#issuecomment-1465778398 * Add documentation in the Devfile reference page * Revert "Display the spinner when creating or updating Kubernetes resources" This reverts commit 6ad073e63cb0e685f165eed767619a90997393a3. * Avoid re-applying Image components multiple times 'adapter#Push' might get called several times when there are state transitions (either on the Deployment in the cluster, or from 'odo'). It might be confusing to apply Image components over and over again (and also it can be slower if we need to push images to remote registries). * Move GetK8sAndOcComponentsToPush and GetImageComponentsToPush to libdevfile package As suggested in review, this should be the responsibility of the devfile library Co-authored-by: Philippe Martin <phmartin@redhat.com> * fixup! Handle automatic image and K8s/OpenShift component creation for 'odo deploy' * fixup! Handle automatic image component creation for 'odo dev' on Podman * fixup! Avoid re-applying Image components multiple times * Apply suggestions from code review Co-authored-by: Parthvi Vala <pvala@redhat.com> * fixup! Do not set default values when parsing a Devfile * Fix devfile-deploy-functional-pods.yaml (used in 'odo logs' tests) Set deployByDefault to false on innerloop-pod component. Otherwise, since it is not referenced by any apply command, it will be automatically created by *both* 'odo dev' and 'odo deploy'. --------- Co-authored-by: Philippe Martin <phmartin@redhat.com> Co-authored-by: Parthvi Vala <pvala@redhat.com>
Which area this feature is related to?
/kind bug
Which area this bug is related to?
/area library
What versions of software are you using?
Go project
Operating System and version:
Fedora 37
Go Pkg Version:
github.com/devfile/library/v2@f87c6926afe80be8abb9fbb83ebfa751f6f93430
Bug Summary
Describe the bug:
While working on adding support for
autoBuild
anddeployByDefault
inodo
(redhat-developer/odo#5694), I needed to handle the case where those fields are not explicitly set in the Devfile and the components are not referenced by anyapply
commands (see #852 (comment)).But currently, the parser automatically sets unset fields to their default values (
false
here) when called with the option to flatten the Devfile:https://github.com/devfile/library/blob/bd4a12f272573de1ab254f3e138a9b55904af620/pkg/devfile/parser/parse.go#L147-L153
On the other hand, parsing without flattening makes our tests using child and parent Devfiles fail (mainly because the child Devfile was missing other definitions like commands or components - see the logs here).
To Reproduce:
See this sample project that highlights the issue: https://github.com/rm3l/bug-devfile-parser-fields-not-set
Expected behavior
As discussed during the community call (on March 20, 2023), flattening should not dictate whether default values should be set or not. It should be up to the clients of the library to decide how to handle unset fields. This is especially necessary since fields like
autoBuild
anddeployByDefault
have 3 states (true
,false
, andnil
) with different behaviors that need to be implemented client-side.Any logs, error output, screenshots etc? Provide the devfile that sees this bug, if applicable
https://github.com/rm3l/bug-devfile-parser-fields-not-set/actions
Additional context
—
Any workaround?
—
Suggestion on how to fix the bug
—
The text was updated successfully, but these errors were encountered: