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

Health Endpoint for DAB Engine #2515

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

sezal98
Copy link
Contributor

@sezal98 sezal98 commented Jan 12, 2025

Why make this change?

This PR includes structural End to end changes for Health Endpoint.
It involved keeping both pipelines steady for original and enhanced health check based on a config flag in the runtime Config.
Resolves #2502

What is this change?

Created a new parameter in RuntimeConfig for Health which would include if the new enhanced version of health check is enabled or not.
New parameter of Health in DataSource which would provide info regarding which query to run on DB and under what threshold.
Created a class DabHealthCheckReport which would include details of status, version and app name like before. But would also be enhanced now to get details of config supplied and health of entities and data source.

TODO

  1. Health Endpoint based on Roles
  2. Max Dop: Parallel call to DB for health check
  3. Validate query text in the Health config
  4. Caching of health endpoint responses

How was this tested?

Currently tested on local. Would be improved further with UTs.

Sample Request(s)

Enhanced Format
image
Original Format
image

@sezal98 sezal98 changed the title Dev/sezalchug/health endpoint Structural Changes for Health Endpoint Jan 12, 2025
@sezal98 sezal98 changed the title Structural Changes for Health Endpoint Structural and Pipeline Changes for Health Endpoint Jan 12, 2025
@@ -44,6 +46,7 @@ public Entity(
Dictionary<string, string>? Mappings,
Dictionary<string, EntityRelationship>? Relationships,
EntityCacheOptions? Cache = null,
DabHealthCheckConfig? Health = null,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the name could be simplified to just say HealthCheck in alignment with other options like Mappings. Since this is already in the context of Dab and its a config, the prefix Dab and suffix Config are not needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

why was this resolved? i don't see an update.

@abhishekkumams
Copy link
Contributor

abhishekkumams commented Jan 17, 2025

Can we have some unit tests to verify the changes in the current PR? Also add what changes are missing here that will be added in the subsequent PRs.

@sezal98 sezal98 changed the title Structural and Pipeline Changes for Health Endpoint Health Endpoint for DAB Engine Jan 22, 2025
@sezal98
Copy link
Contributor Author

sezal98 commented Jan 22, 2025

/azp run

Copy link
Contributor

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

Submitting review done so far - the comments were pending in my local workspace.. still need to review other files.

/// <summary>
/// The version of the service.
/// </summary>
public string? Version { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would this ever be null? Wont we have a version always

/// <summary>
/// The name of the dab service.
/// </summary>
public string? AppName { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Same: AppName should always be present

/// <summary>
/// The configuration details of the dab service.
/// </summary>
public DabConfigurationDetails? DabConfigurationDetails { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Dab cannot start without configuration, this has to be non-null

namespace Azure.DataApiBuilder.Config.ObjectModel
{
/// <summary>
/// The health report of the DAB Enigne.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Copy paste issue, fix description

/// </summary>
public record DabConfigurationDetails
{
public bool Rest { get; init; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Is bool sufficient or do we need to provide the complete details of the Rest runtime options? same for GraphQL


[JsonPropertyName("threshold-ms")]
public int? ThresholdMs { get; set; } // (Default: 10000ms)
public string Role { get; set; } = "*"; // "roles": ["anonymous", "authenticated"] (Default: *)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: be more descriptive of what this Role is for, could be RoleAuthorizedToViewHealth e.g. Set JsonPropertyName to be Role

/// Creates a JSON response for the health check endpoint using the provided health report.
/// If the response has already been created, it will be reused.
/// </summary>
public class HealthReportResponseWriter
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the file name should be HealthReportResponseWriter

// Dependencies
private ILogger? _logger;
private RuntimeConfigProvider _runtimeConfigProvider;
private OriginalHealthReportResponseWriter _originalHealthReportResponseWriter;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why we need a new ResponseWriter. Couldnt we just check the config flag and decide whether to include the additional content or not?

@abhishekkumams abhishekkumams modified the milestones: 1.4, 1.5 Jan 23, 2025
@@ -12,7 +12,12 @@ namespace Azure.DataApiBuilder.Config.ObjectModel;
/// <param name="DatabaseType">Type of database to use.</param>
/// <param name="ConnectionString">Connection string to access the database.</param>
/// <param name="Options">Custom options for the specific database. If there are no options, this could be null.</param>
public record DataSource(DatabaseType DatabaseType, string ConnectionString, Dictionary<string, object?>? Options)
/// <param name="Health">Health check configuration for the database. In case null, follow old format of health check.</param>
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be updated? since we now want to have both old format on the original address and new format on\health?

// The moniker or simple name of the data source to be checked.
// Required when there is a multiple data source scenario.
// TODO: Add validity support for when multiple data sources
public string? Moniker { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we are updating this and not use Moniker.


// The query to be executed to check the health of the data source.
// "query: "SELECT TOP 1 1"
public string? Query { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

We are also not going to have Query as discussed

@abhishekkumams
Copy link
Contributor

The PR description needs to be updated.

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

Successfully merging this pull request may close these issues.

Enhance the Config file to include properties for Health Endpoint
3 participants