Skip to content
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

Library panics when child devfile overrides parent with list attribute #1268

Open
rm3l opened this issue Sep 27, 2023 · 8 comments
Open

Library panics when child devfile overrides parent with list attribute #1268

rm3l opened this issue Sep 27, 2023 · 8 comments
Labels
area/api Enhancement or issue related to the api/devfile specification area/library Common devfile library for interacting with devfiles kind/bug Something isn't working lifecycle/frozen Frozen items. These items will never go stale or rotten after being tagged as frozen.

Comments

@rm3l
Copy link
Member

rm3l commented Sep 27, 2023

Which area this feature is related to?

/kind bug

Which area this bug is related to?

/area api
/area library

What versions of software are you using?

Bug Summary

Issue originally reported in redhat-developer/odo#7099

To Reproduce:

See repro repo here: https://github.com/AgentK9/devfile-override-bug
They tried to run odo dev on their Devfile, but had this panic. I also reproduced the same issue with the latest version of the library.
I thought it was related to pod-overrides attributes, but in fact, the same error happens with any other attribute name, as long as it is a list.

In a nutshell:

  • child devfile:
schemaVersion: 2.2.0
metadata:
  name: base
  version: 1.0.0
parent:
  uri: ./base.devfile.yaml
  components:
    - name: runtime
      container:
        image: python:3.11  # arbitrary
      attributes:
        pod-overrides:
          spec:
            imagePullSecrets:
              - name: abcd
  • parent devfile:
schemaVersion: 2.2.0
metadata:
  name: base
  version: 1.0.0
components:
  - name: runtime
    container:
      image: python:3.11  # arbitrary
    attributes:
      pod-overrides:
        spec:
          imagePullSecrets:
            - name: regcred

Trying to parse the child devfile results in a panic:

$ ./main /home/asoro/work/tmp/7099-odo-panics-when-overriding-parent-components-attributes-pod-override-spec-imagepullsecrets-name/devfile-override-bug/.devfile.yaml                          
parsing devfile from /home/asoro/work/tmp/7099-odo-panics-when-overriding-parent-components-attributes-pod-override-spec-imagepullsecrets-name/devfile-override-bug/.devfile.yaml              
panic: reflect.StructOf: field 0 has invalid name                                                                                                                                              
                                                                                                                                                                                               
goroutine 1 [running]:                                                                                                                                                                         
reflect.StructOf({0xc00093d050, 0x1, 0x1?})                                                                                                                                                    
        /home/asoro/.asdf/installs/golang/1.19.6/go/src/reflect/type.go:2459 +0x29d4                                                                                                           
github.com/devfile/api/v2/pkg/utils/overriding.(*mapEnabledPatchMetaFromStruct).replaceMapWithSingleKeyStruct(0xc00093d190, {0xc0002ec280, 0xc}, 0x0)                                          
        /home/asoro/go/pkg/mod/github.com/devfile/api/[email protected]/pkg/utils/overriding/overriding.go:161 +0x286                                              
github.com/devfile/api/v2/pkg/utils/overriding.mapEnabledPatchMetaFromStruct.LookupPatchMetadataForStruct({{{0x1ab20d0, 0x17735a0}}}, {0xc0002ec280, 0xc})                                     
        /home/asoro/go/pkg/mod/github.com/devfile/api/[email protected]/pkg/utils/overriding/overriding.go:166 +0x6d                                               
k8s.io/apimachinery/pkg/util/strategicpatch.mergeMap(0xc0003890e0, 0xc0003890e0?, {0x1aa1308, 0xc0002c9c40}, {0x60?, 0x6c?})
        /home/asoro/go/pkg/mod/k8s.io/[email protected]/pkg/util/strategicpatch/patch.go:1355 +0x76f
k8s.io/apimachinery/pkg/util/strategicpatch.mergeMapHandler({0x15ea860?, 0xc0003890e0?}, {0x15ea860?, 0xc000389470?}, {0x1aa1308, 0xc0002c9c40}, {0x0, 0x0}, {0x1, 0x1})
        /home/asoro/go/pkg/mod/k8s.io/[email protected]/pkg/util/strategicpatch/patch.go:1413 +0x8a
