ingress-nginx icon indicating copy to clipboard operation
ingress-nginx copied to clipboard

add --global flag to git --add safe.directory command"

Open longwuyuan opened this issue 3 years ago • 3 comments

  • Currently make dev-env is broken if run on Intel Mac and being tracked in https://github.com/kubernetes/ingress-nginx/issues/8879
  • But there is another minor bug in the build.sh. Described below
  • Since git 2.35.2, git warns about a directory being unsafe. Its explained here https://stackoverflow.com/questions/71901632/fatal-error-unsafe-repository-home-repon-is-owned-by-someone-else . This was not happening before. This is breaking builds when run in DIND. Because the user that did the checkout will be random user
  • The fix was already merged in https://github.com/kubernetes/ingress-nginx/pull/8804 but without the --global flag
  • This PR adds the --global flag as absense of this flag is breaking make image on laptop/local
  • But adding the --global flag breaks CI tests as the .gitconfig in the $HOME of user running PROW job is not writable by user running job

/triage accepted /area stabilization /assign @strongjz @tao12345666333

/priority important-soon

longwuyuan avatar Jul 27 '22 19:07 longwuyuan

/ok-to-test

strongjz avatar Jul 27 '22 19:07 strongjz

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: longwuyuan Once this PR has been reviewed and has the lgtm label, please ask for approval from strongjz by writing /assign @strongjz in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Jul 27 '22 19:07 k8s-ci-robot

The same make build target executing the file build.sh runs with different user-id in CI when compared to running as part of make dev-env on Intel MacOS using Colima.

In CI it looks like this ;

