konveyor / move2kube

Move2Kube is a command-line tool for automating creation of Infrastructure as code (IaC) artifacts. It has inbuilt support for creating IaC artifacts for replatforming to Kubernetes/Openshift.
https://move2kube.konveyor.io/
Apache License 2.0
383 stars 118 forks source link

bug: Failed to parameterize error while running move2kube transform on docker-compose file #958

Closed Akash-Nayak closed 1 year ago

Akash-Nayak commented 1 year ago

Describe the bug I am getting an error failed to parameterize YAML files in the source directory while running move2kube transform on the below docker-compose file

To Reproduce Steps to reproduce the behavior:

  1. Input docker-compose.yml
services:
  hello_worldDLR_BR_OP_TAG_BR_CL:
    command:
    - /bin/echo
    - Hello world
    deploy:
      placement:
        constraints:
        - node.a.b.c == true
    environment:
    - env:${CODE}
    image: ubuntu:${TAG}
    links:
    - redis${TAG}:redis${TAG}
    ports:
    - ${UIPORT}:8443
version: "3"
  1. Run move2kube transform over the source folder dc-input.zip which contains the above docker-compose file.

  2. Choose the cluster type as IBM Openshift or Openshift. (The error doesn't appear if I select Kubernetes as the cluster type.)

? Choose the cluster type:
ID: move2kube.target."default".clustertype
Hints:
- Choose the cluster type you would like to target

  [Use arrows to move, type to filter]
  AWS-EKS
  Azure-AKS
  GCP-GKE
  IBM-IKS
> IBM-Openshift
  Kubernetes
  Openshift
  1. It throws an error towards end of transformation.
? Provide the ingress host domain
ID: move2kube.target."default".ingress.host
Hints:
- Ingress host domain is part of service URL

 t14.com
INFO[0041] Transformer Kubernetes Done                  
INFO[0041] Transformer ClusterSelector processing 2 artifacts 
INFO[0041] Transformer ClusterSelector Done             
INFO[0041] Transformer Tekton processing 2 artifacts    
INFO[0041] Transformer Tekton Done                      
INFO[0041] Created 30 pathMappings and 10 artifacts. Total Path Mappings : 30. Total Artifacts : 3. 
INFO[0041] Iteration 4 - 10 artifacts to process        
INFO[0041] Transformer Parameterizer processing 6 artifacts 
WARN[0041] Error in walking through files due to : "stat /var/folders/sw/_kjrz98j3ws1qj7zz6chzhrr0000gn/T/move2kube1729845829/environment-Parameterizer-3160189886/2622198968/deploy/cicd/buildconfig: no such file or directory" 
ERRO[0041] failed to parameterize the YAML files in the source directory /var/folders/sw/_kjrz98j3ws1qj7zz6chzhrr0000gn/T/move2kube1729845829/environment-Parameterizer-3160189886/2622198968/deploy/cicd/buildconfig and write to output directory /var/folders/sw/_kjrz98j3ws1qj7zz6chzhrr0000gn/T/move2kube1729845829/environment-Parameterizer-3160189886/2995956675/buildconfig-parameterized . Error: "stat /var/folders/sw/_kjrz98j3ws1qj7zz6chzhrr0000gn/T/move2kube1729845829/environment-Parameterizer-3160189886/2622198968/deploy/cicd/buildconfig: no such file or directory"

Expected behavior The above error should not show up while running move2kube transform

Screenshots

Screenshot 2023-02-07 at 12 33 01 PM

Desktop (please complete the following information):

move2kube version -l                  
version: v0.3.0+unreleased
gitCommit: 0d8f71ad8264029e04b5d919ca7f5ccb9c1d8c7d
gitTreeState: clean
goVersion: go1.18.1
platform: darwin/amd64
HarikrishnanBalagopal commented 1 year ago

Seems the ir.ContainerImages is empty after ComposeAnalyser.Transform function is called.

Akash-Nayak commented 1 year ago

I just checked that the same issue can also be reproduced with the move2kube-demos docker-compose sample https://github.com/konveyor/move2kube-demos/blob/main/samples/docker-compose/multiple-services/docker-compose.yaml if I comment-out/remove lines 6 and 17, i.e., if the docker-compose file doesn’t have the build key for any service.

HarikrishnanBalagopal commented 1 year ago

Tried adding the build key to the Dockerfile in the original post:

services:
  hello_worldDLR_BR_OP_TAG_BR_CL:
    build: .
    command:
    - /bin/echo
    - Hello world
    deploy:
      placement:
        constraints:
        - node.a.b.c == true
    environment:
    - env:${CODE}
    image: ubuntu:${TAG}
    links:
    - redis${TAG}:redis${TAG}
    ports:
    - ${UIPORT}:8443
version: "3"

This works without error, produces ContainerImages and BuildConfig

HarikrishnanBalagopal commented 1 year ago

fixed by adding a check before creating the artifact in BuildConfig transformer https://github.com/konveyor/move2kube/pull/963/files#diff-2a1ff621d16165f6fe85b3c4599804d42481d872fbebab5c38136dce75c83e01R152