k8s.io/apimachinery/pkg/util/strategicpatch.mergeMap(0xc0003890b0, 0x1?, {0x1aa1308, 0xc0002c9990}, {0x4?, 0x0?})
        /home/asoro/go/pkg/mod/k8s.io/[email protected]/pkg/util/strategicpatch/patch.go:1363 +0x8a5
k8s.io/apimachinery/pkg/util/strategicpatch.mergeSliceWithoutSpecialElements({0xc0002c91a0?, 0x1?, 0x40f1ff?}, {0xc0002c99c0?, 0x1, 0x5?}, {0x15cf388, 0x4}, {0x1aa1308, 0xc0002c9990}, ...)
        /home/asoro/go/pkg/mod/k8s.io/[email protected]/pkg/util/strategicpatch/patch.go:1568 +0x1e6
k8s.io/apimachinery/pkg/util/strategicpatch.mergeSlice({0xc0002c91a0, 0x1, 0x1}, {0xc0002c9700?, 0x1, 0x1}, {0x1aa1308, 0xc0002c9990}, {0x15cf388, 0x4}, ...)
        /home/asoro/go/pkg/mod/k8s.io/[email protected]/pkg/util/strategicpatch/patch.go:1471 +0x3e5
k8s.io/apimachinery/pkg/util/strategicpatch.mergeSliceHandler({0x154f760?, 0xc000870f18?}, {0x154f760?, 0xc000870ff0?}, {0x1aa1308, 0xc0002c9990}, {0x15cf372, 0x5}, {0x15cf388, 0x4}, ...)
        /home/asoro/go/pkg/mod/k8s.io/[email protected]/pkg/util/strategicpatch/patch.go:1429 +0xdb
k8s.io/apimachinery/pkg/util/strategicpatch.mergeMap(0xc000389080, 0xc0002c97e0?, {0x1aa1308, 0xc0002c97e0}, {0x48?, 0xdf?})
        /home/asoro/go/pkg/mod/k8s.io/[email protected]/pkg/util/strategicpatch/patch.go:1373 +0x696
k8s.io/apimachinery/pkg/util/strategicpatch.StrategicMergeMapPatchUsingLookupPatchMeta(0x167b200?, 0xc0001a0880?, {0x1aa1308?, 0xc0002c97e0?})
        /home/asoro/go/pkg/mod/k8s.io/[email protected]/pkg/util/strategicpatch/patch.go:880 +0x2b
github.com/devfile/api/v2/pkg/utils/overriding.OverrideDevWorkspaceTemplateSpec(0xc0001a0880, {0x1a93ed0, 0xc000209b90})
        /home/asoro/go/pkg/mod/github.com/devfile/api/[email protected]/pkg/utils/overriding/overriding.go:95 +0x1ff
github.com/devfile/library/v2/pkg/devfile/parser.parseParentAndPlugin({{{0xc00048ca50, 0x5}, {0x7ffeeaa365b1, 0x9c}, {0x7ffeeaa365b1, 0x9c}, {0xc0002127e0, 0x101, 0x120}, {0x18d3260, ...}, ..
.}, ...}, ...)
        /home/asoro/work/projects/devfile/library/pkg/devfile/parser/parse.go:360 +0x79c
github.com/devfile/library/v2/pkg/devfile/parser.parseDevfile({{{0xc00048ca50, 0x5}, {0x7ffeeaa365b1, 0x9c}, {0x7ffeeaa365b1, 0x9c}, {0xc0002127e0, 0x101, 0x120}, {0x18d3260, ...}, ...}, ...}
, ...)
        /home/asoro/work/projects/devfile/library/pkg/devfile/parser/parse.go:70 +0x1c5
