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

Handle context cancellation in fact gatherers #384

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

balanza
Copy link
Member

@balanza balanza commented Jan 30, 2025

Description

Following #376, handle context cancellation in the following gatherers

  • corosyncconf
  • fstab
  • groups
  • hostsfile
  • osrelease
  • passwd
  • sapcontrol
  • sapinstancehostnameresolver
  • sapprofiles

@balanza balanza requested review from arbulu89 and CDimonaco January 30, 2025 19:34
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!
Comments about the sapcontrol gatherer

log.Error(SapcontrolWebmethodError.
Wrap(fmt.Sprintf("argument %s for %s/%s", factReq.Argument, sid, instanceName)).
Wrap(err.Error()))
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe here we need to do other error checking.
Before the if err != nil, we could check if the context is done, so we avoid continue iterating and we early return the error.

continue
}
results := make(chan []entities.Fact)
go func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

question: why do we need a go routine?
i think we could keep everything in one thread, and in s.gatherSingle we could return facts, err, and if we have an error (caused by ctx being cancelled) simply return with an error.
it would make the code flow and testing easier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants