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

nixos/gitea: add WORK_PATH to config, fix 1.20 #241497

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

bendlas
Copy link
Contributor

@bendlas bendlas commented Jul 4, 2023

Description of changes

Gitea and Forgejo 1.20 need a config option WORK_PATH set and will try to update the config file, which will fail on NixOS where the config is read-only.

Also add myself as maintainer to forgejo

TODO: Either test this with 1.19 or wait for 1.20 to be released before merging this.

DONE: Tested together with 1.19.4-0 from #241777

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

this is in preparation for 1.20, which needs this option set
Copy link
Member

@emilylange emilylange left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

But would you mind changing your gitea: add bendlas to maintainers commit message to forgejo: add bendlas to maintainers? :)

@bendlas
Copy link
Contributor Author

bendlas commented Jul 4, 2023

But would you mind changing your gitea: add bendlas to maintainers commit message to forgejo: add bendlas to maintainers? :)

oof yes, done, thanks!

@SuperSandro2000 SuperSandro2000 marked this pull request as draft July 4, 2023 22:15
@@ -15,6 +15,7 @@ let
APP_NAME = ${cfg.appName}
RUN_USER = ${cfg.user}
RUN_MODE = prod
WORK_PATH = ${cfg.stateDir}
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 was wondering if it wouldn't be worth pulling up the extraConfig line (${optionalString (cfg.extraConfig != null) cfg.extraConfig}) to before the main settings section.

That way, a non-sectioned setting like WORK_PATH could be added via extraConfig as well. Right now such a setting would get assigned randomly to whatever the last settings section turned out to be, right?

Do you see any trade-offs here, @emilylange?

Copy link
Member

Choose a reason for hiding this comment

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

From go-gitea/gitea#25330

The "work path" priority is: WORK_PATH in app.ini > cmd arg --work-path > env var GITEA_WORK_DIR > builtin default

We seem to be doing something similar with GITEA_WORK_DIR at

GITEA_WORK_DIR = cfg.stateDir;

and
GITEA_WORK_DIR = cfg.stateDir;

Assuming the env var does not try to update the specified app.ini, this might be a more suitable place.
Or, alternatively, a lib.mkDefaulted WORK_PATH = cfg.stateDir in config similar to

services.gitea.settings = {
"cron.update_checker".ENABLED = lib.mkDefault false;

I don't know why one would want to manually override WORK_PATH when using the module, but ehh, maybe there are use-cases.
And both solutions would allow for that :)

