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

Multiple Gitea Doctor improvements #10943

Merged
merged 16 commits into from
Apr 6, 2020

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented Apr 3, 2020

  • Add gitea doctor --list flag to list the checks that will be run, including those by default
  • Add gitea doctor --run to run specific checks
  • Add gitea doctor --all to run all checks
  • Add db version checker
  • Add non-default recalculate merge bases check/fixer to doctor
  • Add hook checker (Fix [Feature] for doctor framewrok #9878) and ensure hooks are executable (Fix "Resynchronize pre-receive, update and post-receive hooks" should explicitly set executable bit #6319)
  • Fix authorized_keys checker - slight change of functionality here because parsing the command is fragile and we should just check if the authorized_keys file is essentially the same as what gitea would produce. (This is still not perfect as order matters - we should probably just md5sum the two files.)
  • Add SCRIPT_TYPE check (Fix [Feature] Doctor check if SCRIPT_TYPE is available (default: bash) #10977)
  • Add gitea doctor --fix to attempt to fix what is possible to easily fix
  • Add gitea doctor --log-file to set the log-file, be it a file, stdout or to switch off completely. (Fixes previously undetected bug with certain xorm logging configurations - see @6543 comment.)

Signed-off-by: Andrew Thornton art27@cantab.net

Add recalculate merge bases check/fixer to doctor
Add functionality for doctor only run certain checks

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath added type/feature Completely new functionality. Can only be merged if feature freeze is not active. backport/v1.11 labels Apr 3, 2020
@zeripath zeripath added this to the 1.12.0 milestone Apr 3, 2020
Copy link
Member

@jolheiser jolheiser left a comment

Choose a reason for hiding this comment

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

Few questions

cmd/doctor.go Show resolved Hide resolved
cmd/doctor.go Outdated Show resolved Hide resolved
cmd/doctor.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 3, 2020
Signed-off-by: Andrew Thornton <art27@cantab.net>
@codecov-io
Copy link

codecov-io commented Apr 3, 2020

Codecov Report

Merging #10943 into master will decrease coverage by 0.13%.
The diff coverage is 8.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10943      +/-   ##
==========================================
- Coverage   43.63%   43.50%   -0.14%     
==========================================
  Files         597      597              
  Lines       83923    84176     +253     
==========================================
  Hits        36619    36619              
- Misses      42794    43041     +247     
- Partials     4510     4516       +6     
Impacted Files Coverage Δ
cmd/doctor.go 0.00% <0.00%> (ø)
models/migrations/migrations.go 3.50% <0.00%> (-0.67%) ⬇️
modules/repository/hooks.go 20.45% <23.17%> (-14.94%) ⬇️
models/ssh_key.go 50.28% <54.54%> (-0.15%) ⬇️
modules/indexer/stats/queue.go 62.50% <0.00%> (-18.75%) ⬇️
modules/indexer/stats/db.go 40.62% <0.00%> (-9.38%) ⬇️
modules/git/utils.go 65.67% <0.00%> (-4.48%) ⬇️
services/pull/patch.go 62.93% <0.00%> (-2.80%) ⬇️
services/pull/temp_repo.go 29.05% <0.00%> (-2.57%) ⬇️
services/pull/check.go 50.00% <0.00%> (-2.44%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f072d45...600517e. Read the comment docs.

cmd/doctor.go Outdated Show resolved Hide resolved
cmd/doctor.go Outdated Show resolved Hide resolved
cmd/doctor.go Outdated Show resolved Hide resolved
cmd/doctor.go Outdated Show resolved Hide resolved
cmd/doctor.go Show resolved Hide resolved
zeripath and others added 2 commits April 4, 2020 15:53
Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath changed the title Add recalculate_merge_bases check to doctor Mulitple Gitea Doctor improvements Apr 5, 2020
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 5, 2020
cmd/doctor.go Outdated Show resolved Hide resolved
cmd/doctor.go Outdated Show resolved Hide resolved
modules/repository/hooks.go Show resolved Hide resolved
modules/repository/hooks.go Show resolved Hide resolved
modules/repository/hooks.go Show resolved Hide resolved
models/migrations/migrations.go Outdated Show resolved Hide resolved
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 5, 2020
Copy link
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

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

check-db panic's

@6543
Copy link
Member

6543 commented Apr 6, 2020

[ 2 ] Check Database Version
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6ca727]

goroutine 1 [running]:
code.gitea.io/gitea/modules/log.(*Logger).Log(0x0, 0x3, 0x2, 0x1da74e9, 0x10, 0xc00134c200, 0x1, 0x1, 0xc00133cf30, 0xc000d8b160)
        /home/6543/git/gitea/modules/log/logger.go:58 +0x37
code.gitea.io/gitea/models.(*XORMLogBridge).Log(...)
        /home/6543/git/gitea/models/log.go:31
code.gitea.io/gitea/models.(*XORMLogBridge).Infof(0xc00134c1d0, 0x1da74e9, 0x10, 0xc00134c200, 0x1, 0x1)
        /home/6543/git/gitea/models/log.go:61 +0x79
xorm.io/xorm/log.(*LoggerAdapter).Infof(0xc00134c1e0, 0x1da74e9, 0x10, 0xc00134c200, 0x1, 0x1)
        /home/6543/git/gitea/vendor/xorm.io/xorm/log/logger_context.go:76 +0x65
xorm.io/xorm.(*Session).Ping(0xc000d8b208, 0x0, 0x0)
        /home/6543/git/gitea/vendor/xorm.io/xorm/session_schema.go:25 +0xfd
xorm.io/xorm.(*Engine).Ping(0xc000247d80, 0x0, 0x0)
        /home/6543/git/gitea/vendor/xorm.io/xorm/engine.go:239 +0xcb
code.gitea.io/gitea/models.NewEngine(0x22416e0, 0xc000040128, 0x1e81340, 0x4e4f37, 0xc000f9a270)
        /home/6543/git/gitea/models/models.go:192 +0x6e
code.gitea.io/gitea/cmd.runDoctorCheckDBVersion(0xc000ff8f20, 0xc000010018, 0xc000d8b798, 0x4, 0x4, 0x1d)
        /home/6543/git/gitea/cmd/doctor.go:338 +0x49
code.gitea.io/gitea/cmd.runDoctor(0xc000ff8f20, 0x0, 0xc000ff8dc0)
        /home/6543/git/gitea/cmd/doctor.go:181 +0x7ae
github.com/urfave/cli.HandleAction(0x19f8280, 0x1e811d8, 0xc000ff8f20, 0xc0004fe800, 0x0)
        /home/6543/git/gitea/vendor/github.com/urfave/cli/app.go:490 +0xc8
github.com/urfave/cli.Command.Run(0x1d0b9da, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1db280e, 0x11, 0x0, ...)
        /home/6543/git/gitea/vendor/github.com/urfave/cli/command.go:210 +0x9e8
github.com/urfave/cli.(*App).Run(0xc0005171e0, 0xc00003c180, 0x3, 0x3, 0x0, 0x0)
        /home/6543/git/gitea/vendor/github.com/urfave/cli/app.go:255 +0x741
main.main()
        /home/6543/git/gitea/main.go:109 +0x8a3

@zeripath
Copy link
Contributor Author

zeripath commented Apr 6, 2020

@6543 was that in normal running or in a broken gitea case?

@zeripath
Copy link
Contributor Author

zeripath commented Apr 6, 2020

Nevermind I see what the problem is. @6543 I think that was already broken. I have however, fixed the logging situation.

cmd/doctor.go Outdated Show resolved Hide resolved
@zeripath zeripath merged commit d26885e into go-gitea:master Apr 6, 2020
@zeripath zeripath deleted the doctor-update-merge-base branch April 6, 2020 10:44
zeripath added a commit to zeripath/gitea that referenced this pull request Apr 6, 2020
Backport go-gitea#10943

* Add `gitea doctor --list` flag to list the checks that will be run, including those by default
* Add `gitea doctor --run` to run specific checks
* Add `gitea doctor --all` to run all checks
* Add db version checker
* Add non-default recalculate merge bases check/fixer to doctor
* Add hook checker (Fix go-gitea#9878) and ensure hooks are executable (Fix go-gitea#6319)
* Fix authorized_keys checker - slight change of functionality here because parsing the command is fragile and we should just check if the authorized_keys file is essentially the same as what gitea would produce. (This is still not perfect as order matters - we should probably just md5sum the two files.)
* Add SCRIPT_TYPE check (Fix go-gitea#10977)
* Add `gitea doctor --fix` to attempt to fix what is possible to easily fix
* Add `gitea doctor --log-file` to set the log-file, be it a file, stdout or to switch off completely. (Fixes previously undetected bug with certain xorm logging configurations - see @6543 comment.)

Signed-off-by: Andrew Thornton <art27@cantab.net>
techknowlogick pushed a commit that referenced this pull request Apr 6, 2020
…#10991)

* Mulitple Gitea Doctor improvements (#10943)

Backport #10943

* Add `gitea doctor --list` flag to list the checks that will be run, including those by default
* Add `gitea doctor --run` to run specific checks
* Add `gitea doctor --all` to run all checks
* Add db version checker
* Add non-default recalculate merge bases check/fixer to doctor
* Add hook checker (Fix #9878) and ensure hooks are executable (Fix #6319)
* Fix authorized_keys checker - slight change of functionality here because parsing the command is fragile and we should just check if the authorized_keys file is essentially the same as what gitea would produce. (This is still not perfect as order matters - we should probably just md5sum the two files.)
* Add SCRIPT_TYPE check (Fix #10977)
* Add `gitea doctor --fix` to attempt to fix what is possible to easily fix
* Add `gitea doctor --log-file` to set the log-file, be it a file, stdout or to switch off completely. (Fixes previously undetected bug with certain xorm logging configurations - see @6543 comment.)

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Switch to io.Writer instead of io.StringWriter

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath changed the title Mulitple Gitea Doctor improvements Multiple Gitea Doctor improvements May 8, 2020
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
8 participants