Skip to content

Commit 03f9157

Browse files
committed
ExtractArtifact doesn't deal with http 409 status in HO client API level
1 parent 00ff5dc commit 03f9157

2 files changed

Lines changed: 1 addition & 33 deletions

File tree

frontend/src/libhoclient/host_orchestrator_client.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ type UserArtifactsClient interface {
110110
UploadArtifact(filename string) error
111111
// Extract artifact into the artifacts repository.
112112
// Artifacts are identified by their SHA256 checksum in the artifacts repository
113-
// Returning *hoapi.Operation as nil when there's an error or there's no operation for
114-
// extracting given artifact since it's already extracted before.
115113
ExtractArtifact(filename string) (*hoapi.Operation, error)
116114
// Creates a directory in the host where user artifacts can be uploaded to.
117115
CreateUploadDir() (string, error)
@@ -606,11 +604,7 @@ func (c *HostOrchestratorClientImpl) ExtractArtifact(filename string) (*hoapi.Op
606604
}
607605
op := &hoapi.Operation{}
608606
if err := c.HTTPHelper.NewPostRequest("/v1/userartifacts/"+checksum+"/:extract", nil).JSONResDo(op); err != nil {
609-
if apiCallError, ok := err.(*ApiCallError); ok && apiCallError.HTTPStatusCode == http.StatusConflict {
610-
return nil, nil
611-
} else {
612-
return nil, err
613-
}
607+
return nil, err
614608
}
615609
return op, nil
616610
}

frontend/src/libhoclient/host_orchestrator_client_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -222,32 +222,6 @@ func TestExtractArtifactSucceeds(t *testing.T) {
222222
}
223223
}
224224

225-
func TestExtractArtifactReceive409WhenArtifactIsAlreadyExtracted(t *testing.T) {
226-
tempDir := createTempDir(t)
227-
defer os.RemoveAll(tempDir)
228-
testFile := createTempFile(t, tempDir, "waldo", []byte("waldo"))
229-
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
230-
switch ep := r.Method + " " + r.URL.Path; ep {
231-
case "GET /v1/userartifacts/d2c055002a6cdf8dd9edf90c7a666cb5f7f2d25da8519ec206f56777d74e0c7d":
232-
writeOK(w, hoapi.StatArtifactResponse{})
233-
case "POST /v1/userartifacts/d2c055002a6cdf8dd9edf90c7a666cb5f7f2d25da8519ec206f56777d74e0c7d/:extract":
234-
writeErr(w, http.StatusConflict)
235-
default:
236-
t.Fatal("unexpected endpoint: " + ep)
237-
}
238-
}))
239-
defer ts.Close()
240-
client := NewHostOrchestratorClient(ts.URL)
241-
242-
op, err := client.ExtractArtifact(testFile)
243-
if err != nil {
244-
t.Fatal(err)
245-
}
246-
if op != nil {
247-
t.Fatal("unexpected operation: " + op.Name)
248-
}
249-
}
250-
251225
func TestCreateCVDWithUserProjectOverride(t *testing.T) {
252226
fakeRes := &hoapi.CreateCVDResponse{CVDs: []*hoapi.CVD{{Name: "1"}}}
253227
token := "foo"

0 commit comments

Comments
 (0)