I don't see much value changing the order of the freeform settings option and extraConfig.
But maybe I just don't quite get what you mean with that^^

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 don't really know what's going on either. If there is no WORK_PATH in app.ini, it will try to add it (possibly from that env var you're mentioning). That will fail when app.ini is read-only.

Maybe that could be considered a bug upstream, but I wanted to leave this here, so that we already know when doing the update.

Copy link
Contributor Author

@bendlas bendlas Jul 9, 2023

Choose a reason for hiding this comment

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

I don't see much value changing the order of the freeform settings option and extraConfig.
But maybe I just don't quite get what you mean with that^^

What I meant is: I couldn't add the WORK_PATH through extra config, because:

UNSECTIONED_CONFIG1 = value1

[section1]
SECTION_CONFIG = value2

EXTRA_CONFIG = value3

here, EXTRA_CONFIG = value3 would be considered part of [section1], even though it's meant to be unsectioned. There is also no code that could reasonably rely on this behavior, since the order of sections is essentially random and so the section that an unsectioned extraConfig is assigned to would also be random.

Also I don't think there is a way to denote a "non-section" in order to add more unsectioned values, so in my books moving the extraConfig up would be strictly an improvement, because it would allow adding unsectioned values at all.

Copy link
Member

Choose a reason for hiding this comment

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

TLDR but extraConfig is deprecated and we should remove it rather sooner than later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know.

Do our .ini config helpers do the unsectioned preamble?

@bendlas bendlas requested a review from emilylange July 6, 2023 12:45
@bendlas bendlas marked this pull request as ready for review July 6, 2023 12:45
@SuperSandro2000
Copy link
Member

gitea 1.20 is not released yet, drafting again

@SuperSandro2000 SuperSandro2000 marked this pull request as draft July 13, 2023 14:57
@SuperSandro2000 SuperSandro2000 mentioned this pull request Jul 17, 2023
12 tasks
@bendlas
Copy link
Contributor Author

bendlas commented Jul 17, 2023

Not needed, see #243883

@bendlas bendlas closed this Jul 17, 2023
@ghost
Copy link

ghost commented Jul 23, 2023

Huh, why was this closed? I ran into this issue today after updating and after finding this PR and locking the nixpkgs to the ref of #243883 (b61919e) the issue still happens so I think this is still needed, unless I'm missing something. Either that or remove the restriction of settings that you cant have top level non dict entries in there.

@emilylange
Copy link
Member

I assume you are using Forgejo via services.gitea.packages and your systemd service is restarting every 90 seconds?

If so, the commit in question (b61919e) has been reverted in #244843 and should land in nixos-unstable-small and nixos-unstable shortly, which should solves this.
See https://nixpk.gs/pr-tracker.html?pr=244843
and #243883 (comment)

Also, on a related note:
Forgejo will split out of nixos/gitea (a new services.forgejo) soon, which hopefully prevents such issues in the future.
See #244866

@ghost
Copy link

ghost commented Jul 23, 2023

No, Im using just gitea and the issue i have is gitea wanting to set the missing WORK_PATH variable in its config, but failing because its read-only and aborting immediately.

Jul 23 10:56:50 patchouli gitea[1129269]: 2023/07/23 10:56:46 cmd/web.go:170:serveInstalled() [E] Unable to update WORK_PATH=/var/lib/gitea to config "/var/lib/gitea/custom/conf/app.ini": failed to save "/var/lib/gitea/custom/conf/app.ini": open /var/lib/gitea/custom/conf/app.ini: permission denied
Jul 23 10:56:50 patchouli gitea[1129269]: You must set it manually, otherwise there might be bugs when accessing the git repositories.

Which is also why im so confused this got closed in favour of #244843 because I dont see said fix there or a mention in the upstream changelog that the behaviour changed, i dont think the service type has anything to do with what this PR originally fixed?

EDIT: as i was removing a deprecated entry from gitea.settings it still gives me that error but now stays active (so more of a warning i suppose) so im guessing this didnt cause the crash but using a deprecated setting ([indexer].UPDATE_BUFFER_LEN) did? Works for me i suppose

@emilylange
Copy link
Member

Alright, sorry^^

@bendlas
Copy link
Contributor Author

bendlas commented Jul 23, 2023

Huh, why was this closed? I ran into this issue today after updating and after finding this PR and locking the nixpkgs to the ref of #243883 (b61919e) the issue still happens so I think this is still needed, unless I'm missing something. Either that or remove the restriction of settings that you cant have top level non dict entries in there.

I was assuming that since @Ma27 has been successfully running the updated version, that this change here was not needed after all and did not try myself yet #243883 (comment)

I'll re-open until we figured out what's going on.

@Ma27 can you comment: do you have WORK_PATH = /var/lib/gitea in your /var/lib/gitea/custom/conf/app.ini?

@bendlas bendlas reopened this Jul 23, 2023
@bendlas bendlas changed the title Prepare config for gitea 1.20 nixos/gitea: add WORK_PATH to config, fix 1.20 Jul 23, 2023
@Ma27
Copy link
Member

Ma27 commented Jul 23, 2023

🤦

Oof... I really feel like being struck my Murphy's law re gitea this weekend /o\

tl;dr I get the same warning in my logs, so this PR is indeed needed. Please resolve the conflict in pkgs.forgejo and let CI run one more time, then we should be good to go with this.

First of all, apologies! Let me explain why I missed this:

  • I haven't seen it in the changelogs and with gitea: 1.19.4 -> 1.20.0 #243883 both the tests and my own instance were operating normally and as I'd expect it and I haven't missed the log-line because of that.
  • I misinterpreted the conversation about this issue in gitea: 1.19.4 -> 1.20.0 #243883 as hard crash of gitea and not as log entry which is why I (wrongly) assumed this issue to be resolved. Considering the "there may be bugs" warning we should definitely fix it. Also, I assumed a noticeable problem because I got bitten by a different settings issue as well (CHUNKED_UPLOAD_PATH) so I was fixed on another similar issue.

This is just an explanation, but I won't sugar-coat it, missing that issue was clearly my mistake!

@maddiethecafebabe just to make sure I'm not misunderstanding you: currently your gitea runs fine and the only issue you see is this error in the logs, correct? If that's the case (and no other problems can be observed) then it should be OK to await the next channel bump with this PR included (I'm running gitea for almost a week now without any issues). If you don't want to do that - which is perfectly fine of course: do you need assistance with adding unmerged nixpkgs patches to your deployment or can you do that on your own?

@ghost
Copy link

ghost commented Jul 23, 2023

No worries! Yeah, the log message is marked as an error [E] but it seems to be really just a warning so indeed not urgently, it was something else that caused the crash for me that is now fixed. Thanks yall for looking into it again so quickly

@bendlas bendlas marked this pull request as ready for review July 23, 2023 16:52
@bendlas
Copy link
Contributor Author

bendlas commented Jul 23, 2023

I remember it going into a restart loop, but that was also an earlier RC.

Merge conflict resolved.

Copy link
Member

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

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

Sorry, forgot that this is still open 🤦

@Ma27 Ma27 merged commit ed02e79 into NixOS:master Aug 4, 2023
18 checks passed
@bendlas bendlas deleted the prepare-gitea-120 branch October 22, 2023 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants