Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sdk/azcore/internal/pollers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

// the well-known set of LRO status/provisioning state values.
const (
StatusCompleted = "Completed"
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.

While I'm not opposed to adding this, I believe this is in violation of the ARM RPC spec. Let me follow up on that.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, I was unaware of the spec. Just encountered the bug and tried to solve it this way :) . Let me know if there is a more elegant solution.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @jhendrixMSFT , any update on this?

If there is a better way we can fix the issue please let me know.

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.

Sorry for the delay, I just pinged the owners again to get their input on this.

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.

The service is in error here, it shouldn't be returned Completed. I'm following up with the service team to get this fixed.

StatusSucceeded = "Succeeded"
StatusCanceled = "Canceled"
StatusFailed = "Failed"
Expand All @@ -31,7 +32,7 @@ const (

// IsTerminalState returns true if the LRO's state is terminal.
func IsTerminalState(s string) bool {
return strings.EqualFold(s, StatusSucceeded) || strings.EqualFold(s, StatusFailed) || strings.EqualFold(s, StatusCanceled)
return strings.EqualFold(s, StatusSucceeded) || strings.EqualFold(s, StatusFailed) || strings.EqualFold(s, StatusCanceled) || strings.EqualFold(s, StatusCompleted)
}

// Failed returns true if the LRO's state is terminal failure.
Expand All @@ -44,6 +45,11 @@ func Succeeded(s string) bool {
return strings.EqualFold(s, StatusSucceeded)
}

// Completed return true if is terminal completed
func Completed(s string) bool {
return strings.EqualFold(s, StatusCompleted)
}

// returns true if the LRO response contains a valid HTTP status code
func StatusCodeValid(resp *http.Response) bool {
return exported.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusCreated, http.StatusNoContent)
Expand Down
2 changes: 2 additions & 0 deletions sdk/azcore/internal/pollers/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestIsTerminalState(t *testing.T) {
require.True(t, IsTerminalState("Succeeded"), "Succeeded is a terminal state")
require.True(t, IsTerminalState("failed"), "failed is a terminal state")
require.True(t, IsTerminalState("canceled"), "canceled is a terminal state")
require.True(t, IsTerminalState("Completed"), "Completed is a terminal state")
}

func TestStatusCodeValid(t *testing.T) {
Expand Down Expand Up @@ -90,6 +91,7 @@ func TestIsValidURL(t *testing.T) {
func TestFailed(t *testing.T) {
require.False(t, Failed("Succeeded"))
require.False(t, Failed("Updating"))
require.False(t, Failed("Completed"))
require.True(t, Failed("failed"))
}

Expand Down