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 --port setting #13288

Conversation

zeripath
Copy link
Contributor

Unfortunately there was an error in #13195 which set the --port
option before the settings were read. This PR fixes this by
moving applying this option to after the the settings are read

However, on looking further into this code I believe that the setPort
code was slightly odd.

Firstly, it may make sense to run the install page on a different
temporary port to the full system and this should be possible with
a --install-port option.

Secondy, if the --port option is provided we should apply it to both
otherwise there will be unusual behaviour on graceful restart

Thirdly, the documentation for --port says that the setting is
temporary - it should therefore not save its result to the configuration

(This however, does mean that authorized_keys and internal links may
not be correct. - I think we need to discuss this option further.)

Fix #13277

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

Unfortunately there was an error in go-gitea#13195 which set the --port
option before the settings were read. This PR fixes this by
moving applying this option to after the the settings are read

However, on looking further into this code I believe that the setPort
code was slightly odd.

Firstly, it may make sense to run the install page on a different
temporary port to the full system and this should be possible with
a --install-port option.

Secondy, if the --port option is provided we should apply it to both
otherwise there will be unusual behaviour on graceful restart

Thirdly, the documentation for --port says that the setting is
temporary - it should therefore not save its result to the configuration

(This however, does mean that authorized_keys and internal links may
not be correct. - I think we need to discuss this option further.)

Fix go-gitea#13277

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath added this to the 1.14.0 milestone Oct 24, 2020
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 24, 2020
cmd/web.go Outdated
Comment on lines 193 to 196

if err := cfg.SaveTo(setting.CustomConf); err != nil {
return fmt.Errorf("Error saving generated JWT Secret to custom config: %v", err)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

--port states that it is temporary so it shouldn't write to the ini...

however, this is going to break gitea serv, admin, manager etc. I just don't know what to do here.

In terms of doing a pure bugfix for the linked Issue only this change should be dropped but it's really hard to know what to do here.

@codecov-io
Copy link

codecov-io commented Oct 24, 2020

Codecov Report

Merging #13288 into master will decrease coverage by 0.05%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13288      +/-   ##
==========================================
- Coverage   42.16%   42.11%   -0.06%     
==========================================
  Files         685      689       +4     
  Lines       75571    75851     +280     
==========================================
+ Hits        31867    31947      +80     
- Misses      38482    38669     +187     
- Partials     5222     5235      +13     
Impacted Files Coverage Δ
cmd/web.go 0.00% <0.00%> (ø)
modules/storage/helper.go 22.72% <0.00%> (-31.82%) ⬇️
cmd/cmd.go 17.85% <0.00%> (-13.40%) ⬇️
modules/indexer/stats/db.go 52.17% <0.00%> (-8.70%) ⬇️
modules/git/utils.go 73.77% <0.00%> (-3.28%) ⬇️
services/mirror/mirror.go 16.17% <0.00%> (-2.35%) ⬇️
models/topic.go 65.74% <0.00%> (-1.13%) ⬇️
modules/queue/workerpool.go 59.18% <0.00%> (-0.82%) ⬇️
modules/migrations/github.go 80.19% <0.00%> (-0.61%) ⬇️
modules/git/repo.go 46.19% <0.00%> (-0.51%) ⬇️
... and 22 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 0800c7e...42e97aa. Read the comment docs.

@@ -40,6 +40,7 @@ Starts the server:

- Options:
- `--port number`, `-p number`: Port number. Optional. (default: 3000). Overrides configuration file.
- `--install-port number`: Port number to run the install page on. Optional. (default: 3000). Overrides configuration file.
Copy link
Member

Choose a reason for hiding this comment

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

I think this change could be another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's part of the fix really.

If you make --port apply both before the install page and after the install page then the PORT option in the install page is irrelevant and it is overwritten.

If you make --port only apply once then if there is a graceful restart after install the port that gitea runs on will change.

If you make --port only apply to the install page then that may change behaviour for other people.

In this case the only solution is provide a separate option for the install page then you can have a consistent solution.

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.

fix it

@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 Oct 27, 2020
cmd/web.go Show resolved Hide resolved
cmd/web.go Outdated Show resolved Hide resolved
cmd/web.go Outdated Show resolved Hide resolved
@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 Oct 30, 2020
@techknowlogick
Copy link
Member

🚀

@techknowlogick techknowlogick merged commit dd12384 into go-gitea:master Oct 30, 2020
@zeripath zeripath deleted the fix-13277-agh-set-port-once-read-setting branch October 30, 2020 19:26
@go-gitea go-gitea locked and limited conversation to collaborators Dec 14, 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/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gitea --port rewrites app.ini on it's own, breaks SSH access, API not working & no error logged.
6 participants