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

Fix: Starterproject not replace existing devfile stack files of the context dir #6633

Conversation

valaparthvi
Copy link
Contributor

@valaparthvi valaparthvi commented Mar 6, 2023

What type of PR is this:
/kind bug

What does this PR do / why we need it:
This PR ensures that downloading a starter project does not replace an existing stack files downloading as a part of the Devfile.
Which issue(s) this PR fixes:

Fixes #6489

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:
0. Setup a custom devfile registry by using quay.io/pvala18/devfile-index:latest and go Devfile.

  1. Running the odo init --devfile go --devfile-version latest --starter go-starter --name my-go-app should show the following result:
➜  ls
README.md    devfile.yaml docker       go.mod       kubernetes   main.go

Here docker and kubernetes are a part of the Devfile stack.
2. Run odo init --devfile go --devfile-version latest --starter conflicting-starter-project-demo --name my-go-app. A CONFLICT_STARTER_PROJECT should have been created containing the starter project and a warning must be printed listing the conflicting files.
3. Run odo init --devfile go --devfile-version latest --starter starterproject-with-devfile-demo --name my-go-app. Downloading the starter project should replace devfile.yaml and the stack files.

@netlify
Copy link

netlify bot commented Mar 6, 2023

Deploy Preview for odo-docusaurus-preview canceled.

Name Link
🔨 Latest commit d9f25dc
🔍 Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/641996fb3ff90500081a7171

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. kind/bug Categorizes issue or PR as related to a bug. labels Mar 6, 2023
@openshift-ci openshift-ci bot requested review from anandrkskd and feloy March 6, 2023 10:23
@odo-robot
Copy link

odo-robot bot commented Mar 6, 2023

OpenShift Unauthenticated Tests on commit 9c1a3f4 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Mar 6, 2023

NoCluster Tests on commit 9c1a3f4 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Mar 6, 2023

Unit Tests on commit 9c1a3f4 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Mar 6, 2023

Validate Tests on commit 9c1a3f4 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Mar 6, 2023

Windows Tests (OCP) on commit 9c1a3f4 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Mar 6, 2023

Kubernetes Tests on commit 9c1a3f4 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Mar 6, 2023

Kubernetes Docs Tests on commit f543afa finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Mar 6, 2023

OpenShift Tests on commit 9c1a3f4 finished successfully.
View logs: TXT HTML

@valaparthvi valaparthvi force-pushed the 6489_download_starter_project_replaces_existing_files branch from 3199f13 to ac36ffc Compare March 13, 2023 05:15
@valaparthvi valaparthvi changed the title [WIP] Fix: Starterproject not replace existing devfile stack files of the context dir Fix: Starterproject not replace existing devfile stack files of the context dir Mar 13, 2023
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Mar 13, 2023
@valaparthvi
Copy link
Contributor Author

/override Kubernetes-Integration-Tests/Kubernetes-Integration-Tests

  Expected
      <string>:  âš   Pod is Terminating
       ✗  Finished executing the application (command: devrun) [43s]
       âš   No pod exists
       âš   Pod is Pending
       ✓  Pod is Running
       •  Syncing files into the container  ...
      
 ✓  Syncing files into the container [501ms]
       •  Building your application in container (command: devbuild)  ...
      
 ✓  Building your application in container (command: devbuild) [3s]
       •  Executing the application (command: devrun)  ...
       -  Forwarding from 127.0.0.1:39429 -> 3000
      
      
      ↪ Dev mode
       Keyboard Commands:
      [Ctrl+c] - Exit and delete resources from the cluster
           [p] - Manually apply local changes to the application on the cluster
      
  To satisfy at least one of these matchers: [%!s(*matchers.ContainSubstringMatcher=&{Pushing files... []}) %!s(*matchers.ContainSubstringMatcher=&{Updating Component... []})]
  In [BeforeEach] at: /go/odo_1/tests/helper/helper_run.go:64
------------------------------
•••••••


Summarizing 1 Failure:
  [FAIL] odo dev command tests port-forwarding for the component when devfile has single endpoint when running odo dev when modifying memoryLimit for container in Devfile [BeforeEach] should react on the Devfile modification
  /go/odo_1/tests/helper/helper_run.go:64

@openshift-ci
Copy link

openshift-ci bot commented Mar 13, 2023

@valaparthvi: Overrode contexts on behalf of valaparthvi: Kubernetes-Integration-Tests/Kubernetes-Integration-Tests

In response to this:

/override Kubernetes-Integration-Tests/Kubernetes-Integration-Tests

 Expected
     <string>:  âš   Pod is Terminating
      ✗  Finished executing the application (command: devrun) [43s]
      âš   No pod exists
      âš   Pod is Pending
      ✓  Pod is Running
      •  Syncing files into the container  ...
     
✓  Syncing files into the container [501ms]
      •  Building your application in container (command: devbuild)  ...
     
✓  Building your application in container (command: devbuild) [3s]
      •  Executing the application (command: devrun)  ...
      -  Forwarding from 127.0.0.1:39429 -> 3000
     
     
     ↪ Dev mode
      Keyboard Commands:
     [Ctrl+c] - Exit and delete resources from the cluster
          [p] - Manually apply local changes to the application on the cluster
     
 To satisfy at least one of these matchers: [%!s(*matchers.ContainSubstringMatcher=&{Pushing files... []}) %!s(*matchers.ContainSubstringMatcher=&{Updating Component... []})]
 In [BeforeEach] at: /go/odo_1/tests/helper/helper_run.go:64
------------------------------
•••••••


Summarizing 1 Failure:
 [FAIL] odo dev command tests port-forwarding for the component when devfile has single endpoint when running odo dev when modifying memoryLimit for container in Devfile [BeforeEach] should react on the Devfile modification
 /go/odo_1/tests/helper/helper_run.go:64

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@valaparthvi
Copy link
Contributor Author

/override windows-integration-test/Windows-test

  Expected
      <*url.Error | 0xc0002ec8a0>: {
          Op: "Post",
          URL: "http://127.0.0.1:64534/api/newuser",
          Err: <*errors.errorString | 0xc000088130>{s: "EOF"},
      }
  to be nil
  In [It] at: C:/Users/Administrator.ANSIBLE-TEST-VS/3416/tests/e2escenarios/e2e_test.go:306

  There were additional failures detected after the initial failure.  Here's a summary - for full details run Ginkgo in verbose mode:
    [FAILED] in [AfterEach] at C:/Users/Administrator.ANSIBLE-TEST-VS/3416/tests/helper/helper_filesystem.go:48
------------------------------


Summarizing 1 Failure:
  [FAIL] E2E Test starting with non-empty Directory add Binding [It] should verify developer workflow of using binding as env in innerloop
  C:/Users/Administrator.ANSIBLE-TEST-VS/3416/tests/e2escenarios/e2e_test.go:306

@openshift-ci
Copy link

openshift-ci bot commented Mar 13, 2023

@valaparthvi: Overrode contexts on behalf of valaparthvi: windows-integration-test/Windows-test

In response to this:

/override windows-integration-test/Windows-test

 Expected
     <*url.Error | 0xc0002ec8a0>: {
         Op: "Post",
         URL: "http://127.0.0.1:64534/api/newuser",
         Err: <*errors.errorString | 0xc000088130>{s: "EOF"},
     }
 to be nil
 In [It] at: C:/Users/Administrator.ANSIBLE-TEST-VS/3416/tests/e2escenarios/e2e_test.go:306

 There were additional failures detected after the initial failure.  Here's a summary - for full details run Ginkgo in verbose mode:
   [FAILED] in [AfterEach] at C:/Users/Administrator.ANSIBLE-TEST-VS/3416/tests/helper/helper_filesystem.go:48
------------------------------


Summarizing 1 Failure:
 [FAIL] E2E Test starting with non-empty Directory add Binding [It] should verify developer workflow of using binding as env in innerloop
 C:/Users/Administrator.ANSIBLE-TEST-VS/3416/tests/e2escenarios/e2e_test.go:306

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@valaparthvi valaparthvi requested review from rm3l and removed request for anandrkskd March 13, 2023 11:55
tests/integration/cmd_devfile_init_test.go Show resolved Hide resolved
pkg/registry/registry.go Outdated Show resolved Hide resolved
pkg/registry/registry.go Outdated Show resolved Hide resolved
pkg/registry/registry.go Outdated Show resolved Hide resolved
pkg/registry/registry.go Outdated Show resolved Hide resolved
pkg/registry/registry.go Outdated Show resolved Hide resolved
pkg/registry/registry.go Outdated Show resolved Hide resolved
pkg/registry/registry.go Outdated Show resolved Hide resolved
@@ -228,7 +224,7 @@ func IsValidProjectDir(path string, devfilePath string) error {
// takes an absolute path prefixed with file:// and extracts it to a destination.
// pathToUnzip specifies the path within the zip folder to extract
// TODO(feloy) sync with devfile library?
func GetAndExtractZip(zipURL string, destination string, pathToUnzip string, starterToken string) error {
func GetAndExtractZip(zipURL string, destination string, pathToUnzip string, starterToken string, fsys filesystem.Filesystem) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can fsys be the first parameter of this function, just to be consistent with the other functions like IsValidProjectDir?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the position of fsys in IsValidProjectDir just to be more consistent with other functions.

pkg/util/util.go Outdated Show resolved Hide resolved
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
@valaparthvi valaparthvi force-pushed the 6489_download_starter_project_replaces_existing_files branch from efc25e4 to 30bb75c Compare March 16, 2023 18:44
@valaparthvi
Copy link
Contributor Author

/override Kubernetes-Integration-Tests/Kubernetes-Docs-Integration-Tests

  user-guides/quickstart/docs-mdx/dotnet/dotnet_odo_dev_output.mdx
  Expected
      <string>:   (
        	"""
        	... // 9 identical lines
        	•  Waiting for Kubernetes resources  ...
        	âš   Pod is Pending
      - 	✓  Pod is Running
        	✓  Syncing files into the container [1s]
        	✓  Building your application in container (command: build) [1s]
        	... // 9 identical lines
        	[Ctrl+c] - Exit and delete resources from the cluster
        	[p] - Manually apply local changes to the application on the cluster
      + 	✓  Pod is Running
        	```
        	"""
        )
      
  to be empty
  In [It] at: /go/odo_1/tests/documentation/user-guides/doc_user_guides_quickstart_test.go:208
------------------------------
Spawning '/go/bin/odo init' from /tmp/2337855403
••Spawning '/go/bin/odo init' from /tmp/4264151494
•Spawning '/go/bin/odo init' from /tmp/1110626714
•


Summarizing 1 Failure:
  [FAIL] User guides: Quickstart test .NET quickstart guide [It] should test the complete dotnet quickstart output in order
  /go/odo_1/tests/documentation/user-guides/doc_user_guides_quickstart_test.go:208

@openshift-ci
Copy link

openshift-ci bot commented Mar 20, 2023

@valaparthvi: Overrode contexts on behalf of valaparthvi: Kubernetes-Integration-Tests/Kubernetes-Docs-Integration-Tests

In response to this:

/override Kubernetes-Integration-Tests/Kubernetes-Docs-Integration-Tests

 user-guides/quickstart/docs-mdx/dotnet/dotnet_odo_dev_output.mdx
 Expected
     <string>:   (
       	"""
       	... // 9 identical lines
       	•  Waiting for Kubernetes resources  ...
       	âš   Pod is Pending
     - 	✓  Pod is Running
       	✓  Syncing files into the container [1s]
       	✓  Building your application in container (command: build) [1s]
       	... // 9 identical lines
       	[Ctrl+c] - Exit and delete resources from the cluster
       	[p] - Manually apply local changes to the application on the cluster
     + 	✓  Pod is Running
       	```
       	"""
       )
     
 to be empty
 In [It] at: /go/odo_1/tests/documentation/user-guides/doc_user_guides_quickstart_test.go:208
------------------------------
Spawning '/go/bin/odo init' from /tmp/2337855403
••Spawning '/go/bin/odo init' from /tmp/4264151494
•Spawning '/go/bin/odo init' from /tmp/1110626714
•


Summarizing 1 Failure:
 [FAIL] User guides: Quickstart test .NET quickstart guide [It] should test the complete dotnet quickstart output in order
 /go/odo_1/tests/documentation/user-guides/doc_user_guides_quickstart_test.go:208

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@valaparthvi
Copy link
Contributor Author

/override windows-integration-test/Windows-test

  Expected
      <*url.Error | 0xc0005dac00>: {
          Op: "Post",
          URL: "http://127.0.0.1:61953/api/newuser",
          Err: <*errors.errorString | 0xc000088130>{s: "EOF"},
      }
  to be nil
  In [It] at: C:/Users/Administrator.ANSIBLE-TEST-VS/3429/tests/e2escenarios/e2e_test.go:306

  There were additional failures detected after the initial failure.  Here's a summary - for full details run Ginkgo in verbose mode:
    [FAILED] in [AfterEach] at C:/Users/Administrator.ANSIBLE-TEST-VS/3429/tests/helper/helper_filesystem.go:48
------------------------------


Summarizing 1 Failure:
  [FAIL] E2E Test starting with non-empty Directory add Binding [It] should verify developer workflow of using binding as env in innerloop
  C:/Users/Administrator.ANSIBLE-TEST-VS/3429/tests/e2escenarios/e2e_test.go:306

@openshift-ci
Copy link

openshift-ci bot commented Mar 20, 2023

@valaparthvi: Overrode contexts on behalf of valaparthvi: windows-integration-test/Windows-test

In response to this:

/override windows-integration-test/Windows-test

 Expected
     <*url.Error | 0xc0005dac00>: {
         Op: "Post",
         URL: "http://127.0.0.1:61953/api/newuser",
         Err: <*errors.errorString | 0xc000088130>{s: "EOF"},
     }
 to be nil
 In [It] at: C:/Users/Administrator.ANSIBLE-TEST-VS/3429/tests/e2escenarios/e2e_test.go:306

 There were additional failures detected after the initial failure.  Here's a summary - for full details run Ginkgo in verbose mode:
   [FAILED] in [AfterEach] at C:/Users/Administrator.ANSIBLE-TEST-VS/3429/tests/helper/helper_filesystem.go:48
------------------------------


Summarizing 1 Failure:
 [FAIL] E2E Test starting with non-empty Directory add Binding [It] should verify developer workflow of using binding as env in innerloop
 C:/Users/Administrator.ANSIBLE-TEST-VS/3429/tests/e2escenarios/e2e_test.go:306

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@valaparthvi valaparthvi requested a review from rm3l March 20, 2023 10:57
pkg/registry/registry.go Outdated Show resolved Hide resolved
pkg/registry/registry.go Outdated Show resolved Hide resolved
pkg/registry/registry.go Outdated Show resolved Hide resolved
pkg/registry/registry.go Outdated Show resolved Hide resolved
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
…icting and non-conflicting cases

Signed-off-by: Parthvi Vala <pvala@redhat.com>
@valaparthvi valaparthvi requested a review from rm3l March 20, 2023 14:57
Copy link
Member

@rm3l rm3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. LGTM overall. I had one last comment on error handling when walking the directory tree.

pkg/registry/registry.go Show resolved Hide resolved
Signed-off-by: Parthvi Vala <pvala@redhat.com>
@valaparthvi valaparthvi requested a review from rm3l March 20, 2023 18:35
Copy link
Member

@rm3l rm3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Mar 20, 2023
Copy link
Member

@rm3l rm3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, sorry. I just approved this PR feature-wise, but noticed I had a lot of odostarterproject* and odo* non-empty folders filling up my temporary filesystem.

pkg/registry/registry.go Show resolved Hide resolved
pkg/registry/registry.go Show resolved Hide resolved
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Mar 20, 2023
@valaparthvi valaparthvi force-pushed the 6489_download_starter_project_replaces_existing_files branch from c826e28 to 101b895 Compare March 21, 2023 10:39
@valaparthvi valaparthvi reopened this Mar 21, 2023
@valaparthvi valaparthvi reopened this Mar 21, 2023
Signed-off-by: Parthvi Vala <pvala@redhat.com>
@valaparthvi valaparthvi force-pushed the 6489_download_starter_project_replaces_existing_files branch from 101b895 to d9f25dc Compare March 21, 2023 11:37
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
0.3% 0.3% Duplication

Copy link
Member

@rm3l rm3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this!

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Mar 21, 2023
@openshift-merge-robot openshift-merge-robot merged commit 47234b9 into redhat-developer:main Mar 21, 2023
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. lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Downloading starterproject replaces existing contents of a directory
3 participants