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(monitor): provide always valid exitcode #3836

Closed

Conversation

jusito
Copy link
Contributor

@jusito jusito commented Apr 3, 2022

Description

These changes are the core changes needed for my docker pull request. The changes are tested against every servercode.

  1. command monitor had multiple issues, mainly it doesn't exit with a usable exit code. I applied the style guide and documentation should be correct now.
  2. 127.0.0.1 should be part of fallback ips and maybe the others should even be removed. E.g. the port config inside a container can be 27015 but its mapped to host 27016, maybe because on 27015 is another server. Therefore if the host ip is taken to do a check, the wrong server is monitored.
  3. lgsm/functions/core_dl.sh:368 hides curl failing
  4. linuxgsm.sh changes are really useful to debug multiple invocations. As a result you can run a clean container and dump this file after the run to get a complete debug log.
  5. lgsm/functions/install_server_files.sh missed a check if branch is missing
  6. lgsm/functions/fix.sh refactoring to get rid of lots of branches which are error prone. Also added check to validate names added to arrays are valid.
  7. lgsm/functions/install_header.sh probably a typo?

Fixes #[issue]

Type of change

  • Bug fix (a change which fixes an issue).
  • New feature (change which adds functionality).
  • New Server (new server added).
  • Refactor (restructures existing code).
  • Comment update (typo, spelling, explanation, examples, etc).

Checklist

PR will not be merged until all steps are complete.

  • This pull request links to an issue draft pr which depends on this.
  • This pull request uses the develop branch as its base.
  • This pull request Subject follows the Conventional Commits standard.
  • This code follows the style guidelines of this project.
  • I have performed a self-review of my code.
  • I have checked that this code is commented where required.
  • I have provided a detailed with enough description of this PR.
  • I have checked If documentation needs updating.

Documentation

If documentation does need updating either update it by creating a PR (preferred) or request a documentation update.

Thank you for your Pull Request!

@jusito jusito changed the title added docker integration feat docker integration Apr 3, 2022
Copy link
Member

@dgibbs64 dgibbs64 left a comment

Choose a reason for hiding this comment

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

Some interesting changes. I will have to review further myself and make any further changes required. Good PR. Thanks

# uses status var from check_status.sh
if [ "${status}" != "0" ]; then
fn_print_ok "Checking session: "
fn_print_ok_eol_nl
fn_script_log_pass "Checking session: OK"
Copy link
Member

Choose a reason for hiding this comment

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

This is required for logging

function fn__is_valid_ip() {
local ip="${1}"
# excluding 0.* ips also
grep -qEe '^[1-9]+[0-9]*\.[0-9]+\.[0-9]+\.[0-9]+$' <<< "${ip}"
Copy link
Member

Choose a reason for hiding this comment

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

Nice improvement :)

fn_script_log_info "Checking active updates: CHECKING"
fn_print_error_nl "Checking active updates: SteamCMD is currently checking for updates: "
fn_print_error_eol
fn_script_log_error "Checking active updates: SteamCMD is currently checking for updates: ERROR"
Copy link
Member

Choose a reason for hiding this comment

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

removing script_log_error removed logging for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is your rule for using fn_script_log_* here ?
Do you prefer setting the exitcode by fn_scrip_log_* in this case I can add it also in the other locations where I set exitcode directly.

I didn't add it because it seems like duplicate log output, if there would be a fn_script_log_dots [and replacing in monitor fn_print_dots with it] or fn_print_*_nl() which also setting the exitcode, I would be more satisfied. Would you be fine with such a solution?

@@ -62,6 +62,10 @@ fn_install_server_files(){
remote_fileurl="https://files.sa-mp.com/samp037svr_R2-1.tar.gz"; local_filedir="${tmpdir}"; local_filename="samp037svr_R2-1.tar.gz"; chmodx="nochmodx" run="norun"; force="noforce"; md5="93705e165550c97484678236749198a4"
elif [ "${shortname}" == "zmr" ]; then
remote_fileurl="http://linuxgsm.download/ZombieMasterReborn/zombie_master_reborn_b5_2.tar.xz"; local_filedir="${tmpdir}"; local_filename="zombie_master_reborn_b5_2.tar.xz"; chmodx="nochmodx" run="norun"; force="noforce"; md5="4b9b9832e863d03981a40c26065792a6"
else
fn_print_error "Installing ${gamename} Server failed, missing default configuration"
Copy link
Member

Choose a reason for hiding this comment

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

LinuxGSM would fail long before getting here is $shortname was was not available

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bdserver will run into this without the fix from following pr, makes it more safe to use here.
https://github.com/jusito/LinuxGSM/blob/fix/bdserver/lgsm/functions/install_server_files.sh#L13-L16

jusito added a commit to jusito/LinuxGSM that referenced this pull request Apr 4, 2022
@jusito
Copy link
Contributor Author

jusito commented Apr 4, 2022

Some interesting changes. I will have to review further myself and make any further changes required. Good PR. Thanks

You are welcome, regarding the changes I would suggest to guide me, because there are around 5-20 other pull requests waiting to be opened after this. Do you prefer a pr per servercode even if only one file is changed or group some of them. E.g. some servers just don't listen to serverquery port, even in an isolated environment with correct config and correct invocation. Therefore I tried to use another mode or set it to "1".

@h3o66 h3o66 added the branch conflicts Branch of pr has conflicts that need to be worked on label Aug 24, 2022
@jusito jusito force-pushed the feat/docker-integration branch 2 times, most recently from 4796863 to 2a14460 Compare August 24, 2022 19:11
jusito added a commit to jusito/LinuxGSM that referenced this pull request Aug 24, 2022
@jusito jusito force-pushed the feat/docker-integration branch 2 times, most recently from 50fbfb8 to 07eef64 Compare August 24, 2022 20:30
@jusito
Copy link
Contributor Author

jusito commented Aug 24, 2022

Resolved the conflicts, messed a bit with git history and needed to rewrite it.
Just to be sure everything is working iam running my own tests on all gameservers and checking the logs, please dont merge until these tests are done.

@Claiyc Claiyc removed the branch conflicts Branch of pr has conflicts that need to be worked on label Aug 24, 2022
@jusito
Copy link
Contributor Author

jusito commented Aug 25, 2022

test logs looking good for me

@Claiyc
Copy link
Member

Claiyc commented Aug 25, 2022

Then I guess this is ready to merge @h3o66 @dgibbs64

@dgibbs64 dgibbs64 force-pushed the develop branch 5 times, most recently from f02e53d to 2257be4 Compare October 22, 2022 21:53
@jusito jusito changed the title feat docker integration fix(monitor): provide always valid exitcode Mar 13, 2023
@dgibbs64
Copy link
Member

Looking to get this merged. However, the issue I have is there are multiple features/fixes in this PR. Ideally these fixes should be broken down in to smaller PR's that will allow me to test individually and merge.

I will have a go a breaking down the code a merging in a bit at a time

@jusito
Copy link
Contributor Author

jusito commented Mar 28, 2023

I would like to help you, I have time after thursday but could finish it until saturday evening, would that help you ?

@dgibbs64
Copy link
Member

Yeah that would be awesome. I am going though another PR currently and then I'm going to break down this one. When you start breaking things down just let me know which feature you are doing so we don't overlap :)

@jusito
Copy link
Contributor Author

jusito commented Mar 31, 2023

  • currently rebasing this pr
  • reviewing it again
    • check_ip.sh, refactor / 127.0.0.1 as fallback default

      127.0.0.1 should be part of fallback ips and maybe the others should even be removed. E.g. the port config inside a container can be 27015 but its mapped to host 27016, maybe because on 27015 is another server. Therefore if the host ip is taken to do a check, the wrong server is monitored.
      Examples:

      1. Used on host directly
        • As long as 127.0.0.1 is there or only user configured ip is used, its fine.
      2. Used via docker / other virtual environment which is provided by lgsm, lets say we using virtual port mapping so port in container is 27015 but port outside is host:27016 and lets say a second server is running on host:27015.
        • Any non 127.0.0.1 ip could be an issue but we could add it on docker side into the config as "ip". The scripts respecting only 127.0.0.1 in this case and if the user is able to override it this code is fine.
      3. Like b. but a virtual environment which isn't provided by lgsm, e.g. third party docker images.
        • 127.0.0.1 is the only valid option as default, some could argue ips above that like host ip should be configured by the user. Any other ip, even as fallback, could led to weird restarts which are hard to debug.

      The last case was before and is after this still an issue. But we can't only add 127.0.0.1 untested, because some server might not accept such requests. So that would need complete testing.

    • core_dl.sh, exit code of curl overwritten before stored

    • fix.sh refactor to remove error prone branches and also added checks

    • info_messages.sh if referenced queryport / voiceport is "NOT SET" grep would look for NOT in the file SET and silently fail

    • query_gamedig.sh, should always provide "querystatus" and in particular on fail != 0 for monitor command & a typo in a variable name

    • install_server_files.sh, fail safely if serverfiles arent configured correctly

    • command_monitor.sh, looks good to me. Only the part where you would like to see logging to console and when for fn_script_ , I would need a hint for that.

  • breaking it down

@jusito jusito force-pushed the feat/docker-integration branch from 07eef64 to 242d0a4 Compare March 31, 2023 11:51
@jusito
Copy link
Contributor Author

jusito commented Apr 1, 2023

split into individual prs.

@jusito jusito closed this Apr 1, 2023
@dgibbs64
Copy link
Member

dgibbs64 commented Apr 2, 2023

Thanks for splitting them up. I was able to review and merge most quite quickly.

Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants