Skip to content

Commit

Permalink
Merge #11146 #11159
Browse files Browse the repository at this point in the history
11146: [auto] detect concurrent update error from local backend r=Zaid-Ajaj a=Zaid-Ajaj

Fixes #11108

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


11159: [dotnet] Simplify the format of docs comment of Output<T> r=Zaid-Ajaj a=Zaid-Ajaj

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. -->

Fixes #11120 because docfx cannot properly render ordered lists

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: Zaid Ajaj <zaid.naom@gmail.com>
  • Loading branch information
bors[bot] and Zaid-Ajaj committed Oct 26, 2022
3 parents 9f7a1a9 + 80674c0 + 06456d7 commit ed41404
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
@@ -0,0 +1,4 @@
changes:
- type: fix
scope: auto/dotnet,go,nodejs,python
description: detect concurrent update error from local backend.
Expand Up @@ -23,11 +23,13 @@ internal CommandException(string name, CommandResult result)
private static readonly Regex _notFoundRegexPattern = new Regex("no stack named.*found");
private static readonly Regex _alreadyExistsRegexPattern = new Regex("stack.*already exists");
private static readonly string _conflictText = "[409] Conflict: Another update is currently in progress.";
private static readonly string _localBackendConflictText = "the stack is currently locked by";

internal static CommandException CreateFromResult(CommandResult result)
=> _notFoundRegexPattern.IsMatch(result.StandardError) ? new StackNotFoundException(result)
: _alreadyExistsRegexPattern.IsMatch(result.StandardError) ? new StackAlreadyExistsException(result)
: result.StandardError.IndexOf(_conflictText, StringComparison.Ordinal) >= 0 ? new ConcurrentUpdateException(result)
: result.StandardError.IndexOf(_localBackendConflictText, StringComparison.Ordinal) >= 0 ? new ConcurrentUpdateException(result)
: new CommandException(result);
}
}
7 changes: 2 additions & 5 deletions sdk/dotnet/Pulumi/Core/Output.cs
Expand Up @@ -128,11 +128,8 @@ internal interface IOutput
/// <see cref="Output{T}"/>s are a key part of how Pulumi tracks dependencies between <see
/// cref="Resource"/>s. Because the values of outputs are not available until resources are
/// created, these are represented using the special <see cref="Output{T}"/>s type, which
/// internally represents two things:
/// <list type="number">
/// <item><description>An eventually available value of the output</description></item>
/// <item><description>The dependency on the source(s) of the output value</description></item>
/// </list>
/// internally represents two things: an eventually available value of the output and
/// the dependency on the source(s) of the output value.
/// In fact, <see cref="Output{T}"/>s is quite similar to <see cref="Task{TResult}"/>.
/// Additionally, they carry along dependency information.
/// <para/>
Expand Down
4 changes: 3 additions & 1 deletion sdk/go/auto/errors.go
Expand Up @@ -47,7 +47,9 @@ func IsConcurrentUpdateError(e error) bool {
return false
}

return strings.Contains(ae.stderr, "[409] Conflict: Another update is currently in progress.")
conflictText := "[409] Conflict: Another update is currently in progress."
localBackendConflictText := "the stack is currently locked by"
return strings.Contains(ae.stderr, conflictText) || strings.Contains(ae.stderr, localBackendConflictText)
}

// IsSelectStack404Error returns true if the error was a result of selecting a stack that does not exist.
Expand Down
10 changes: 6 additions & 4 deletions sdk/nodejs/automation/errors.ts
Expand Up @@ -62,14 +62,16 @@ export class StackAlreadyExistsError extends CommandError {
const notFoundRegex = new RegExp("no stack named.*found");
const alreadyExistsRegex = new RegExp("stack.*already exists");
const conflictText = "[409] Conflict: Another update is currently in progress.";
const localBackendConflictText = "the stack is currently locked by";

/** @internal */
export function createCommandError(result: CommandResult): CommandError {
const stderr = result.stderr;
return (
notFoundRegex.test(stderr) ? new StackNotFoundError(result) :
alreadyExistsRegex.test(stderr) ? new StackAlreadyExistsError(result) :
stderr.indexOf(conflictText) >= 0 ? new ConcurrentUpdateError(result) :
new CommandError(result)
notFoundRegex.test(stderr) ? new StackNotFoundError(result)
: alreadyExistsRegex.test(stderr) ? new StackAlreadyExistsError(result)
: stderr.indexOf(conflictText) >= 0 ? new ConcurrentUpdateError(result)
: stderr.indexOf(localBackendConflictText) >= 0 ? new ConcurrentUpdateError(result)
: new CommandError(result)
);
}
3 changes: 3 additions & 0 deletions sdk/python/lib/pulumi/automation/errors.py
Expand Up @@ -68,6 +68,7 @@ class InvalidVersionError(Exception):
not_found_regex = re.compile("no stack named.*found")
already_exists_regex = re.compile("stack.*already exists")
conflict_text = "[409] Conflict: Another update is currently in progress."
local_backend_conflict_text = "the stack is currently locked by"
inline_source_error_text = "python inline source runtime error"
runtime_error_regex = re.compile(
"failed with an unhandled exception|panic: runtime error|an unhandled error occurred:"
Expand All @@ -86,6 +87,8 @@ def create_command_error(command_result: "CommandResult") -> CommandError:
return StackAlreadyExistsError(command_result)
if conflict_text in stderr:
return ConcurrentUpdateError(command_result)
if local_backend_conflict_text in stderr:
return ConcurrentUpdateError(command_result)
if compilation_error_regex.search(stdout):
return CompilationError(command_result)
if inline_source_error_text in stdout:
Expand Down

0 comments on commit ed41404

Please sign in to comment.