+ git version
[299](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:300)
git version 2.32.2
[300](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:301)
++ git config safe.directory
[301](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:302)
+ echo 'Value in gitSafeDir = '
[302](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:303)
Value in gitSafeDir = 
[303](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:304)
++ git config safe.directory
[304](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:305)
+ [[ '' == *ingress-nginx* ]]
[305](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:306)
+ echo 'safedir is not set'
[306](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:307)
safedir is not set
[307](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:308)
+ pwd
[308](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:309)
/go/src/k8s.io/ingress-nginx
[309](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:310)
+ ls -ltha
[310](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:311)
total 664K   
[311](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:312)
drwxr-xr-x    3 root     root        4.0K Jul 28 13:15 ..
[312](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:313)
drwxr-xr-x   17 1001     121         4.0K Jul 28 13:14 .
[313](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:314)
drwxr-xr-x    3 1001     121         4.0K Jul 28 13:14 bin
[314](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:315)
drwxr-xr-x    8 1001     121         4.0K Jul 28 13:14 .git
[315](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:316)
drwxr-xr-x   13 1001     121         4.0K Jul 28 13:14 images
[316](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:317)
drwxr-xr-x    8 1001     121         4.0K Jul 28 13:14 internal
[317](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:318)
-rw-r--r--    1 1001     121         4.8K Jul 28 13:14 mkdocs.yml
[318](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:319)
drwxr-xr-x    7 1001     121         4.0K Jul 28 13:14 pkg
[319](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:320)
drwxr-xr-x    3 1001     121         4.0K Jul 28 13:14 rootfs
[320](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:321)
drwxr-xr-x    7 1001     121         4.0K Jul 28 13:14 test
[321](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:322)
drwxr-xr-x    2 1001     121         4.0K Jul 28 13:14 version
[322](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:323)
drwxr-xr-x    5 1001     121         4.0K Jul 28 13:14 .github
[323](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:324)
-rw-r--r--    1 1001     121          758 Jul 28 13:14 .gitignore
[324](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:325)
-rw-r--r--    1 1001     121          317 Jul 28 13:14 .luacheckrc
[325](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:326)
-rw-r--r--    1 1001     121            0 Jul 28 13:14 32
[326](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:327)
-rw-r--r--    1 1001     121         3.8K Jul 28 13:14 CONTRIBUTING.md
[327](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:328)
-rw-r--r--    1 1001     121       358.3K Jul 28 13:14 Changelog.md
[328](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:329)
-rw-r--r--    1 1001     121        10.4K Jul 28 13:14 ISSUE_TRIAGE.md
[329](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:330)
-rw-r--r--    1 1001     121        11.1K Jul 28 13:14 LICENSE
[330](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:331)
-rw-r--r--    1 1001     121         8.0K Jul 28 13:14 Makefile
[331](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:332)
-rw-r--r--    1 1001     121          149 Jul 28 13:14 NGINX_BASE
[332](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:333)
-rw-r--r--    1 1001     121          226 Jul 28 13:14 OWNERS
[333](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:334)
-rw-r--r--    1 1001     121          653 Jul 28 13:14 OWNERS_ALIASES
[334](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:335)
-rw-r--r--    1 1001     121         5.7K Jul 28 13:14 README.md
[335](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:336)
-rw-r--r--    1 1001     121        15.2K Jul 28 13:14 RELEASE.md
[336](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:337)
-rw-r--r--    1 1001     121         1.0K Jul 28 13:14 SECURITY.md
[337](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:338)
-rw-r--r--    1 1001     121          539 Jul 28 13:14 SECURITY_CONTACTS
[338](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:339)
-rw-r--r--    1 1001     121            7 Jul 28 13:14 TAG
[339](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:340)
drwxr-xr-x    2 1001     121         4.0K Jul 28 13:14 build
[340](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:341)
drwxr-xr-x    3 1001     121         4.0K Jul 28 13:14 charts
[341](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:342)
-rw-r--r--    1 1001     121          662 Jul 28 13:14 cloudbuild.yaml
[342](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:343)
drwxr-xr-x    7 1001     121         4.0K Jul 28 13:14 cmd
[343](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:344)
-rw-r--r--    1 1001     121          148 Jul 28 13:14 code-of-conduct.md
[344](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:345)
drwxr-xr-x    5 1001     121         4.0K Jul 28 13:14 deploy
[345](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:346)
drwxr-xr-x    8 1001     121         4.0K Jul 28 13:14 docs
[346](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:347)
-rw-r--r--    1 1001     121         7.0K Jul 28 13:14 go.mod
[347](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:348)
-rw-r--r--    1 1001     121       114.4K Jul 28 13:14 go.sum
[348](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:349)
drwxr-xr-x    4 1001     121         4.0K Jul 28 13:14 hack
[349](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:350)
+ id
[350](https://github.com/kubernetes/ingress-nginx/runs/7560687230?check_suite_focus=true#step:8:351)
uid=1001 gid=121

On Intel MacOS with Colima, it looks like this ;

+ git version
git version 2.32.2
++ git config safe.directory
+ echo 'Value in gitSafeDir = '
Value in gitSafeDir = 
++ git config safe.directory
+ [[ '' == *ingress-nginx* ]]
+ echo 'safedir is not set'
safedir is not set
+ pwd
/go/src/k8s.io/ingress-nginx
+ ls -ltha
total 668K   
drwxr-xr-x    1 503      dialout     1.2K Jul 28 13:10 .
drwxr-xr-x    3 root     root        4.0K Jul 28 13:10 ..
drwxr-xr-x    1 503      dialout       96 Jul 28 13:10 bin
drwxr-xr-x    1 503      dialout      480 Jul 28 13:10 .git
drwxr-xr-x    1 503      dialout      288 Jul 28 13:10 build
-rw-r--r--    1 503      dialout        0 Jul 28 08:20 32
drwxr-xr-x    1 503      dialout      320 Jul 27 18:04 rootfs
-rw-r--r--    1 503      dialout     8.0K Jul 27 09:56 Makefile
-rw-r--r--    1 503      dialout     7.0K Jul 27 09:56 go.mod
-rw-r--r--    1 503      dialout   114.4K Jul 27 09:56 go.sum
-rw-r--r--    1 503      dialout      149 Jul 24 16:54 NGINX_BASE
drwxr-xr-x    1 503      dialout      672 Jul 24 16:54 hack
drwxr-xr-x    1 503      dialout      320 Jul 23 16:42 .modcache
drwxr-xr-x    1 503      dialout      224 Jul 23 12:10 .github
-rw-r--r--    1 503      dialout      758 Jul 23 12:10 .gitignore
-rw-r--r--    1 503      dialout      317 Jul 23 12:10 .luacheckrc
-rw-r--r--    1 503      dialout     3.8K Jul 23 12:10 CONTRIBUTING.md
-rw-r--r--    1 503      dialout   358.3K Jul 23 12:10 Changelog.md
-rw-r--r--    1 503      dialout    10.4K Jul 23 12:10 ISSUE_TRIAGE.md
-rw-r--r--    1 503      dialout    11.1K Jul 23 12:10 LICENSE
-rw-r--r--    1 503      dialout      226 Jul 23 12:10 OWNERS
-rw-r--r--    1 503      dialout      653 Jul 23 12:10 OWNERS_ALIASES
-rw-r--r--    1 503      dialout     5.7K Jul 23 12:10 README.md
-rw-r--r--    1 503      dialout    15.2K Jul 23 12:10 RELEASE.md
-rw-r--r--    1 503      dialout     1.0K Jul 23 12:10 SECURITY.md
-rw-r--r--    1 503      dialout      539 Jul 23 12:10 SECURITY_CONTACTS
-rw-r--r--    1 503      dialout        7 Jul 23 12:10 TAG
drwxr-xr-x    1 503      dialout       96 Jul 23 12:10 charts
-rw-r--r--    1 503      dialout      662 Jul 23 12:10 cloudbuild.yaml
drwxr-xr-x    1 503      dialout      224 Jul 23 12:10 cmd
-rw-r--r--    1 503      dialout      148 Jul 23 12:10 code-of-conduct.md
drwxr-xr-x    1 503      dialout      192 Jul 23 12:10 deploy
drwxr-xr-x    1 503      dialout      480 Jul 23 12:10 docs
drwxr-xr-x    1 503      dialout      480 Jul 23 12:10 images
drwxr-xr-x    1 503      dialout      256 Jul 23 12:10 internal
-rw-r--r--    1 503      dialout     4.8K Jul 23 12:10 mkdocs.yml
drwxr-xr-x    1 503      dialout      224 Jul 23 12:10 pkg
drwxr-xr-x    1 503      dialout      288 Jul 23 12:10 test
drwxr-xr-x    1 503      dialout       96 Jul 23 12:10 version
+ id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)
+ whoami
root
+ git status
fatal: unsafe repository ('/go/src/k8s.io/ingress-nginx' is owned by someone else)
To add an exception for this directory, call:

        git config --global --add safe.directory /go/src/k8s.io/ingress-nginx
make[1]: *** [build] Error 128
make: *** [dev-env] Error 2

longwuyuan avatar Jul 28 '22 13:07 longwuyuan

@longwuyuan: PR needs rebase.

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.

k8s-ci-robot avatar Sep 03 '22 05:09 k8s-ci-robot