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

[ServiceBus] Pass timeout to server when accepting next session #23210

Merged

Conversation

jeremymeng
Copy link
Member

@jeremymeng jeremymeng commented Sep 13, 2022

This is ported from .NET PR Azure/azure-sdk-for-net#30963

The service hardcodes a max of 1 minute and 5 seconds when accepting a session. This means the retry timeout the user specifies in the client is ignored if they specify a value higher than this. We should specify the timeout property in the link settings properties when opening a link for next available session to support long polling.

Packages impacted by this PR

@azure/service-bus

Issues associated with this PR

#23118

This is ported from .NET PR Azure/azure-sdk-for-net#30963

he service hardcodes a max of 1 minute and 5 seconds when accepting a session.
This means the retry timeout the user specifies in the client is ignored if they
specify a value higher than this. We should specify the timeout property in the
link settings properties when opening a link for next available session to
support long polling.
// The number of milliseconds to use as the basis for calculating a random jitter amount
// opening receiver links. This is intended to ensure that multiple
// session operations don't timeout at the same exact moment.
const jitterBaseInMs = Math.min(operationTimeout * 0.01, 100);
Copy link
Member Author

Choose a reason for hiding this comment

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

The jitter may not be as useful in JS since we don't have multiple threads.

Copy link
Member

Choose a reason for hiding this comment

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

Well there is still the concept of concurrency, no? It may all be occurring on one thread but I think spreading out the timeouts would still help alleviate context switching.

// Subtract a random amount up to 100ms from the operation timeout as the jitter when attempting to open next available session link.
// This prevents excessive resource usage when using high amounts of concurrency and accepting the next available session.
// Take the min of 1% of the total timeout and the base jitter amount so that we don't end up subtracting more than 1% of the total timeout.
const timeoutWithJitterInMs = operationTimeout - jitterBaseInMs * Math.random();
Copy link
Member

Choose a reason for hiding this comment

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

I made an update to the .NET implementation to subtract an additional 20ms as long as the timeout is over 1 s. Azure/azure-sdk-for-net#31069

Copy link
Member Author

Choose a reason for hiding this comment

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

I port this over too and add some fix so this really only applies to acceptNextSession()

@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

