kpt icon indicating copy to clipboard operation
kpt copied to clipboard

kpt pkg update --strategy force-delete-replace

Open RafalMaleska opened this issue 3 years ago • 2 comments

Expected behavior

when using kpt pkg update --strategy force-delete-replace and having changes in the Kptfile in the upstream repository. Kpt should replace the local Kptfile with the changed version from upstream.

Actual behavior

Kpt throws:

Updating package "prd" with strategy "force-delete-replace".



panic: runtime error: invalid memory address or nil pointer dereference

[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x537c0a8]



goroutine 1 [running]:

github.com/GoogleContainerTools/kpt/internal/util/update.Command.mergePackage({0xc0001c4460, {0x7ff7bfeffb09, 0x6}, {0x7ff7bfeffb1b, 0x14}, 0xc001873ce0}, {0x5bc4410?, 0xc0011e1ef0?}, {0xc000aac0c0, 0x5f}, ...)

    github.com/GoogleContainerTools/kpt/internal/util/update/update.go:461 +0x4c8

github.com/GoogleContainerTools/kpt/internal/util/update.Command.updatePackage({0xc0001c4460, {0x7ff7bfeffb09, 0x6}, {0x7ff7bfeffb1b, 0x14}, 0xc001873ce0}, {0x5bc4410, 0xc0011e1ef0}, {0xc000a91dc0, 0x20}, ...)

    github.com/GoogleContainerTools/kpt/internal/util/update/update.go:403 +0x935

github.com/GoogleContainerTools/kpt/internal/util/update.Command.updateRootPackage({0xc0001c4460, {0x7ff7bfeffb09, 0x6}, {0x7ff7bfeffb1b, 0x14}, 0xc001873ce0}, {0x5bc4410, 0xc0011e1ef0?}, 0xc0001c4460)

    github.com/GoogleContainerTools/kpt/internal/util/update/update.go:301 +0xe28

github.com/GoogleContainerTools/kpt/internal/util/update.(*Command).Run(0xc001ff2c80, {0x5bc4410, 0xc0011e1ef0?})

    github.com/GoogleContainerTools/kpt/internal/util/update/update.go:154 +0x61a

github.com/GoogleContainerTools/kpt/internal/cmdupdate.(*Runner).runE(0xc001ff2c60, 0xc0022f9ca8?, {0xc0022f9c80?, 0x0?, 0x0?})

    github.com/GoogleContainerTools/kpt/internal/cmdupdate/cmdupdate.go:128 +0x30

github.com/spf13/cobra.(*Command).execute(0xc000407b80, {0xc00234c040, 0x4, 0x4})

    github.com/spf13/[email protected]/command.go:856 +0x67c

github.com/spf13/cobra.(*Command).ExecuteC(0xc000406000)

    github.com/spf13/[email protected]/command.go:974 +0x3b4

github.com/spf13/cobra.(*Command).Execute(...)

    github.com/spf13/[email protected]/command.go:902

k8s.io/component-base/cli.run(0xc000406000)

    k8s.io/[email protected]/cli/run.go:146 +0x305

k8s.io/component-base/cli.RunNoErrOutput(...)

    k8s.io/[email protected]/cli/run.go:84

main.runMain()

    github.com/GoogleContainerTools/kpt/main.go:68 +0xb0

main.main()

    github.com/GoogleContainerTools/kpt/main.go:45 +0x19

make: *** [update] Error 2

Information

kpt version: 1.0.0-beta.17

Steps to reproduce the behavior

  • create an upstream repository wit a Kptfile like:
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
  name: egress-gateway-internet
info:
  site: https://wiki.company.com/
  emails:
    - [email protected]
  license: MPL-2.0
  licenseFile: LICENSE
  description: Egress Gateway Package
  keywords:
    - istio
    - gateway
  man: https://wiki.company.com/
  • kpt pkg get >>upstream-repository-git-url-ref<<

  • change upstream Kptfile. For example change e-mail or man:

apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
  name: egress-gateway-internet
info:
  site: https://changes.company.com/
  emails:
    - [email protected]
  license: MPL-2.0
  licenseFile: LICENSE
  description: Egress Gateway Package
  keywords:
    - istio
    - gateway
  man: https://changes.company.com/
  • run locally kpt pkg update --strategy force-delete-replace
  • kpt throws:
Updating package "prd" with strategy "force-delete-replace".



panic: runtime error: invalid memory address or nil pointer dereference

[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x537c0a8]



goroutine 1 [running]:

github.com/GoogleContainerTools/kpt/internal/util/update.Command.mergePackage({0xc0001c4460, {0x7ff7bfeffb09, 0x6}, {0x7ff7bfeffb1b, 0x14}, 0xc001873ce0}, {0x5bc4410?, 0xc0011e1ef0?}, {0xc000aac0c0, 0x5f}, ...)

    github.com/GoogleContainerTools/kpt/internal/util/update/update.go:461 +0x4c8

github.com/GoogleContainerTools/kpt/internal/util/update.Command.updatePackage({0xc0001c4460, {0x7ff7bfeffb09, 0x6}, {0x7ff7bfeffb1b, 0x14}, 0xc001873ce0}, {0x5bc4410, 0xc0011e1ef0}, {0xc000a91dc0, 0x20}, ...)

    github.com/GoogleContainerTools/kpt/internal/util/update/update.go:403 +0x935

github.com/GoogleContainerTools/kpt/internal/util/update.Command.updateRootPackage({0xc0001c4460, {0x7ff7bfeffb09, 0x6}, {0x7ff7bfeffb1b, 0x14}, 0xc001873ce0}, {0x5bc4410, 0xc0011e1ef0?}, 0xc0001c4460)

    github.com/GoogleContainerTools/kpt/internal/util/update/update.go:301 +0xe28

github.com/GoogleContainerTools/kpt/internal/util/update.(*Command).Run(0xc001ff2c80, {0x5bc4410, 0xc0011e1ef0?})

    github.com/GoogleContainerTools/kpt/internal/util/update/update.go:154 +0x61a

github.com/GoogleContainerTools/kpt/internal/cmdupdate.(*Runner).runE(0xc001ff2c60, 0xc0022f9ca8?, {0xc0022f9c80?, 0x0?, 0x0?})

    github.com/GoogleContainerTools/kpt/internal/cmdupdate/cmdupdate.go:128 +0x30

github.com/spf13/cobra.(*Command).execute(0xc000407b80, {0xc00234c040, 0x4, 0x4})

    github.com/spf13/[email protected]/command.go:856 +0x67c

github.com/spf13/cobra.(*Command).ExecuteC(0xc000406000)

    github.com/spf13/[email protected]/command.go:974 +0x3b4

github.com/spf13/cobra.(*Command).Execute(...)

    github.com/spf13/[email protected]/command.go:902

k8s.io/component-base/cli.run(0xc000406000)

    k8s.io/[email protected]/cli/run.go:146 +0x305

k8s.io/component-base/cli.RunNoErrOutput(...)

    k8s.io/[email protected]/cli/run.go:84

main.runMain()

    github.com/GoogleContainerTools/kpt/main.go:68 +0xb0

main.main()

    github.com/GoogleContainerTools/kpt/main.go:45 +0x19

make: *** [update] Error 2

A workaround is removing the upstream lock from the local Kptfile and running kpt pkg update --strategy force-delete-replace. I'm suspecting that this issue is caused by Kpt having troubles updating Kptfiles with the strategy force-delete-replace when remote Kptfile have been changes. Is this a bug?

RafalMaleska avatar Jun 20 '22 10:06 RafalMaleska

also experienced that behaviour. would very much welcome a solution.

jonasknappitsch avatar Jun 20 '22 11:06 jonasknappitsch

Thanks for reporting it. We will take a look at it shortly.

droot avatar Jun 21 '22 20:06 droot