【发布时间】:2018-11-09 20:48:17
【问题描述】:
这是一个非常具体的错误,过去几天我一直在调查它,但遇到了死胡同。
我的蛋糕构建脚本中的一个任务是尝试检查弹性 beanstalk 环境是否已准备好。我们一直在使用这个插件 (https://github.com/mathieukempe/Cake.AWS.ElasticBeanstalk) 我派生了 repo 以添加 DescribeEnvironments() 实现。如果我直接在控制台应用程序中运行插件代码,它就可以工作。但是,当我从蛋糕构建脚本运行它时,它会抛出 System.MissingMethodException: Method not found: 'System.String Amazon.Runtime.Internal.Util.StringUtils.FromDateTimeToISO8601(System.DateTime)'
不幸的是,我认为我是互联网上唯一遇到此问题的人。
下面是我的蛋糕脚本正在运行的任务:
Task("CheckEBEnvironment")
.Does((context) => {
var settings = CreateElasticBeanstalkSettings();
if (context.ApplicationVersionReady(settings, ebApplication, ebEnvironment, ebVersion)) {
Information("Environment ready.");
isReady = true;
} else {
Information("Environment not ready...");
}
});
下面是插件代码:
[CakeAliasCategory("AWS")]
[CakeNamespaceImport("Amazon")]
[CakeNamespaceImport("Amazon.ElasticBeanstalk")]
public static class ElasticBeanstalkAliases
{
private static IElasticBeanstalkManager CreateManager(this ICakeContext context)
{
return new ElasticBeanstalkManager(context.Environment, context.Log);
}
// ...
[CakeMethodAlias]
[CakeAliasCategory("ElasticBeanstalk")]
public static bool ApplicationVersionReady(this ICakeContext context, ElasticBeanstalkSettings settings, string applicationName, string environmentName, string versionLabel)
{
var manager = context.CreateManager();
return manager.ApplicationVersionReady(settings, applicationName, environmentName, versionLabel);
}
}
这里是实现:
public class ElasticBeanstalkManager : IElasticBeanstalkManager
{
private readonly ICakeEnvironment _Environment;
private readonly ICakeLog _Log;
/// <summary>
/// If the manager should output progrtess events to the cake log
/// </summary>
public bool LogProgress { get; set; }
public ElasticBeanstalkManager(ICakeEnvironment environment, ICakeLog log)
{
if (environment == null)
{
throw new ArgumentNullException("environment");
}
if (log == null)
{
throw new ArgumentNullException("log");
}
_Environment = environment;
_Log = log;
this.LogProgress = true;
}
//Request
private AmazonElasticBeanstalkClient GetClient(ElasticBeanstalkSettings settings)
{
if (settings == null)
{
throw new ArgumentNullException("settings");
}
if (settings.Region == null)
{
throw new ArgumentNullException("settings.Region");
}
if (settings.Credentials == null)
{
if (String.IsNullOrEmpty(settings.AccessKey))
{
throw new ArgumentNullException("settings.AccessKey");
}
if (String.IsNullOrEmpty(settings.SecretKey))
{
throw new ArgumentNullException("settings.SecretKey");
}
return new AmazonElasticBeanstalkClient(settings.AccessKey, settings.SecretKey, settings.Region);
}
else
{
return new AmazonElasticBeanstalkClient(settings.Credentials, settings.Region);
}
}
public bool ApplicationVersionReady(ElasticBeanstalkSettings settings, string applicationName, string environmentName, string versionLabel)
{
if (string.IsNullOrEmpty(applicationName))
{
throw new ArgumentNullException(nameof(applicationName));
}
if (string.IsNullOrEmpty(environmentName))
{
throw new ArgumentNullException(nameof(environmentName));
}
if (string.IsNullOrEmpty(versionLabel))
{
throw new ArgumentNullException(nameof(versionLabel));
}
var client = GetClient(settings);
var status = client.DescribeEnvironmentsAsync(new DescribeEnvironmentsRequest
{
ApplicationName = applicationName,
EnvironmentNames = new List<string>(new[] {environmentName}),
VersionLabel = versionLabel,
IncludeDeleted = false,
}).Result.Environments[0].Status.Value;
return status == "Ready";
}
}
这是整个异常消息:
System.AggregateException:发生一个或多个错误。 ---> System.MissingMethodException:找不到方法:'System.String Amazon.Runtime.Internal.Util.StringUtils.FromDateTimeToISO8601(System.DateTime)'。 在 Amazon.ElasticBeanstalk.Model.Internal.MarshallTransformations.DescribeEnvironmentsRequestMarshaller.Marshall(DescribeEnvironmentsRequest publicRequest) 在 Amazon.Runtime.Internal.Marshaller.PreInvoke(IExecutionContext executionContext) 在 Amazon.Runtime.Internal.Marshaller.InvokeAsync[T](IExecutionContext executionContext) 在 Amazon.Runtime.Internal.CallbackHandler.d__9
1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.ErrorCallbackHandler.<InvokeAsync>d__51.MoveNext() --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在 Amazon.Runtime.Internal.MetricsHandler.d__11.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task1.GetResultCore(布尔 waitCompletionNotification) 在 Cake.AWS.ElasticBeanstalk.ElasticBeanstalkManager.ApplicationVersionReady(ElasticBeanstalkSettings 设置,字符串应用程序名称,字符串环境名称,字符串版本标签) 在提交#0.b__0_11(ICakeContext 上下文) --->(内部异常#0)System.MissingMethodException:找不到方法:'System.String Amazon.Runtime.Internal.Util.StringUtils.FromDateTimeToISO8601(System.DateTime)'。 在 Amazon.ElasticBeanstalk.Model.Internal.MarshallTransformations.DescribeEnvironmentsRequestMarshaller.Marshall(DescribeEnvironmentsRequest publicRequest) 在 Amazon.Runtime.Internal.Marshaller.PreInvoke(IExecutionContext executionContext) 在 Amazon.Runtime.Internal.Marshaller.InvokeAsync[T](IExecutionContext executionContext) 在 Amazon.Runtime.Internal.CallbackHandler.d__91.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.ErrorCallbackHandler.<InvokeAsync>d__51.MoveNext() --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在 Amazon.Runtime.Internal.MetricsHandler.d__1`1.MoveNext()
我的猜测是,蛋糕上下文在某处为请求设置了日期时间,这是亚马逊无法处理的格式。如果有人有任何想法或遇到类似问题,我将不胜感激。
【问题讨论】:
标签: c# .net amazon-elastic-beanstalk iso8601 cakebuild