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

Actuator content negotiation #1438

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Actuator content negotiation #1438

wants to merge 8 commits into from

Conversation

TimHess
Copy link
Member

@TimHess TimHess commented Jan 16, 2025

Description

  • Improves content negotiation, provides per-request support for determining version
  • Removes most v1/v2 remnants that aren't needed anymore.
  • Improves Spring alignment for Liveness, Readiness, Disk Space, /health v3

Now includes changes from #1445

Resolves #1335, Resolves #1367

Partially addresses #1440 (probes are still enabled by default, showDetails not investigated yet)

TODO:

  • docs
  • further alignment with Spring on probes and groups

Quality checklist

  • Your code complies with our Coding Style.
  • You've updated unit and/or integration tests for your change, where applicable.
  • You've updated documentation for your change, where applicable.
    If your change affects other repositories, such as Documentation, Samples and/or MainSite, add linked PRs here.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.
  • You've added required license files and/or file headers (explaining where the code came from with proper attribution), where code is copied from StackOverflow, a blog, or OSS.

@TimHess TimHess added Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line labels Jan 16, 2025
@TimHess TimHess self-assigned this Jan 16, 2025
Copy link
Member

@bart-vmware bart-vmware left a comment

Choose a reason for hiding this comment

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

Looks great, happy to see all the startup classes are gone.

Although we decided to change Steeltoe to not perform any content negotiation anymore, I'm concerned adding it later is going to be a breaking change. Therefore I opened #1445, which builds upon this PR.

writer.WriteStartObject();

foreach ((string detailKey, object detailValue) in value.Details)
foreach (KeyValuePair<string, object> detail in value.Details)
Copy link
Member

Choose a reason for hiding this comment

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

Please deconstruct into:

foreach ((string componentKey, object componentValue) in value.Details)

Copy link
Member Author

Choose a reason for hiding this comment

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

HealthConverter has been removed

health.Should().ContainKey("details");
var details = JsonSerializer.Deserialize<Dictionary<string, object>>(health!["details"].ToString()!);
health.Should().ContainKey("components");
var details = JsonSerializer.Deserialize<Dictionary<string, object>>(health!["components"].ToString()!);
Copy link
Member

Choose a reason for hiding this comment

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

var details var components

@@ -38,58 +38,22 @@ public static IServiceCollection AddThreadDumpActuator(this IServiceCollection s
/// The incoming <paramref name="services" /> so that additional calls can be chained.
/// </returns>
public static IServiceCollection AddThreadDumpActuator(this IServiceCollection services, bool configureMiddleware)
{
Copy link
Member

Choose a reason for hiding this comment

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

The following note should be removed from the documentation at https://github.com/SteeltoeOSS/Documentation/blob/v4/api/v4/management/threaddump.md:

image

@@ -21,8 +21,7 @@ public sealed class EndpointMiddlewareTest : BaseTest
{
["management:endpoints:enabled"] = "true",
["management:endpoints:dump:enabled"] = "true",
["management:endpoints:actuator:exposure:include:0"] = "threaddump",
["management:endpoints:actuator:exposure:include:1"] = "dump"
["management:endpoints:actuator:exposure:include:0"] = "threaddump"
Copy link
Member

Choose a reason for hiding this comment

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

I find it confusing that we now have an actuator with the ID "threaddump" at /actuator/threaddump, while its configuration key is management:endpoints:dump, especially since we also have management:endpoints:heapdump.

I'd like to propose changing the configuration key to match up (which is a breaking change that we should call out in the docs)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was planning to break things up a little, but this got big enough that it doesn't make sense to do separately so is now included

Copy link
Member

Choose a reason for hiding this comment

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

In the following tests:

  • HealthActuator_ReturnsOnlyStatus
  • HealthActuator_ReturnsOnlyStatus_WhenAuthorizedSetButUserIsNot
  • HealthActuator_ReturnsDetailsWhenConfigured

The line:

health.Should().NotContainKey("details");

should be removed. Because details is a child of components, so it can never occur as a key in the health dictionary.

And I think that comments like:

// {"status":"UP","components":{"diskSpace":{"status":"UP","details":{"total":1003588939776...

should be removed, because they are no longer correct. They add confusion as soon as the comment differs from a changed implementation, which we won't get any warnings/failures about.

@bart-vmware bart-vmware added this to the 4.0.0-m1 milestone Jan 21, 2025
@TimHess TimHess changed the title Remove actuator content negotiation, only support v3 Actuator content negotiation Jan 21, 2025
@TimHess TimHess force-pushed the remove_negotiation branch from a83dfac to 50fdd11 Compare January 22, 2025 00:56
@TimHess TimHess added Warn/breaking-change There is a breaking change in the code Warn/api-change The APIs were changed and removed Warn/breaking-change There is a breaking change in the code labels Jan 22, 2025
TimHess and others added 4 commits January 21, 2025 19:07
Co-authored-by: Bart Koelman <104792814+bart-vmware@users.noreply.github.com>
drop HealthConverter
align probe contributor Ids with Spring
disk contributor: add path and exists details, drop status
Groups:
- decouple default group and contributor names
- use PostConfigure to set defaults
@TimHess TimHess force-pushed the remove_negotiation branch from 50fdd11 to 47d8e71 Compare January 22, 2025 01:13
allow "v2" responses where SBA requires v2 and there is no real difference
@TimHess TimHess force-pushed the remove_negotiation branch from 80a3801 to b127eee Compare January 25, 2025 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line Warn/api-change The APIs were changed
Projects
None yet
2 participants