odo: Erasing a local devfile is not enough to reset odo

/kind bug

What versions of software are you using?

Operating System: macOS 10.15.4

Output of odo version: odo v1.2.0 (e1232ad1a)

Server: <redacted> Kubernetes: v1.11.0+d4cacc0

How did you run odo exactly?

  1. odo component create maven
  2. Realize that I actually wanted another component type
  3. odo component create java-spring-boot
  4. Get an error: ✗ This directory already contains a devfile.yaml, please delete it and run the component creation command again
  5. So follow the instructions and delete devfile.yaml
  6. odo component create java-spring-boot:
Experimental mode is enabled, use at your own risk

Validation
 ✓  Checking devfile compatibility [14ms]
 ✗  Validating devfile component [114030ns]
 ✗  This workspace directory already contains a devfile component

Actual behavior

See above.

Expected behavior

Be able to create my component the second time around without issue. At least, provide a better error message that would allow a user to fix the issue.

Any logs, error output, etc?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (16 by maintainers)

Most upvoted comments

* `odo delete -a ` should work even if the component was not pushed, and it should delete both `.env` folder and devfile.yaml

@kadel I am not sure if we should delete the devfile.yaml for the user as part of the odo delete -a command or should we require the user to manually delete the devfile.yaml. Consider the scenario that developer A has developed an app and check into git together with a customized devfile.yaml. Then, developer B clone that app git repo and use odo to continue to do the development. After developer B is done with the component, if developer B do odo delete -a, we’ll be removing the devfile.yaml that is not even created by odo. Should we consider the devfile.yaml as part of the application resource and let the user handle the lifecycle of that?

I also think we should not delete the devfile.yaml with odo delete -a since we can create a component odo create nodejs for example, with an existing devfile.yaml in current dir.

If we really want to delete devfile.yaml with odo delete -a, the alternative would be to prompt a question and ask if the devfile.yaml should be deleted.

Agreed with the second part, odo delete --all should definitely prompt for confirmation, the same as it is currently asking when running odo delete. Only when --force flag is provided the prompt should be skipped.

@kadel I am not sure if we should delete the devfile.yaml for the user as part of the odo delete -a command or should we require the user to manually delete the devfile.yaml. Consider the scenario that developer A has developed an app and check into git together with a customized devfile.yaml. Then, developer B clone that app git repo and use odo to continue to do the development. After developer B is done with the component, if developer B do odo delete -a, we’ll be removing the devfile.yaml that is not even created by odo. Should we consider the devfile.yaml as part of the application resource and let the user handle the lifecycle of that?

Hmm, that also makes sense.

But what about this scenario:

  • I create new odo component odo create
  • I realized that I wanted to do something else
  • I run odo delete --all with the assumption that it will delete everything that odo created after all the flag is called all (but in this case it will keep devfile.yaml)
  • I run odo create again and it fails 😦

I think that if we are clear about what the odo delete -a does it should be ok, after all, it is not a default delete strategy users will need to provide additional flag, and they will be asked to confirm. If odo is creating devfile with odo create there should be also a variation of odo delete command to completely clean what odo created.

What about this?

  • odo delete
    • should delete what was created in the cluster and keep .odo and devfile.yaml in place
    • if the component was not pushed yet (nothing was created in the cluster) it should just print information that there is nothing in the cluster. No error should be thrown.
    • should ask the user for confirmation unless executed with -f flag
    • the output should contain information that this is just deleting resources from the cluster
  • odo delete --all
    • should delete everything form cluster as odo delete does
    • in addition to deleting resources from the cluster, it should also delete .odo and devfile.yaml
    • should ask the user for confirmation unless executed with -f flag
    • confirmation will have three stages.
      • Do you want to delete all resources related to this component from the cluster? (Y/n)
      • Do you want to delete local configuration in .odo directory? (Y/n)
      • Do you want to delete devfile.yaml from the current directory? (Y/n)

This would make odo delete is an inversion of odo push and odo delete --all inversion of odo create; odo push and the user will always have a choice to decide what to delete.

What do you think?