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

Resolver gatherer #274

Merged
merged 22 commits into from
Oct 19, 2023
Merged

Resolver gatherer #274

merged 22 commits into from
Oct 19, 2023

Conversation

rtorrero
Copy link
Contributor

@rtorrero rtorrero commented Oct 10, 2023

This PR adds a resolver gatherer, it uses the filesystem to search for running sap systems and the profile data to get the virtual hostnames associated to each instance of the sap system. It will then attempt to resolve those hostnames to confirm that the OS knows about them.

Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

@rtorrero Some initial comments about the generic logic of the code

internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Looking good @rtorrero
Good progress

internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/gatherer.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

More comments

pkg/utils/hostnameresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
@rtorrero rtorrero force-pushed the resolver-gatherer branch 2 times, most recently from ed99aea to 55d8719 Compare October 17, 2023 07:19
@rtorrero rtorrero marked this pull request as ready for review October 17, 2023 07:21
Copy link
Member

@CDimonaco CDimonaco left a comment

Choose a reason for hiding this comment

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

I think the code looks good, I'm requesting changes not on the logic itself, but on style and readability

Anyway GJ

internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
pkg/utils/hostnameresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
@rtorrero
Copy link
Contributor Author

@CDimonaco @arbulu89 thanks for the reviews, I think I've addressed everything, the only thing that I'm not 100% I did accordingly was the mocks, I didn't fully understand @arbulu89 proposal but I think I came up with a solution that addresses the main concern of not adding stuff to the utils when it's not being used elsewhere. In addition to the comments, I also:

  • Added the 'reachability' details (using ping) in the resulting fact value.
  • Improved a bit the main success test to include additional profiles and a failing ping.

Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Suggestions from my side

internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/saplocalhostresolver.go Outdated Show resolved Hide resolved
internal/factsengine/gatherers/mocks/HostPinger.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
@rtorrero rtorrero requested a review from arbulu89 October 18, 2023 11:44
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

@rtorrero Great! It looks good now.
Now....
the most difficult thing. Naming XD
I would vote for SapInstanceNameResolver or SapInstanceResolver or SapHostnameResolver, with preference for the first.
And the gatherer name would be sap_instancename_resolver maybe.
@abravosuse any idea?

google.golang.org/protobuf v1.31.0
)

require (
github.com/d-tux/go-fstab v0.0.0-20141204152952-eb4090f26517
github.com/iancoleman/strcase v0.2.0
github.com/spf13/afero v1.9.5
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know why golang moves this to other require. Mysteries XD

@abravosuse
Copy link

abravosuse commented Oct 18, 2023

@rtorrero @arbulu89 It's not the instance name that we are trying to resolve but the instance hostname. Therefore my preference would be SapInstanceHostnameResolver.

hostnameRegexCompiled = regexp.MustCompile(`(.+)_(.+)_(.+)`) // <SID>_<InstanceNumber>_<Hostname>
regexSubgroupsCount = 4
SapInstanceHostnameResolverDetailsError = entities.FactGatheringError{
Type: "sapinstance_hostname_resolver-details-error",
Copy link
Contributor

Choose a reason for hiding this comment

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

In other gatherers package_version, even though gatherer uses _, we use - here.
I don't want to create a big fuzz about that, but just wanted to comment hehe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no worries, I can change it

Copy link
Member

@EMaksy EMaksy left a comment

Choose a reason for hiding this comment

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

Hey nice work, lgtm :D

@rtorrero rtorrero merged commit c1e5123 into main Oct 19, 2023
9 checks passed
@rtorrero rtorrero deleted the resolver-gatherer branch October 19, 2023 07:51
@CDimonaco CDimonaco added the enhancement New feature or request label Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

5 participants