only for acceptNetSession()
@jeremymeng jeremymeng merged commit be0a582 into Azure:main Sep 15, 2022
@jeremymeng jeremymeng deleted the sb/pass-client-timeout-acceptnextsession branch September 15, 2022 19:10
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-js that referenced this pull request Apr 25, 2023
Release of microsoft.network api version: 2022 11 01 (Azure#23652)

* Adds base for updating Microsoft.Network from version stable/2022-09-01 to version 2022-11-01

* Updates readme

* Updates API version in new specs and examples

* remove loadDistributionPolicy from appgw PUT request body example (Azure#23144)

* remove loadDistributionPolicy from appgw PUT request body example

* remove loadDistributionPolicy from appgw PUT request body example2

* remove loadDistributionPolicy from appgw PUT request body example

* remove duplicates

* add private link configuration to see if it will fix validation error

* remove privateLinkConfig related

* revert changes to see if still get validation error

* update back to original changes

* add response resource id to fix modelValidation error

* add connection resource

* Selector in Exclusions should not be required as Operator EqualsAny does not need a Selector (Azure#23184)

* Application Gateway WAF Rate Limit feature swagger changes (Azure#23021)

* Application Gateway WAF Rate Limit feature swagger changes

* Fixing lint errors

* Updated rate limit feature examples

* Fix for applicationGatewayIpConfigurations property and make the priority parameter as required for NSG (Azure#23210)

* Fix for applicationGatewayIpConfigurations property

This swagger definition is defining property applicationGatewayIpConfigurations,

```
"applicationGatewayIpConfigurations": {
          "type": "array",
          "items": {
            "$ref": "./applicationGateway.json#/definitions/ApplicationGatewayIPConfiguration"
          },
          "description": "Application gateway IP configurations of virtual network resource."
        }
```
but actual rest api returned applicationGatewayIPConfigurations, the P is upper case while in swagger it is lower case.
```
{
  "name": "subnet-agw",
  "id": "/subscriptions/<sub-id>/resourceGroups/<rg-name>/providers/Microsoft.Network/virtualNetworks/<vnet-name>/subnets/subnet-agw",
  "properties": {
      "applicationGatewayIPConfigurations": [
          {
              "id": "/subscriptions/<sub-id>/resourceGroups/<rg-name>/providers/Microsoft.Network/applicationGateways/<agw-name>/gatewayIPConfigurations/appGatewayIpConfig"
          }
      ]
  },
  "type": "Microsoft.Network/virtualNetworks/subnets"
}
```

* Making priority property required

[This is the API invoked](https://learn.microsoft.com/en-us/rest/api/virtualnetwork/network-security-groups/create-or-update?tabs=HTTP#code-try-0).

For the NSG security rules without priorities, seems like the priority parameter is required. Azure portal works as expected. I don't think that's allowed but according to the schema it is because the priority property is not marked as required. I tried to create a NSG security rule without the priorities and it failed with below.

Request Body:

```
{
  "properties": {
    "securityRules": [
      {
        "name": "rule1",
        "properties": {
          "protocol": "*",
          "sourceAddressPrefix": "*",
          "destinationAddressPrefix": "*",
          "access": "Allow",
          "destinationPortRange": "80",
          "sourcePortRange": "*",
          "direction": "Inbound"
        }
      }
    ]
  },
  "location": "eastus"
}
```
Response received:

```
{
  "error": {
    "code": "SecurityRuleInvalidPriority",
    "message": "Security rule has invalid Priority. Value provided: 0 Allowed range 100-4096.",
    "details": []
  }
}
```
This PR will make the priority parameter as required.

* Update NetworkSecurityGroupDelete.json

* Update NetworkSecurityGroupRuleDelete.json

* Update NetworkSecurityGroupDelete.json

* Undo previous change of making fields optional within Exclusion (Azure#23325)

* Nivishenker/http headers to insert (Azure#23295)

* new app rule property - http header to insert

* prettier

* add to 22-11-01

* removed changes from 22-09-01

* fixed example

* delete RCG example

* fix delete examples

* added a Location header

* prettier fix

* Application Gateway WAF Log scrubbing swagger changes (Azure#23022)

* Log scrubbing API changes

* Update examples

* Addressing comments

* Fix

* Update property in load balancer for Connection Draining Phase 1 (Azure#23082)

* Update property in load balancer for Coneection Draining Phase 1

* Fix model validation

* Azure Firewall Packet Capture API. Cancelled PR from 2022-09-01 and created for 2022-11-01 (Azure#23114)

* moving packet-capture api to 2022-11-01 release from 2022-09-01

* fixing the LRO response header error for model validation

* Changes for Additional nic and corrections (Azure#23522)

* Changes for Additional nic and corrections

* Fixes for tool reported issues

* Fix for SpellCheck, ModelValidation

* Defining Location in NetworkVirtualApplianceDelete for async

* Minor fix

* Minor fix

* Minor fix

* PrettierCheck fixed

* Fixing VirtualApplianceAdditionalNicProperties

* ModelValidation fixed

* Correcting the location header string

* Correcting location header

* Prettied Check Fix

* Fix

* Fix

* Add inspection limit changes (Azure#23536)

* Fixed headers for examples (Azure#23554)

* Fix response of API: List of advertised/learned BGP routes (Azure#23555)

* fix response type

* fix format

* fix example, add x-ms-identifiers

* AuxiliarySku on Nic (Azure#23552)

* Adding auxiliary sku property on nic

* Adding AcceleratedConnections to AuxMode

* modifying the auxSku values

* Removing accidental change

---------

Co-authored-by: Prachi Pravin Bhavsar <prbhavsar@microsoft.com>

* migrated latest pr from incorrect branch (Azure#23589)

* Changes for NVA connection (Azure#23173)

* Changes for NVA connection

* Changes to address validation failures

* Fix some ModelValidation errors

* Fix some ModelValidation errors

* Fix some ModelValidation errors

* Fix some ModelValidation errors

* Fix some ModelValidation errors

* Addressing some review comments

* Addressing some review comments

* Addressing some review comments

* Addressing some review comments

* Addressing some review comments

* Fix camel case for property name

* Fixing resourceUri to Camel case in example files

* Fix SDK duplication error

* Fix one LintDiff error

* try fix lintdiff errors

* fix lro erro in lintdiff

* fix model validation error

* Bastion S360 for 2022-11 version (Azure#23595)

* Release microsoft.network 2022 11 01 (Azure#23564)

* Application Gateway WAF Rate Limit feature swagger changes

* Fixing lint errors

* Updated rate limit feature examples

* rateLimitDuration and rateLimitThreshold are not mandatory. There are only mandatory if ruleType is RateLimitRule. This validation will be done in NRP.

* Fix attempt 2. Removed minimum constraint from rateLimitThreshold. Validation will be done in NRP

* Remove the minimum number for the option field requestBodyInspectLimitInKB (Azure#23663)

* Remove minimum value for optional field requestBodyInspectLimitInKB

* Remove exlcusiveMinimum

---------

Co-authored-by: htippanaboya <102244326+htippanaboya@users.noreply.github.com>
Co-authored-by: tracyMicro <127259533+tracyMicro@users.noreply.github.com>
Co-authored-by: tejasshah7 <49326906+tejasshah7@users.noreply.github.com>
Co-authored-by: sraghavan-msft <98118843+sraghavan-msft@users.noreply.github.com>
Co-authored-by: navba-MSFT <57353862+navba-MSFT@users.noreply.github.com>
Co-authored-by: NiviShenker <99583088+NiviShenker@users.noreply.github.com>
Co-authored-by: Sindhu Aluguvelli <sindhureddy216@gmail.com>
Co-authored-by: phrazfipho <121897152+phrazfipho@users.noreply.github.com>
Co-authored-by: nikhilpadhye1 <68977752+nikhilpadhye1@users.noreply.github.com>
Co-authored-by: JainRah <108508612+JainRah@users.noreply.github.com>
Co-authored-by: karanbazaz <karan.bazaz@gmail.com>
Co-authored-by: yeliMSFT <95386492+yeliMSFT@users.noreply.github.com>
Co-authored-by: pracsb <78512712+pr-work@users.noreply.github.com>
Co-authored-by: Prachi Pravin Bhavsar <prbhavsar@microsoft.com>
Co-authored-by: nanditaashok-ms <122581061+nanditaashok-ms@users.noreply.github.com>
Co-authored-by: anvrao1 <109107918+anvrao1@users.noreply.github.com>
Co-authored-by: baoqihuang0326 <119557638+baoqihuang0326@users.noreply.github.com>
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.

4 participants