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

Failed plan crashes the project #169

Closed
gabriel-farache opened this issue Mar 12, 2024 · 6 comments · Fixed by konveyor/move2kube-api#170
Closed

Failed plan crashes the project #169

gabriel-farache opened this issue Mar 12, 2024 · 6 comments · Fixed by konveyor/move2kube-api#170
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@gabriel-farache
Copy link

gabriel-farache commented Mar 12, 2024

Describe the bug
When the plan command fails, the project crashes and no action can be performed on it

To Reproduce
Steps to reproduce the behavior:

  1. Create a workspace and a project
  2. Start a plan via the API with invalid input with remote source, ie: wrong url so the plan will fail
    Command executed should be similar to plan --name a --plan-progress-port 32881 --log-file m2kcli.log --source git+ssh://bitbucket.com/gfarache31/m2k-test@master --disable-local-execution
  3. Check the logs to see the error, something similar to:
time="2024-03-12T09:47:17Z" level=info msg="plan cmdArgs: [plan --name a --plan-progress-port 32881 --log-file m2kcli.log --source git+ssh://bitbucket.com/gfarache31/m2k-test@master --disable-local-execution]"
time="2024-03-12T09:47:17Z" level=info msg="Project: 4a3d44ae-ba55-49b9-ae67-9b0b6d66640e; level=info msg=\"Cloning the repository using git into '/tmp/move2kube3232420242/m2ksources' . This might take some time.\""
time="2024-03-12T09:47:18Z" level=info msg="Project: 4a3d44ae-ba55-49b9-ae67-9b0b6d66640e; level=fatal msg=\"failed to create the plan. Error: \\\"failed to clone the repo 'git+ssh://bitbucket.com/gfarache31/m2k-test@master'. Error: failed to clone using vcs url 'git+ssh://bitbucket.com/gfarache31/m2k-test@master' and clone options {CommitDepth:1 Overwrite:true MaxSize:-1 CloneDestinationPath:/tmp/move2kube3232420242/m2ksources}. Error: failed to perform clone operation using git. Error: repository already exists\\\"\""
time="2024-03-12T09:47:18Z" level=error msg="failed to update the database after planning finished. Error: \"failed to copy the plan file from /tmp/plan-4a3d44ae-ba55-49b9-ae67-9b0b6d66640e-4058952779/m2k.plan to /move2kube-api/data/projects/4a3d44ae-ba55-49b9-ae67-9b0b6d66640e/inputs/expanded/m2k.plan after planning finished. Error: \\\"failed to open the source file at path \\\\\\\"/tmp/plan-4a3d44ae-ba55-49b9-ae67-9b0b6d66640e-4058952779/m2k.plan\\\\\\\" Error: \\\\\\\"open /tmp/plan-4a3d44ae-ba55-49b9-ae67-9b0b6d66640e-4058952779/m2k.plan: no such file or directory\\\\\\\"\\\"\""
  1. Try to delete the project or start another planning
  2. See error

Expected behavior
The project should remain available: we should be able to start new plan if a previous one failed and we should be able to delete the project as well

Screenshots
image
The project cannot be deleted but the plan failed (the ID of this screenshot and the previous trace does not match because I have too many projects)
Desktop (please complete the following information):

  • OS: [e.g. iOS] Fedora
  • Browser [e.g. chrome, safari] chrome
  • Version [e.g. 22] v0.3.11

Additional context
Related to konveyor/move2kube-api#159

@gabriel-farache
Copy link
Author

Refreshing this issue by providing the error logged when trying the GET the plan when a error previously occured:

time="2024-08-12T09:49:23Z" level=info msg="GET /api/v1/workspaces/b37ca163-c276-4cd6-a608-836e37a20be5/projects/a28112bf-2801-4df4-aa78-14286446673a/plan" request-id=426715a4-5ab3-41f5-9539-e4a20dab4cca
time="2024-08-12T09:49:23Z" level=error msg="failed to send a GET request to get the plan progress from the server at http://localhost:38369/progress . Error: \"Get \\\"http://localhost:38369/progress\\\": dial tcp [::1]:38369: connect: connection refused\""

Previous relevant logs:

time="2024-08-12T09:48:19Z" level=info msg="plan cmdArgs: [plan --name d --plan-progress-port 38369 --log-file m2kcli.log --source git+ssh://bitbucket.org/gfarache31/m2k-test --disable-local-execution]"
time="2024-08-12T09:48:19Z" level=info msg="Project: a28112bf-2801-4df4-aa78-14286446673a; level=info msg=\"Cloning the repository using git into '/tmp/move2kube2229537828/m2ksources' . This might take some time.\""
time="2024-08-12T09:48:20Z" level=info msg="Project: a28112bf-2801-4df4-aa78-14286446673a; level=fatal msg=\"failed to create the plan. Error: \\\"failed to clone the repo 'git+ssh://bitbucket.org/gfarache31/m2k-test'. Error: failed to clone using vcs url 'git+ssh://bitbucket.org/gfarache31/m2k-test' and clone options {CommitDepth:1 Overwrite:true MaxSize:-1 CloneDestinationPath:/tmp/move2kube2229537828/m2ksources}. Error: failed to perform clone operation using git with options {URL:[email protected]:gfarache31/m2k-test Auth:<nil> RemoteName:origin ReferenceName:refs/heads/main SingleBranch:true Mirror:false NoCheckout:false Depth:1 RecurseSubmodules:0 ShallowSubmodules:false Progress:<nil> Tags:2 InsecureSkipTLS:false CABundle:[] ProxyOptions:{URL: Username: Password:} Shared:false} and {CommitDepth:1 Overwrite:true MaxSize:-1 CloneDestinationPath:/tmp/move2kube2229537828/m2ksources}. Error: couldn't find remote ref \\\\\\\"refs/heads/main\\\\\\\"\\\"\""
time="2024-08-12T09:48:20Z" level=error msg="failed to update the database after planning finished. Error: \"failed to copy the plan file from /tmp/plan-a28112bf-2801-4df4-aa78-14286446673a-1634040701/m2k.plan to /move2kube-api/data/projects/a28112bf-2801-4df4-aa78-14286446673a/inputs/expanded/m2k.plan after planning finished. Error: \\\"failed to open the source file at path \\\\\\\"/tmp/plan-a28112bf-2801-4df4-aa78-14286446673a-1634040701/m2k.plan\\\\\\\" Error: \\\\\\\"open /tmp/plan-a28112bf-2801-4df4-aa78-14286446673a-1634040701/m2k.plan: no such file or directory\\\\\\\"\\\"\""

@kmehant is this issue in the roadmap somewhere?

@ashokponkumar
Copy link
Member

@HarikrishnanBalagopal Any thoughts on what is happening here? Is it a quick fix?

@HarikrishnanBalagopal
Copy link
Contributor

HarikrishnanBalagopal commented Aug 23, 2024

@gabriel-farache Hi, I was trying to reproduce the issue. I was able to run the Move2Kube CLI in the terminal and get the errors that you gave.

However I am not able to reproduce the issue using Move2Kube UI or the API directly. Currently there is no support for remote source URLs in the API.

Can you please provide more details on the steps to reproduce the issue, especially step 2?

1. Create a workspace and a project
2. Start a plan via the API with invalid input with remote source, ie: wrong url so the plan will fail
Command executed should be similar to plan --name a --plan-progress-port 32881 --log-file m2kcli.log --source git+ssh://bitbucket.com/gfarache31/m2k-test@master --disable-local-execution
3. Check the logs to see the error, something similar to:

Update:
Found this konveyor/move2kube-api#155

@HarikrishnanBalagopal
Copy link
Contributor

HarikrishnanBalagopal commented Aug 24, 2024

@gabriel-farache PTAL konveyor/move2kube-api#170

Before

time="2024-08-24T13:43:37Z" level=fatal msg="failed to create the plan. Error: \"failed to clone the repo 'git+ssh://bitbucket.com/gfarache31/m2k-test@master'. Error: failed to clone using vcs url 'git+ssh://bitbucket.com/gfarache31/m2k-test@master' and clone options {CommitDepth:1 Overwrite:true MaxSize:-1 CloneDestinationPath:/tmp/move2kube2819398992/m2ksources}. Error: failed to perform clone operation using git. Error: error creating SSH agent: \\\"SSH agent requested but SSH_AUTH_SOCK not-specified\\\"\"" 
DEBU[2186] planning finished. inside Update. just before checks start 
DEBU[2186] readProject project: {Metadata:{Id:695cb5e9-5e2b-4f06-a027-a244cf83a65a Name:p2 Description: Timestamp:2024-08-24T13:43:02.544472026Z} Inputs:map[] Outputs:map[] Status:map[planning:true]} 
DEBU[2186] planning finished. inside Update. just before update start 
DEBU[2186] planning finished. inside Update. just before effects start 
ERRO[2186] failed to update the database after planning finished. Error: "failed to copy the plan file from /tmp/plan-695cb5e9-5e2b-4f06-a027-a244cf83a65a-4107616358/m2k.plan to /move2kube-api/data/projects/695cb5e9-5e2b-4f06-a027-a244cf83a65a/inputs/expanded/m2k.plan after planning finished. Error: failed to open the source file at path \"/tmp/plan-695cb5e9-5e2b-4f06-a027-a244cf83a65a-4107616358/m2k.plan\" Error: \"open /tmp/plan-695cb5e9-5e2b-4f06-a027-a244cf83a65a-4107616358/m2k.plan: no such file or directory\"" 
INFO[2251] POST /api/v1/workspaces/ecd6ddbb-5bd3-4ad2-9210-1c08dd8c9243/projects/695cb5e9-5e2b-4f06-a027-a244cf83a65a/plan?remote-source=git%2Bhttps%3A%2F%2Fgithub.com%2Fkonveyor%2Fmove2kube&dump-cli-logs=true  request-id=24823cc8-bfb1-4f18-845e-f5bc73dda58e
DEBU[2251] readProject project: {Metadata:{Id:695cb5e9-5e2b-4f06-a027-a244cf83a65a Name:p2 Description: Timestamp:2024-08-24T13:43:02.544472026Z} Inputs:map[] Outputs:map[] Status:map[planning:true]} 
ERRO[2251] failed to start plan generation. Error: "the generation for object with id: 695cb5e9-5e2b-4f06-a027-a244cf83a65a is ongoing"  request-id=24823cc8-bfb1-4f18-845e-f5bc73dda58e

After

time="2024-08-24T15:53:21Z" level=fatal msg="failed to create the plan. Error: \"failed to clone the repo 'git+ssh://bitbucket.com/gfarache31/m2k-test@master'. Error: failed to clone using vcs url 'git+ssh://bitbucket.com/gfarache31/m2k-test@master' and clone options {CommitDepth:1 Overwrite:true MaxSize:-1 CloneDestinationPath:/tmp/move2kube4090321658/m2ksources}. Error: failed to perform clone operation using git. Error: error creating SSH agent: \\\"SSH agent requested but SSH_AUTH_SOCK not-specified\\\"\"" 
DEBU[0216] planning finished. inside Update. just before checks start 
DEBU[0216] readProject project: {Metadata:{Id:88aa190f-8ce6-4f68-9fe6-c8f451de46e8 Name:p2 Description: Timestamp:2024-08-24T15:52:13.454367954Z} Inputs:map[] Outputs:map[] Status:map[planning:true]} 
DEBU[0216] planning finished. inside Update. just before update start 
DEBU[0216] planning finished. inside Update. just before effects start 
ERRO[0216] failed to finish planning using move2kube. Error: "exit status 1" 
DEBU[0216] planning finished. inside deferred Update. just before update start in defer 
DEBU[0216] deferred Update project {Metadata:{Id:88aa190f-8ce6-4f68-9fe6-c8f451de46e8 Name:p2 Description: Timestamp:2024-08-24T15:52:13.454367954Z} Inputs:map[] Outputs:map[] Status:map[plan:false plan_error:true planning:false remote:true stale_plan:false]} 
DEBU[0216] planning finished. inside deferred Update near end 
INFO[0463] POST /api/v1/workspaces/4b17bd88-98ad-47c1-bfd3-bfcd102a82ec/projects/88aa190f-8ce6-4f68-9fe6-c8f451de46e8/plan?remote-source=git%2Bhttps%3A%2F%2Fgithub.com%2Fkonveyor%2Fmove2kube&dump-cli-logs=true  request-id=ed55f090-d10e-422a-bd83-9cd6355dda73
DEBU[0463] readProject project: {Metadata:{Id:88aa190f-8ce6-4f68-9fe6-c8f451de46e8 Name:p2 Description: Timestamp:2024-08-24T15:52:13.454367954Z} Inputs:map[] Outputs:map[] Status:map[plan:false plan_error:true planning:false remote:true stale_plan:false]} 
DEBU[0463] just before updating state before starting planning for project '88aa190f-8ce6-4f68-9fe6-c8f451de46e8' in workspace '4b17bd88-98ad-47c1-bfd3-bfcd102a82ec' 
DEBU[0463] plan progress server metadata {Host:localhost Port:37455 Debug:false} 
DEBU[0463] just before starting effects before starting planning for project '88aa190f-8ce6-4f68-9fe6-c8f451de46e8' in workspace '4b17bd88-98ad-47c1-bfd3-bfcd102a82ec' 
DEBU[0463] just before copying over reference type inputs before starting planning for project '88aa190f-8ce6-4f68-9fe6-c8f451de46e8' in workspace '4b17bd88-98ad-47c1-bfd3-bfcd102a82ec' 
DEBU[0463] just before starting planning for project 88aa190f-8ce6-4f68-9fe6-c8f451de46e8 in workspace 4b17bd88-98ad-47c1-bfd3-bfcd102a82ec 
INFO[0463] Planning started for the project with id 88aa190f-8ce6-4f68-9fe6-c8f451de46e8 
INFO[0463] Starting plan at directory /tmp/plan-88aa190f-8ce6-4f68-9fe6-c8f451de46e8-909757260 using configs [] and source git+https://github.com/konveyor/move2kube and customizations  to output /tmp/plan-88aa190f-8ce6-4f68-9fe6-c8f451de46e8-909757260. Will dump cli logs to stdout: true

@HarikrishnanBalagopal
Copy link
Contributor

@gabriel-farache We have made a new release with the fix https://github.com/konveyor/move2kube-api/releases/tag/v0.3.14

@gabriel-farache
Copy link
Author

@HarikrishnanBalagopal Thank you! It works like a charm, now I can reuse the project even if there was an error on it previously

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants