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

Binary component create fails if path is relative and includes ../ #3797

Closed
amitkrout opened this issue Aug 20, 2020 · 7 comments · Fixed by #4139
Closed

Binary component create fails if path is relative and includes ../ #3797

amitkrout opened this issue Aug 20, 2020 · 7 comments · Fixed by #4139
Assignees
Labels
area/testing Issues or PRs related to testing, Quality Assurance or Quality Engineering priority/Medium Nice to have issue. Getting it done before priority changes would be great.

Comments

@amitkrout
Copy link
Contributor

amitkrout commented Aug 20, 2020

/kind bug

What versions of software are you using?

Operating System:
macOS
Output of odo version:
master

How did you run odo exactly?

It("binary component is valid if path is relative and includes ../", func() {
       oc.ImportJavaIS(project)
       helper.CopyExample(filepath.Join("binary", "java", "openjdk"), context)

       relativeContext := fmt.Sprintf("..%c%s", filepath.Separator, filepath.Base(context))
       fmt.Printf("relativeContext = %#v\n", relativeContext)

      helper.CmdShouldPass("odo", append(args, "create", "java:8", "sb-jar-test", "--project",
             project, "--binary", filepath.Join(context, "sb.jar"), "--context", relativeContext)...)
      helper.ValidateLocalCmpExist(relativeContext, "Type,java:8", "Name,sb-jar-test")
})

Actual behavior

[oc] 'Running odo with args [odo component create java:8 sb-jar-test --project hkanwitwml --binary 
/var/folders/c9/fb55pf_568dfd1fzj9w1v4n00000gn/T/640472875/sb.jar --context ../640472875]
[odo] Validation
[odo]  •  Validating component  ...
[odo]  ✗  Validating component [543ms]
[odo]  ✗  ../../../../../../../var/folders/c9/fb55pf_568dfd1fzj9w1v4n00000gn/T/640472875/sb.jar binary needs to be inside of the context directory (../640472875)

Expected behavior

Should pass

Any logs, error output, etc?

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 20, 2020
@amitkrout
Copy link
Contributor Author

Failing on macOS while running the test script.

@amitkrout amitkrout added kind/failing-test area/testing Issues or PRs related to testing, Quality Assurance or Quality Engineering priority/High Important issue; should be worked on before any other issues (except priority/Critical issue(s)). and removed kind/bug Categorizes issue or PR as related to a bug. labels Aug 20, 2020
@anandrkskd
Copy link
Contributor

I have tested the above test on linux and was not able to reproduce error, Thus it is macOS specific error, and will require access to mac environment.

@amitkrout
Copy link
Contributor Author

amitkrout commented Sep 4, 2020

This is seems to be a test script failure. I am not able to reproduce it locally. In the script --context is not pointing to the correct relative context path

Script

relativeContext := fmt.Sprintf("..%c%s", filepath.Separator, filepath.Base(context))
       fmt.Printf("relativeContext = %#v\n", relativeContext)

Failure command

[oc] 'Running odo with args [odo component create java:8 sb-jar-test --project hkanwitwml --binary 
/var/folders/c9/fb55pf_568dfd1fzj9w1v4n00000gn/T/640472875/sb.jar --context ../640472875]

NOTE: It passes on windows and Linux

@girishramnani girishramnani added priority/Medium Nice to have issue. Getting it done before priority changes would be great. and removed priority/High Important issue; should be worked on before any other issues (except priority/Critical issue(s)). labels Sep 14, 2020
@prietyc123
Copy link
Contributor

prietyc123 commented Oct 4, 2020

@anandrkskd We have got mini mac in our test lab, I think you can use that to fix this. However I have installed the minimal setup on that machine, so there shouldn't be any issue for you. We need to fix this for running periodic tests successfully on macOS without any blocker.

@anandrkskd
Copy link
Contributor

@prietyc123 can't we use absolute path instead of using relative path in our test, are there any negative side to it?

@prietyc123
Copy link
Contributor

@prietyc123 can't we use absolute path instead of using relative path in our test, are there any negative side to it?

@anandrkskd It's not about the negative side of it, If you see https://github.com/openshift/odo/blob/master/tests/integration/component.go#L304 the scope of the tests spec itself is relative path and that is one of the scenario we need to validate.

@anandrkskd
Copy link
Contributor

This issue on mac is not due to wrong relativeContext but from where the test are ran, commonVar.Context in our code create random directory in /var/.../--(random dir) but while the test are ran it is executed in /private/var/.../--(random dir) which contains exact same files. This may be caused due to ginkgo as in tests there is no mention of commonVar.Context dir creation under /private/and the tests are using ginkgo.

The logs here shows Prenent working dir for the test as /private/var/folders/4t/1v3n1n653cxfm09gwyd7dwdw0000gn/T/943289648 and the contextdir that was actually passed was /var/folders/4t/1v3n1n653cxfm09gwyd7dwdw0000gn/T/943289648

