.Net 应用程序运行状况检查在 Fargate 上失败

问题描述 投票:0回答:1

我有一个 .Net 应用程序,我正在尝试将其部署在 Fargate 上。 目前,来自公共 DNS 的运行状况检查正在通过,但来自注册目标的各个 privateIps 的运行状况检查失败。见下图 enter image description here

我需要在代码或 Program.cs 中配置任何内容才能允许这些请求通过吗? 这就是我的 Program.cs 目前的样子

using CHIPADMINWEB.Extensions;
using Microsoft.AspNetCore.Mvc;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHealthChecks();

builder.RegisterServices(typeof(Program));

var isLocalEnv = Environment.GetEnvironmentVariable("IS_LOCAL_ENV");

if (string.IsNullOrEmpty(isLocalEnv) || !isLocalEnv.ToLower().Equals("true"))
{
    builder.Services.AddDataProtection().PersistKeysToAWSSystemsManager("/Backoffice/Frontend/DataProtection");
    builder.Services.AddMvc();
}


var app = builder.Build();

app.MapHealthChecks("/healthz.html").AllowAnonymous();
app.RegisterPipelineComponents(typeof(Program));

Console.WriteLine($"Urls from Program.cs before app.Run(): {string.Join(", ", app.Urls)}");


app.Run("http://*:80");


Console.WriteLine($"Urls from Program.cs afte app.Run(): {string.Join(", ", app.Urls)}");

任何帮助将不胜感激。

请在下面找到以下命令的输出。

  1. aws elbv2 describe-target-groups
{
    "TargetGroups": [
        {
            "TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:533267186874:targetgroup/TestSt-testb-R7CTTOEHJ3YZ/edc6b4640fe04145",
            "TargetGroupName": "TestSt-testb-R7CTTOEHJ3YZ",
            "Protocol": "HTTP",
            "Port": 80,
            "VpcId": "vpc-0daab6dbe1f80c361",
            "HealthCheckProtocol": "HTTP",
            "HealthCheckPort": "traffic-port",
            "HealthCheckEnabled": true,
            "HealthCheckIntervalSeconds": 30,
            "HealthCheckTimeoutSeconds": 10,
            "HealthyThresholdCount": 5,
            "UnhealthyThresholdCount": 2,
            "HealthCheckPath": "/healthz.html",
            "Matcher": {
                "HttpCode": "200"
            },
            "LoadBalancerArns": [
                "arn:aws:elasticloadbalancing:us-east-1:533267186874:loadbalancer/app/test-backofficebackend-lb/faa19d4b7637ee2b"
            ],
            "TargetType": "ip",
            "ProtocolVersion": "HTTP1",
            "IpAddressType": "ipv4"
        },
        {
            "TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:533267186874:targetgroup/TestSt-testb-YBCCMPDKJYVP/ee7f7b52f9d4fce5",
            "TargetGroupName": "TestSt-testb-YBCCMPDKJYVP",
            "Protocol": "HTTP",
            "Port": 80,
            "VpcId": "vpc-0daab6dbe1f80c361",
            "HealthCheckProtocol": "HTTP",
            "HealthCheckPort": "traffic-port",
            "HealthCheckEnabled": true,
            "HealthCheckIntervalSeconds": 30,
            "HealthCheckTimeoutSeconds": 10,
            "HealthyThresholdCount": 5,
            "UnhealthyThresholdCount": 2,
            "HealthCheckPath": "/healthz.html",
            "Matcher": {
                "HttpCode": "200"
            },
            "LoadBalancerArns": [
                "arn:aws:elasticloadbalancing:us-east-1:533267186874:loadbalancer/app/test-backofficefrontend-lb/6721d13b8aad4bd1"
            ],
            "TargetType": "ip",
            "ProtocolVersion": "HTTP1",
            "IpAddressType": "ipv4"
        },
        {
            "TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:533267186874:targetgroup/TestSt-testm-W2PLGYCYO3NA/84e37f2be9769802",
            "TargetGroupName": "TestSt-testm-W2PLGYCYO3NA",
            "Protocol": "HTTP",
            "Port": 80,
            "VpcId": "vpc-0daab6dbe1f80c361",
            "HealthCheckProtocol": "HTTP",
            "HealthCheckPort": "traffic-port",
            "HealthCheckEnabled": true,
            "HealthCheckIntervalSeconds": 30,
            "HealthCheckTimeoutSeconds": 10,
            "HealthyThresholdCount": 5,
            "UnhealthyThresholdCount": 2,
            "HealthCheckPath": "/healthz.html",
            "Matcher": {
                "HttpCode": "200"
            },
            "LoadBalancerArns": [
                "arn:aws:elasticloadbalancing:us-east-1:533267186874:loadbalancer/app/test-mobileappbackend-lb/c85648b4e24646b4"
            ],
            "TargetType": "ip",
            "ProtocolVersion": "HTTP1",
            "IpAddressType": "ipv4"
        }
    ]
}
  1. aws elbv2 describe-target-health --target-group-arn arn:aws:elasticloadbalancing:us-east-1:533267186874:targetgroup/TestSt-testb-YBCCMPDKJYVP/ee7f7b52f9d4fce5
{
    "TargetHealthDescriptions": [
        {
            "Target": {
                "Id": "10.0.3.229",
                "Port": 80,
                "AvailabilityZone": "us-east-1b"
            },
            "HealthCheckPort": "80",
            "TargetHealth": {
                "State": "draining",
                "Reason": "Target.DeregistrationInProgress",
                "Description": "Target deregistration is in progress"
            }
        },
        {
            "Target": {
                "Id": "10.0.3.50",
                "Port": 80,
                "AvailabilityZone": "us-east-1b"
            },
            "HealthCheckPort": "80",
            "TargetHealth": {
                "State": "draining",
                "Reason": "Target.DeregistrationInProgress",
                "Description": "Target deregistration is in progress"
            }
        }
    ]
}
asp.net .net aws-fargate
1个回答
1
投票

事实证明,中间件代码中有逻辑可以确定正在使用的浏览器。 有一个异常处理程序未记录任何消息。 检查浏览器类型的代码抱怨并抛出 500 状态代码,但没有日志记录。 一旦我弄清楚了这一点,问题就很容易解决,因为我忽略了健康端点的中间件代码

© www.soinside.com 2019 - 2024. All rights reserved.