Skip to content

Scaler apis#2954

Merged
alrod merged 30 commits intodevfrom
scaler-apis
Mar 23, 2023
Merged

Scaler apis#2954
alrod merged 30 commits intodevfrom
scaler-apis

Conversation

@alrod
Copy link
Copy Markdown
Member

@alrod alrod commented Feb 7, 2023

Comment thread test/Microsoft.Azure.WebJobs.Host.EndToEndTests/Scale/ScaleHostEndToEndTests.cs Outdated
Comment thread test/Microsoft.Azure.WebJobs.Host.EndToEndTests/Scale/ScaleHostEndToEndTests.cs Outdated
Comment thread src/Microsoft.Azure.WebJobs.Host/Hosting/WebJobsHostBuilderExtensions.cs Outdated
Comment thread src/Microsoft.Azure.WebJobs.Host/Hosting/WebJobsHostBuilderExtensions.cs Outdated
Comment thread src/Microsoft.Azure.WebJobs.Host/Scale/ScaleOptions.cs Outdated
Comment thread src/Microsoft.Azure.WebJobs.Host/Scale/ScaleOptions.cs Outdated
@alrod alrod requested a review from mathewc February 11, 2023 01:11
Comment thread src/Microsoft.Azure.WebJobs.Host.Storage/StorageServiceCollectionExtensions.cs Outdated
Comment thread src/Microsoft.Azure.WebJobs.Host/Scale/ScaleMonitorService.cs Outdated
Comment thread src/Microsoft.Azure.WebJobs.Host/Scale/TriggerMetadata.cs Outdated
Comment thread test/Microsoft.Azure.WebJobs.Host.EndToEndTests/Scale/ScaleHostEndToEndTests.cs Outdated
Comment thread test/Microsoft.Azure.WebJobs.Host.EndToEndTests/Scale/ScaleHostEndToEndTests.cs Outdated
Comment thread src/Microsoft.Azure.WebJobs.Host/Scale/TriggerMetadataProvider.cs Outdated
Comment thread src/Microsoft.Azure.WebJobs.Host/Hosting/WebJobsHostBuilderExtensions.cs Outdated
@mathewc mathewc requested a review from brettsam February 22, 2023 19:51
Comment thread src/Microsoft.Azure.WebJobs.Host/Constants.cs
@mathewc
Copy link
Copy Markdown
Member

mathewc commented Feb 22, 2023

Adding @brettsam for general WebJobs SDK review, as well as specific review for the DI and host builder changes, since he has a lot of experience in that area

Comment thread src/Microsoft.Azure.WebJobs.Host/Hosting/WebJobsHostBuilderExtensions.cs Outdated
Comment thread src/Microsoft.Azure.WebJobs.Host/Scale/IScalerProvider.cs Outdated
@chiangvincent chiangvincent dismissed their stale review March 10, 2023 20:12

remove requirement

Comment thread src/Microsoft.Azure.WebJobs.Host/Scale/TriggerMetadata.cs Outdated
@pragnagopa pragnagopa requested a review from fabiocav March 10, 2023 22:51
Copy link
Copy Markdown
Member

@fabiocav fabiocav left a comment

Choose a reason for hiding this comment

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

Quick review on some of the DI changes. Sharing this, but will continue to iterate.

services.TryAddSingleton<ITargetScalerManager, TargetScalerManager>();

services.AddCommonScaleServices();
services.AddSingleton<IScaleMetricsRepository, NullScaleMetricsRepository>();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider using TryAddSingleton here instead.

}

// Options logging
services.AddTransient(typeof(OptionsFactory<>));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are we adding these options services as part of the scale logic? In the context of Functions, this is already handled, but for WebJobs, this shouldn't be tied to this logic.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, it's not really. AddWebJobsScale configures a host as a ScaleHost, and we want the options logging stuff as well to log ScaleOptions. So it's common registrations that we want to do for normal WebJobs hosts as well as scaler hosts. Could be factored into a shared method like I did for AddCommonScaleServices.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you call services.AddOptions() instead? That conditionally registers everything you'd need for Options -- and if they change something in future versions, it'd continue to work.