relativeContext = "../943289648"
pwd: /private/var/folders/4t/1v3n1n653cxfm09gwyd7dwdw0000gn/T/943289648 contextdir: /var/folders/4t/1v3n1n653cxfm09gwyd7dwdw0000gn/T/943289648
Created dir: /var/folders/4t/1v3n1n653cxfm09gwyd7dwdw0000gn/T/943289648
Creating a new project: wvgvaphxaz
Running odo with args [odo project create wvgvaphxaz -w -v4]
[odo] I1021 15:02:55.566395   15894 util.go:730] HTTPGetRequest: https://raw.githubusercontent.com/openshift/odo/master/build/VERSION
[odo] I1021 15:02:55.566625   15894 util.go:751] Response will be cached in /var/folders/4t/1v3n1n653cxfm09gwyd7dwdw0000gn/T/odohttpcache for 1h0m0s
[odo]  •  Waiting for project to come up  ...
[odo] I1021 15:02:58.098114   15894 occlient.go:529] Status of creation of project wvgvaphxaz is Active
[odo] I1021 15:02:58.098134   15894 occlient.go:534] Project wvgvaphxaz now exists
[odo] I1021 15:02:58.377376   15894 namespace.go:181] Status of creation of service account &ServiceAccount{ObjectMeta:{default  wvgvaphxaz /api/v1/namespaces/wvgvaphxaz/serviceaccounts/default 9b64840f-f9f4-4888-a480-7abd6c82e98f 41996 0 2020-10-21 15:02:56 +0530 IST <nil> <nil> map[] map[] [] []  []},Secrets:[]ObjectReference{ObjectReference{Kind:,Namespace:,Name:default-token-bxvg8,UID:,APIVersion:,ResourceVersion:,FieldPath:,},ObjectReference{Kind:,Namespace:,Name:default-dockercfg-zsslw,UID:,APIVersion:,ResourceVersion:,FieldPath:,},},ImagePullSecrets:[]LocalObjectReference{LocalObjectReference{Name:default-dockercfg-zsslw,},},AutomountServiceAccountToken:nil,} is ready
 ✓  Waiting for project to come up [3s]
[odo]  ✓  Project 'wvgvaphxaz' is ready for use
[odo]  ✓  New project created and now using project: wvgvaphxaz
[odo] I1021 15:02:58.382082   15894 odo.go:72] Could not get the latest release information in time. Never mind, exiting gracefully :)
Current working dir: /Users/qetest/go/src/github.com/openshift/odo/tests/integration
Setting KUBECONFIG=/var/folders/4t/1v3n1n653cxfm09gwyd7dwdw0000gn/T/943289648/config
Setting current dir to: /var/folders/4t/1v3n1n653cxfm09gwyd7dwdw0000gn/T/943289648
Running oc with args [oc get is -n openshift -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}']
[oc] 'apicast-gateway
[oc] apicurito-ui
.
.
.
[oc] 'Running odo with args [odo create --s2i java:8 sb-jar-test --project wvgvaphxaz --binary /var/folders/4t/1v3n1n653cxfm09gwyd7dwdw0000gn/T/943289648/sb.jar --context ../943289648]
[odo] Validation
[odo]  •  Validating component  ...
[odo]  ✗  Validating component [600ms]
[odo]  ✗  ../../../../../../../var/folders/4t/1v3n1n653cxfm09gwyd7dwdw0000gn/T/943289648/sb.jar binary needs to be inside of the context directory (../943289648)
Deleting project: wvgvaphxaz
Running odo with args [odo project delete wvgvaphxaz -f]
[odo]  ✓  Deleted project : wvgvaphxaz
[odo]  ⚠  Warning! Projects are deleted from the cluster asynchronously. Odo does its best to delete the project. Due to multi-tenant clusters, the project may still exist on a different node.
Setting current dir to: /Users/qetest/go/src/github.com/openshift/odo/tests/integration

------------------------------
• Failure [18.671 seconds]
odo component command tests
/Users/qetest/go/src/github.com/openshift/odo/tests/integration/cmd_cmp_test.go:13
  Creating component
  /Users/qetest/go/src/github.com/openshift/odo/tests/integration/component.go:47
    binary component is valid if path is relative and includes ../ [It]
    /Users/qetest/go/src/github.com/openshift/odo/tests/integration/component.go:295

    No future change is possible.  Bailing out early after 4.837s.
    Running odo with args [odo create --s2i java:8 sb-jar-test --project wvgvaphxaz --binary /var/folders/4t/1v3n1n653cxfm09gwyd7dwdw0000gn/T/943289648/sb.jar --context ../943289648]
    Expected
        <int>: 1
    to match exit code:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Issues or PRs related to testing, Quality Assurance or Quality Engineering priority/Medium Nice to have issue. Getting it done before priority changes would be great.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants