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

APP-6696 pass new AgentInfo.PlatformTags in config/reader.go #4469

Merged
merged 7 commits into from
Oct 22, 2024

Conversation

abe-winter
Copy link
Member

@abe-winter abe-winter commented Oct 21, 2024

What changed

  • readExtendedPlatformTags in config reader

Why

So we can select module binaries based on platform details.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Oct 21, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 21, 2024
@abe-winter abe-winter marked this pull request as ready for review October 21, 2024 18:25
Copy link
Member

@Otterverse Otterverse left a comment

Choose a reason for hiding this comment

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

The parser can create half-empty tags, so that's the primary concern. Also suggestion for a simpler path to file reading.

config/reader.go Outdated
Comment on lines 67 to 68
if runtime.GOOS == "linux" && rutils.PathExists("/etc/os-release") {
if body, err := os.Open("/etc/os-release"); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This feels like the long way around for two reasons. First, no need to check the path first. Just check the error from os.Open with !errors.Is(err, os.ErrNotExist)

Second, opening the file, then buffering it into a reader, then parsing it, and deferring a close() is a lot of steps for something that's mostly replaced by "os.ReadFile()" which just gives you back the bytes directly.

That said, nothing inherently wrong here either, so consider this optional.

Copy link
Member Author

Choose a reason for hiding this comment

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

simplified it in a532b41

config/reader.go Outdated
Comment on lines 73 to 75
tags = append(tags, "distro:"+osRelease["ID"])
tags = append(tags, "os_version:"+osRelease["VERSION_ID"])
tags = append(tags, "codename:"+osRelease["VERSION_CODENAME"])
Copy link
Member

Choose a reason for hiding this comment

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

No guarantee that all of these will be in every os-release file, as the fields are all optional. Many distros populate only some of these. If they're blank, you're gonna end up with odd tags like codename: which may break other stuff down the line when parsing.

Ex: Arch looks like this:

NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo

Copy link
Member Author

Choose a reason for hiding this comment

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

changed logic in a532b41 to only set a tag if the value exists

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 21, 2024
Copy link
Member

@Otterverse Otterverse left a comment

Choose a reason for hiding this comment

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

LGTM!

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 22, 2024
@abe-winter abe-winter merged commit 1930eb1 into viamrobotics:main Oct 22, 2024
18 checks passed
@abe-winter abe-winter deleted the aw-constraints branch October 22, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants