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

Add custom MarshalYAML() method to component to fix YAML marshaling of error values #3835

Merged

Conversation

fearful-symmetry
Copy link
Contributor

What does this PR do?

fixes #2940

This adds a MarshalYAML() method to the Component type that populates an ErrMsg value. This is needed to properly report any potential error values that might end up in a diagnostic dump; depending on the underlying type that's in the Err field, the YAML marshaller might just end up creating an empty {} value in the final YAML. I figured this approach, of creating a special ErrMsg field, was less invasive than coming up with some custom error wrapper that we would need to give special treatment.

Why is it important?

Errors should be properly reported in diagnostic dumps

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

@fearful-symmetry fearful-symmetry added the Team:Elastic-Agent Label for the Agent team label Nov 28, 2023
@fearful-symmetry fearful-symmetry self-assigned this Nov 28, 2023
@fearful-symmetry fearful-symmetry requested a review from a team as a code owner November 28, 2023 21:47
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

Copy link
Contributor

mergify bot commented Nov 28, 2023

This pull request does not have a backport label. Could you fix it @fearful-symmetry? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

Copy link

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Looks good.

Thanks for the improvement!

@fearful-symmetry fearful-symmetry merged commit 93f159a into elastic:main Nov 30, 2023
9 checks passed
@pierrehilbert
Copy link
Contributor

@fearful-symmetry What would you think about backporting this to 8.11 branch?
cc @cmacknz

@cmacknz
Copy link
Member

cmacknz commented Dec 1, 2023

Good idea, added the backport label

mergify bot pushed a commit that referenced this pull request Dec 1, 2023
…f error values (#3835)

* add custom MarshalYAML to component

* add changelog

* add nil check

* update tests

---------

Co-authored-by: Pierre HILBERT <pierre.hilbert@elastic.co>
(cherry picked from commit 93f159a)
pierrehilbert added a commit that referenced this pull request Dec 4, 2023
…f error values (#3835) (#3856)

* add custom MarshalYAML to component

* add changelog

* add nil check

* update tests

---------

Co-authored-by: Pierre HILBERT <pierre.hilbert@elastic.co>
(cherry picked from commit 93f159a)

Co-authored-by: Alex K <8418476+fearful-symmetry@users.noreply.github.com>
Co-authored-by: Pierre HILBERT <pierre.hilbert@elastic.co>
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.

components-actual diagnostic skips content of component/unit errors
5 participants