Skip to content

Conversation

@aruetten
Copy link

Description

Add Amazon Linux as known distro

Solution

Add if condition checking for amazon in the /etc/os_release file and set the distro var to Red Hat

Tests

Did run the code without the specific condition leading to Red Hat anyways, see:

[root@ip-10-xxx-xx-xx tmp]# bash -x test.sh
+ for command in "grep -E \"^NAME=\" /etc/os-release" "lsb_release -i" "cat /proc/version" "uname -a"
++ eval grep -E '"^NAME="' /etc/os-release
+ distro_string='NAME="Amazon Linux"'
+ unset distro
+ [[ name="amazon linux" == *\d\e\b\i\a\n* ]]
+ [[ name="amazon linux" == *\r\e\d\ \h\a\t* ]]
+ [[ name="amazon linux" == *\c\e\n\t\o\s* ]]
+ [[ name="amazon linux" == *\r\o\c\k\y* ]]
+ [[ name="amazon linux" == *\u\b\u\n\t\u* ]]
+ [[ name="amazon linux" == *\s\u\s\e* ]]
+ [[ name="amazon linux" == *\d\a\r\w\i\n* ]]
+ [[ -n '' ]]
+ for command in "grep -E \"^NAME=\" /etc/os-release" "lsb_release -i" "cat /proc/version" "uname -a"
++ eval lsb_release -i
+ distro_string=
+ unset distro
+ [[ '' == *\d\e\b\i\a\n* ]]
+ [[ '' == *\r\e\d\ \h\a\t* ]]
+ [[ '' == *\c\e\n\t\o\s* ]]
+ [[ '' == *\r\o\c\k\y* ]]
+ [[ '' == *\u\b\u\n\t\u* ]]
+ [[ '' == *\s\u\s\e* ]]
+ [[ '' == *\d\a\r\w\i\n* ]]
+ [[ -n '' ]]
+ for command in "grep -E \"^NAME=\" /etc/os-release" "lsb_release -i" "cat /proc/version" "uname -a"
++ eval cat /proc/version
+ distro_string='Linux version 6.1.150-174.273.amzn2023.x86_64 (mockbuild@ip-10-0-44-125) (gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5), GNU ld version 2.41-50.amzn2023.0.3) #1 SMP PREEMPT_DYNAMIC Tue Sep  9 12:21:26 UTC 2025'
+ unset distro
+ [[ linux version 6.1.150-174.273.amzn2023.x86_64 (mockbuild@ip-10-0-44-125) (gcc (gcc) 11.5.0 20240719 (red hat 11.5.0-5), gnu ld version 2.41-50.amzn2023.0.3) #1 smp preempt_dynamic tue sep  9 12:21:26 utc 2025 == *\d\e\b\i\a\n* ]]
+ [[ linux version 6.1.150-174.273.amzn2023.x86_64 (mockbuild@ip-10-0-44-125) (gcc (gcc) 11.5.0 20240719 (red hat 11.5.0-5), gnu ld version 2.41-50.amzn2023.0.3) #1 smp preempt_dynamic tue sep  9 12:21:26 utc 2025 == *\r\e\d\ \h\a\t* ]]
+ distro=RedHat
+ [[ -n RedHat ]]
+ break
+ echo RedHat
RedHat

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

Add Amazon Linux as known distro
@aruetten
Copy link
Author

aruetten commented Oct 16, 2025

Forget to mention the actual issue and use case for us.

This is not an issue while using the script on an AWS EC2 instance with Amazon Linux.

But we use the script also inside a docker container based on an Amazon Linux Image.

The issue there is that inside docker /etc/os-release will point to Amazon Linux while /proc/version is created at boot time and based on the host system and not the container. The host system can be any linux and does not necessarily have RedHat inside /proc/version.

Copy link
Contributor

@epugh epugh left a comment

Choose a reason for hiding this comment

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

Looks reasonable.. would love one more plus one!

@janhoy
Copy link
Contributor

janhoy commented Oct 18, 2025

@eric, come to think of it, should have a test for the install script, but it is difficult to automate. BATS won’t work, and docker is a singe process thing. I know you can install systemd as pod 1 in a container and thus be able to hack it. Could then run tests for various Linux flavors…

this edit is super small and safe though..

@epugh
Copy link
Contributor

epugh commented Oct 20, 2025

@eric, come to think of it, should have a test for the install script, but it is difficult to automate. BATS won’t work, and docker is a singe process thing. I know you can install systemd as pod 1 in a container and thus be able to hack it. Could then run tests for various Linux flavors…

this edit is super small and safe though..

Yeah, I tend to stay away from this file because I am scared of breaking it! This should go to all our branches right? Or just go to main and branch_10x?

@janhoy
Copy link
Contributor

janhoy commented Oct 20, 2025

I think this is safe also for 9x yes

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.

3 participants