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

License activation failure cause exit code 0 #64

Open
erlioniel opened this issue Jan 20, 2021 · 8 comments
Open

License activation failure cause exit code 0 #64

erlioniel opened this issue Jan 20, 2021 · 8 comments
Labels
bug in unity This is a bug in unity itself (out of scope) bug Something isn't working help wanted Extra attention is needed

Comments

@erlioniel
Copy link

Bug description
If unity in the container got the wrong license activation file (or credentials, I guess, didn't check) it fails to build / test with exit code 0. Which is threatened as a successful run.

How to reproduce

  • Put to secrets wrong license (outdated, another version, etc)
  • Run pipeline

Expected behavior

  • Docker should exit with non-zero code
@erlioniel erlioniel added the bug Something isn't working label Jan 20, 2021
@erlioniel
Copy link
Author

Closed. For details - @webbertakken

@webbertakken
Copy link
Member

Thank you for reporting this issue.

This is a bug in Unity editor itself, which doesn't omit a non-zero exit code when hardware ids mismatch or in some cases where invalid licenses are given.

Workaround

Most people move past this by fixing their activation while setting up their project, since the actual build step uses proper exit codes (which you can extend yourself inside the build script).

Additional information

It's a bug that predates this very repository and has been reported in unity-actions, unity-builder and in repository of the preceeding images gableroux/unity3d and the gableroux/unity3d-gitlab-ci-example.

Since we can't rely on exit code (pre-build-time anyway) we would have to either inject something in the binary or somehow extract the right information out of the output. So far nobody has come up with a reliable way to do this.

To anyone reading this, feel free to reopen if you have suggestions on how to solve this in an elegant way.

@webbertakken webbertakken added the bug in unity This is a bug in unity itself (out of scope) label Jan 20, 2021
@mob-sakai mob-sakai mentioned this issue Jan 20, 2021
2 tasks
@mob-sakai
Copy link
Contributor

mob-sakai commented Jan 20, 2021

In some failing cases, the output will be different.

tl; dr

How to check activation result:

unity-editor -quit -logFile activation.log -manualLicenseFile <UNITY_LICENSE_FILE>
[ -z "`grep -e 'Next license update check is after' activation.log`" ]  && echo 'error: Failed to load license file'
[ -n "`grep -e 'Failed to load license file from' activation.log`" ]  && echo 'error: Failed to load license file'
[ -n "`grep -e 'LICENSE SYSTEM.* != ' activation.log`" ]  && echo 'error: Machine ID is different'



Success

$ unity-editor -quit -logFile /dev/stdout -manualLicenseFile success.ulf
...
 Load manual activation license file.
LICENSE SYSTEM [2021120 17:25:14] Load license file from: success.ulf
LICENSE SYSTEM [2021120 17:25:14] Next license update check is after 2021-01-21T17:04:09
 License file loaded.

Failed: Machine ID is different

$ unity-editor -quit -logFile /dev/stdout -manualLicenseFile unmatched_machine_id.ulf
...
 Load manual activation license file.
LICENSE SYSTEM [2021120 17:11:47] Load license file from: unmatched_machine_id.ulf
LICENSE SYSTEM [2021120 17:11:47] Next license update check is after 2021-01-21T17:10:34
LICENSE SYSTEM [2021120 17:11:47] 576562626572264761624c65526f7578 != B2DD8DE7-7E63-5962-95B4-3EEA5A1718C0
LICENSE SYSTEM [2021120 17:11:47] 576562626572264761624c65526f7578 != C02VQ158HTDG
 License file loaded.

Failed: The input file is not found

$ unity-editor -quit -logFile /dev/stdout -manualLicenseFile non_exist.ulf
...
 Load manual activation license file.
LICENSE SYSTEM [2021120 17:20:50] Load license file from: non_exist.ulf
LICENSE SYSTEM [2021120 17:20:50] Failed to load license file from: non_exist.ulf
 License file loaded.

Failed: The input file is empty

$ unity-editor -quit -logFile /dev/stdout -manualLicenseFile empty.ulf
...
 Load manual activation license file.
LICENSE SYSTEM [2021120 17:13:55] Load license file from: empty.ulf
LICENSE SYSTEM [2021120 17:13:55] Failed to load license file from: empty.ulf
 License file loaded.

Failed: The input file is alf

$ unity-editor -quit -logFile /dev/stdout -manualLicenseFile Unity.alf
...
 Load manual activation license file.
LICENSE SYSTEM [2021120 17:17:5] Load license file from: Unity.alf
LICENSE SYSTEM [2021120 17:17:5] Could not find digest XML element in license file. 
 License file loaded.

Failed: The structure of the input file is different

$ unity-editor -quit -logFile /dev/stdout -manualLicenseFile different_structure.ulf
...
 Load manual activation license file.
LICENSE SYSTEM [2021120 17:15:16] Load license file from: different_structure.ulf
 License file loaded.

@GabLeRoux
Copy link
Member

GabLeRoux commented Jan 20, 2021

So if we want to support this, we should have some way to parse unity's output to provide more insights on the error. It is probably feasible, but the solution should be discussed as this is definitely something that can make things more complicated in the project (and we want to keep actions as simple as possible here).

Edit: I missed the How to check activation result: part above sorry for confusion.

Should we execute unity command with tee instead? example: | tee unity_stdout.log and after the step, cat unity_stdout.log | grep '<some possible errors>'?

-logFile /dev/stdout should be kept otherwise, output won't be streamed to job's stdout.

Or is it possible (and desired) to run suggested command above and then proceed with a build in the actions?

@webbertakken
Copy link
Member

If we pipe it into an application, it should be something that can also forward non-zero exit codes while still logging to console.

Or perhaps we can use PIPESTATUS[0] as explained in this answer on StackOverflow.

@webbertakken
Copy link
Member

Reopening as it seems we have some ways to move forward. I have attempted it before, back when starting builder action, but I didn't manage to get it to work back then.

PRs are most welcome on this one :)

@webbertakken webbertakken reopened this Jan 20, 2021
@webbertakken webbertakken added the help wanted Extra attention is needed label Jan 20, 2021
@mob-sakai
Copy link
Contributor

When a license activation fails, additional context can be output using the solution described above.
For example:

  • Run Unity with -createManualActivationFile option to create and output a new alf file
    • Users can fix the license activation error without any new workflow (unity-request-activation-file action)
  • Output about "how to activate a license" (i.e. "what should you do next")

Do you have any suggestions?

@webbertakken
Copy link
Member

I really like that idea, however I would keep them separate for now. The idea is to fully automate activation.

There's an issue for it game-ci/unity-builder#193.

So I'd keep the scope to activation only for now (thus excluding requesting activation file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug in unity This is a bug in unity itself (out of scope) bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants