fix: windows compilation #1101
No reviewers
Labels
No labels
FreeBSD
Kind/Breaking
Kind/Bug
Kind/Chore
Kind/DependencyUpdate
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
Windows
linux-powerpc64le
linux-riscv64
linux-s390x
run-end-to-end-tests
run-forgejo-tests
run-multi-platform-tests
No milestone
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
forgejo/runner!1101
Loading…
Reference in a new issue
No description provided.
Delete branch ":fix-windows-compilation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original pull request: #987
Fixes #1032
thanks for picking it up 😁
before I suggest things, how familiar are you with Go?
just enough to compile a project, but I'm ready to learn
I read your comments from the original pull request, but unfortunately, I only just now looked at util.go. I'll try to adjust the code accordingly.
I'm stuck at the same point as AnsisMalins. Since build tags seem to be file level only, I don't know how to handle this without creating a new utils.go in artifactscache containing only the suicide function. otherwise I have to duplicate all non platform specific code of handler.go to handler_windows.go. and as I understand it you said no to both options.
The way I understand @earl-warren comment is that they want to end with this situation:
act/artifactcache/util.goact/artifactcache/util_windows.goThat being said, I have some questions regarding original design here: Is the intention really to kill entire runner when cache servers encounters fatal error? Somehow that feels a bit extreme, though, as we are failing hard on conditions such as unable to read cache.
Imagine situation where artifact cache is mounted to NFS volume that is temporarily unavailable - I wouldn't want it to kill runner, just gracefully handle the fact that cache doesn't exist and pretend we didn't get hit instead, while logging error for operator.
@proton-ab wrote in #1101 (comment):
Exactly!
The policy is to failing hard in case an error is not recoverable, i.e. there is no way to ensure the runner will keep working as it should. If you think it could be done differently could you please open a feature request or a discussion? This a design question that has a wider scope than this pull request.
Alright, then I misunderstood the comment in the original pull request.
Code has been changed as requested.
//go:build windowsotherwise it will have suicide() defined twice
I just tested it and it's defined twice with 'windows'
sorry missed the file name. but in container utils_windows.go there is no such declaration. and it compiles fine without.
I'm very confused now. It passed CI but... how can it compile when the function is effectively declared twice if not on windows.
There is something trivial I don't see. 🤔
I'm not used to Go, but my wild guess was that '_windows' in the file name must be interpreted as build tag automaticaly.
@earl-warren so do you still want me to add the build tag to the file content or is it fine via file name?
I have to say I absolutely do not understand how that works as it is. I would need to research why it compiles before I can give an opinion. If you find the answer this can move on. Otherwise it is a mystery blocking my review I'm afraid. I will eventually take the time to figure it out but not right now.
https://pkg.go.dev/cmd/go#hdr-Build_constraints
thanks!
So... having one file named
act/artifactcache/utils_windows.goand the otheract/artifactcache/utils_linux.gowith no//go:build ...should work fine, right?Usually
_unixis the opposite of_windows, I think. Keeps the BSDs happy. Otherwise, yes.Right... my head is elsewhere, I'm a poor reviewer right now, thanks for fixing my mistakes.
//go:build !windowsand
//go:build windowsis what I had in memory. I now understand the build tag and the special name termination are redundant, reason why it worked here, with the right mixture of name termination and build tag.
I think it is best how it is done (and done in container/utils.go).
You need different file names anyway but if you would use only file names you have to create one for every platform. So having a default file which excludes by comment and other files which include by name makes sense to me.
If it's done with comments to always do it the same way I would't use _windows in the file name. But that's just my opinion.
The mixture of build tags and file name extension confused me. Please choose one or the other. If I was confused... others will I'm sure.
Do you want separate PR to change it in
container/utils.gotoo?Alright, I added the built tag comment to utils_windows.go
Thanks everyone for your patience. I learned something valuable 😁
I can only agree with that 😃
Thanks for having this merged even though Windows isn't officially supported here.
The general idea is that windows specific (or other proprietary OS) can be included as long as they are sandboxed in a clear way.
It would be very useful if you could you weigh in on the request to make room to prepare for such patches in a windows dedicated repository https://github.com/Crown0815/Forgejo-runner-windows-builder/issues/5 🙏
@Crown0815 FYI