konveyor / move2kube-api

HTTP REST API for move2kube
https://move2kube.konveyor.io/
Apache License 2.0
6 stars 18 forks source link

bug: planning and transformation fails when the zip file has no top level folder #147

Closed HarikrishnanBalagopal closed 1 year ago

HarikrishnanBalagopal commented 1 year ago

Bug

Overview

When the sources folder uploaded to the UI is a zip/archive with no top level folder, the planning fails. This happens because we put a .m2kignore file in the folder, so Move2Kube doesn't find any services.

Steps to reproduce

  1. Start the UI.
  2. Create a workspace and project.
  3. Upload the golang-no-parent-folder.zip file as a source input. golang-no-parent-folder.zip
  4. Start planning, no services are detected.
  5. Start transformation, fails and prints error logs in the terminal because it can't find the output folder.

Actual behaviour

INFO[20468] Project: 27ea485f-bd8d-4543-a9e8-2ea7529507a2; level=info msg="Planning finished on the base directory: '/tmp/plan-27ea485f-bd8d-4543-a9e8-2ea7529507a2-3686120573/sources'" 
INFO[20468] Project: 27ea485f-bd8d-4543-a9e8-2ea7529507a2; level=info msg="Planning started on its sub directories" 
INFO[20468] Project: 27ea485f-bd8d-4543-a9e8-2ea7529507a2; level=info msg="Planning finished on its sub directories" 
INFO[20468] Project: 27ea485f-bd8d-4543-a9e8-2ea7529507a2; level=info msg="[Directory Walk] Identified 0 named services and 0 to-be-named services" 
INFO[20468] Project: 27ea485f-bd8d-4543-a9e8-2ea7529507a2; level=info msg="[Named Services] Identified 0 named services" 
INFO[20468] Project: 27ea485f-bd8d-4543-a9e8-2ea7529507a2; level=info msg="Planning done. Number of services identified: 0" 
INFO[20468] Project: 27ea485f-bd8d-4543-a9e8-2ea7529507a2; level=info msg="Plan can be found at [/tmp/plan-27ea485f-bd8d-4543-a9e8-2ea7529507a2-3686120573/m2k.plan]." 
INFO[20468] Project: 27ea485f-bd8d-4543-a9e8-2ea7529507a2; level=warning msg="Did not detect any services in the directory /tmp/plan-27ea485f-bd8d-4543-a9e8-2ea7529507a2-3686120573/sources . Also we didn't find any default transformers to run."

After this if you start transformation, Move2Kube aborts because the plan has no services inside it. So the output folder isn't created.

https://gist.github.com/eloycoto/ad287ef001f3477d418571ecbc90d896

INFO[0030] Project: dfc29a1a-b991-44a4-b9c7-7c74d2fea661; Output:2691dc52-2c41-4635-8548-86f78570abcc; level=info msg="Detected a plan file at path /move2kube-api/data/projects/dfc29a1a-b991-44a4-b9c7-7c74d2fea661/outputs/2691dc52-2c41-4635-8548-86f78570abcc/m2k.plan. Will transform using this plan."
INFO[0030] Project: dfc29a1a-b991-44a4-b9c7-7c74d2fea661; Output:2691dc52-2c41-4635-8548-86f78570abcc; level=warning msg="Using the detected plan with specified source. If you did not want to use the plan file at /move2kube-api/data/projects/dfc29a1a-b991-44a4-b9c7-7c74d2fea661/outputs/2691dc52-2c41-4635-8548-86f78570abcc/m2k.plan, delete it and rerun the command."
INFO[0030] Project: dfc29a1a-b991-44a4-b9c7-7c74d2fea661; Output:2691dc52-2c41-4635-8548-86f78570abcc; level=fatal msg="Failed to find any services or default transformers. Aborting."
ERRO[0030] failed to copy over the m2kconfig.yaml and m2kqacache.yaml. Error: "failed to write the plan file to the path /move2kube-api/data/projects/dfc29a1a-b991-44a4-b9c7-7c74d2fea661/outputs/2691dc52-2c41-4635-8548-86f78570abcc/output/m2k.plan . Error: \"open /move2kube-api/data/projects/dfc29a1a-b991-44a4-b9c7-7c74d2fea661/outputs/2691dc52-2c41-4635-8548-86f78570abcc/output/m2k.plan: no such file or directory\""

Expected behaviour

The planning should succeed and detect a Golang service. The transformation should succeed and produce the Dockerfile and K8s YAMLs.

Version

$ move2kube-api version -l
version: v0.1.0+unreleased
gitCommit: a88d5e4b373c7ee7f610b968faa3163938430466
gitTreeState: clean
goVersion: go1.19.2
platform: darwin/amd64