https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Options/src/OptionsServiceCollectionExtensions.cs#L22

Copy link
Copy Markdown
Member Author

@alrod alrod Mar 13, 2023

Choose a reason for hiding this comment

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

This was copy pasted from here. Do we want to change this in the both places: services.AddTransient(typeof(OptionsFactory<>)); -> services.AddOptions() ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Bunch of the tests are broken after the change:
https://github.com/Azure/azure-webjobs-sdk/pull/2954/checks?check_run_id=11964665844

Do we want to fix them all revert services.AddOptions()?

/// <summary>
/// Manages scale monitoring operations.
/// </summary>
public class ScaleManager
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this type need to be public?

Should we define (and register) an interface for this?

Copy link
Copy Markdown
Member

@mathewc mathewc Mar 11, 2023

Choose a reason for hiding this comment

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

We had defined an interface, but I just made it a public service type, similar to the decision I made for ConcurrencyManager. The rational is that it makes it easier to add new operations in the future w/o breaking an interface.

If we went the interface route, we wouldn't have an IScaleManager interface because that implies a larger capability set than just GetStatus. We'd end up defining just an IHostScaleStatusProvider or IScaleStatusProvider or some such interface for just that operation. I considered this.

Comment thread src/Microsoft.Azure.WebJobs.Host/Scale/TriggerMetadata.cs Outdated
services.AddSingleton<IConcurrencyStatusRepository, BlobStorageConcurrencyStatusRepository>();
}

public static void AddAzureStorageScaleServices(this IServiceCollection services)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this meant to ever be called by a customer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, this will be called from ScaleController, see example here:
https://github.com/Azure/azure-webjobs-sdk/blob/scaler-apis/test/Microsoft.Azure.WebJobs.Host.EndToEndTests/Scale/ScaleHostEndToEndTests.cs#L84

Function host is not supposed to call this.

}

/// <summary>
/// Configures the specified <see cref="IHostBuilder"/> as a scale manager host.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is that something a customer will do? Or do we need to mention this is only for internal infrastructure or something like that?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, this will be called from `ScaleController and a webjobs customer is not suppose to create a "scale manager host". I I extended the description.

}

// Options logging
services.AddTransient(typeof(OptionsFactory<>));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you call services.AddOptions() instead? That conditionally registers everything you'd need for Options -- and if they change something in future versions, it'd continue to work.

https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Options/src/OptionsServiceCollectionExtensions.cs#L22

@alrod alrod requested review from brettsam, fabiocav and mathewc March 13, 2023 16:44
namespace Microsoft.Azure.WebJobs.Host.Scale
{
/// <summary>
/// Interface for providing a scale status
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"Interface for providing aggregate scale status across all functions being monitored by the host."

Comment thread build/common.props Outdated
<Version>3.0.36$(VersionSuffix)</Version>
<HostStorageVersion>5.0.0-beta.2$(VersionSuffix)</HostStorageVersion>
<Version>3.0.37$(VersionSuffix)</Version>
<HostStorageVersion>5.0.0-beta.3$(VersionSuffix)</HostStorageVersion>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This package is about to be published as a GA (non-beta) release, OK to add the changes here?

Copy link
Copy Markdown
Member Author

@alrod alrod Mar 22, 2023

Choose a reason for hiding this comment

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

Updated to <HostStorageVersion>5.0.0$(VersionSuffix)</HostStorageVersion>

@pragnagopa
Copy link
Copy Markdown
Member

@alrod - Please update the PR description and would be great if you can add PRs links to extension SDK updates and Functions Host

@alrod
Copy link
Copy Markdown
Member Author

alrod commented Mar 22, 2023

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@alrod
Copy link
Copy Markdown
Member Author

alrod commented Mar 22, 2023

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@alrod
Copy link
Copy Markdown
Member Author

alrod commented Mar 22, 2023

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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.

Exposing common scaling code to consume by SC v3

6 participants