github.com/devfile/library/v2/pkg/devfile/parser.populateAndParseDevfile({{{0xc00048ca50, 0x5}, {0x7ffeeaa365b1, 0x9c}, {0x7ffeeaa365b1, 0x9c}, {0xc0002127e0, 0x101, 0x120}, {0x18d3260, ...},
 ...}, ...}, ...)
        /home/asoro/work/projects/devfile/library/pkg/devfile/parser/parse.go:261 +0x188
github.com/devfile/library/v2/pkg/devfile/parser.ParseDevfile({{0x7ffeeaa365b1, 0x9c}, {0x0, 0x0}, {0x0, 0x0, 0x0}, 0x0, 0x0, {0x0, ...}, ...})
        /home/asoro/work/projects/devfile/library/pkg/devfile/parser/parse.go:192 +0x425
github.com/devfile/library/v2/pkg/devfile.ParseDevfileAndValidate({{0x7ffeeaa365b1, 0x9c}, {0x0, 0x0}, {0x0, 0x0, 0x0}, 0x0, 0x0, {0x0, ...}, ...})
        /home/asoro/work/projects/devfile/library/pkg/devfile/parse.go:92 +0xa5
main.parserTest()
        /home/asoro/work/projects/devfile/library/main.go:58 +0x238
main.main()
        /home/asoro/work/projects/devfile/library/main.go:34 +0x52

Expected behavior

Successful parsing with correct attribute overridden.

Any workaround?

@openshift-ci openshift-ci bot added kind/bug Something isn't working area/api Enhancement or issue related to the api/devfile specification area/library Common devfile library for interacting with devfiles labels Sep 27, 2023
@rm3l rm3l changed the title Library panics when child devfile overrides parent list attribute Library panics when child devfile overrides parent with list attribute Sep 27, 2023
Copy link

This issue is stale because it has been open for 90 days with no activity. Remove stale label or comment or this will be closed in 60 days.

@github-actions github-actions bot added the lifecycle/stale Stale items. These items have not been updated for 90 days. label Dec 28, 2023
@kevariste225
Copy link

+1

@github-actions github-actions bot removed the lifecycle/stale Stale items. These items have not been updated for 90 days. label Feb 3, 2024
@Jdubrick Jdubrick moved this to Refinement in Devfile Project Mar 4, 2024
Copy link

This issue is stale because it has been open for 90 days with no activity. Remove stale label or comment or this will be closed in 60 days.

@github-actions github-actions bot added the lifecycle/stale Stale items. These items have not been updated for 90 days. label Sep 22, 2024
@AgentK9
Copy link

AgentK9 commented Sep 22, 2024

ping

@github-actions github-actions bot removed the lifecycle/stale Stale items. These items have not been updated for 90 days. label Sep 23, 2024
Copy link

This issue is stale because it has been open for 90 days with no activity. Remove stale label or comment or this will be closed in 120 days.

@github-actions github-actions bot added the lifecycle/stale Stale items. These items have not been updated for 90 days. label Dec 22, 2024
@AgentK9
Copy link

AgentK9 commented Dec 23, 2024

pong

@michael-valdron
Copy link
Member

michael-valdron commented Dec 23, 2024

/lifecycle frozen

Going to freeze the lifecycle of this issue for reviewing in the new year, due to the effect this bug is having.

@michael-valdron michael-valdron removed the lifecycle/stale Stale items. These items have not been updated for 90 days. label Dec 23, 2024
@michael-valdron
Copy link
Member

/lifecycle frozen

@openshift-ci openshift-ci bot added the lifecycle/frozen Frozen items. These items will never go stale or rotten after being tagged as frozen. label Dec 23, 2024
@michael-valdron michael-valdron moved this from Refinement to Backlog in Devfile Project Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Enhancement or issue related to the api/devfile specification area/library Common devfile library for interacting with devfiles kind/bug Something isn't working lifecycle/frozen Frozen items. These items will never go stale or rotten after being tagged as frozen.
Projects
Status: Backlog
Development

No branches or pull requests

4 participants