odo: Cannot delete devfile component from cluster without context folder

/kind bug

What versions of software are you using?

Operating System: Linux

Output of odo version: 2.0.0

How did you run odo exactly?

Current project is p1

~/component$ odo create nodejs --app app1
Validation
 ✓  Checking devfile existence [27213ns]
 ✓  Checking devfile compatibility [37570ns]
 ✓  Creating a devfile component from registry: DefaultDevfileRegistry [40669ns]
 ✓  Validating devfile component [81577ns]

Please use `odo push` command to create the component with source deployed

~/component$ odo push

Validation
 ✓  Validating the devfile [25241ns]

Creating Kubernetes resources for component nodejs
 ✓  Waiting for component to start [6s]

Applying URL changes
 ✓  URL http-3000: http://http-3000-nodejs-p4.apps-crc.testing/ created

Syncing to component nodejs
 ✓  Checking files for pushing [879948ns]
 ✓  Syncing files to the component [455ms]

Executing devfile commands for component nodejs
 ✓  Executing install command "npm install" [4s]
 ✓  Executing run command "npm start" [1s]

Pushing devfile component nodejs
 ✓  Changes successfully pushed to component

Actual behavior

~/component$ cd ..

~$ odo delete nodejs --project p1 --app app1
✗  Component nodejs does not exist on the cluster

Expected behavior

~$ odo delete nodejs --project p1 --app app1
? Are you sure you want to delete the devfile component: nodejs? Yes

Gathering information for component nodejs
 ✓  Checking status for component [19ms]

Deleting component nodejs
 ✓  Deleting Kubernetes resources for component [12ms]
 ✓  Successfully deleted component
~$

Any logs, error output, etc?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (15 by maintainers)

Most upvoted comments

I was debugging it and at first look it seemed simple to me, if the right devfile is not being deleted, it must not be taking in account the right path. pkg/odo/cli/component/delete.go::DevFileRun, while performing the deletion, it doesn’t really take context into account,

		if do.componentForceDeleteFlag {
			if !util.CheckPathExists(DevfilePath) {      <-------
				return fmt.Errorf("devfile.yaml does not exist in the current directory")
			}
			if !do.EnvSpecificInfo.IsUserCreatedDevfile() {
				err = util.DeletePath(DevfilePath)       <--------
				if err != nil {
					return err
				}

				log.Successf("Successfully deleted devfile.yaml file")

			} else {
				log.Info("Didn't delete the devfile as it was user provided")
			}

		}

If we were to change DevfilePath to do.devfilePath it seems to delete the right devfile. I checked with odo delete -f --all --context <context_folder>. I am not sure if this answers point 3 that you made here though.