Skip to content

Commit

Permalink
Fix error and success handling on image pull
Browse files Browse the repository at this point in the history
We have shown error on every pull because we tried to parse the whole
response as one JSON, but in fact it is a group of JSONs. That meant we
failed to notice the fact that we were not showing any useful error when
downloading actually failed. (We always just shown that we could not
parse the response)

Fixes #640
  • Loading branch information
marusak committed Jan 4, 2021
1 parent 0d039c4 commit d4cdfa7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,18 @@ export function pullImage(system, reference) {
reference: reference,
};
podmanCall("libpod/images/pull", "POST", options, system)
.then(reply => resolve(JSON.parse(reply)))
.then(r => {
// Need to check the last response if it contains error
const responses = r.trim().split("\n");
const response = JSON.parse(responses[responses.length - 1]);
if (response.error) {
response.message = response.error;
reject(response);
} else if (response.cause) // present for 400 and 500 errors
reject(response);
else
resolve();
})
.catch(reject);
});
}
3 changes: 3 additions & 0 deletions test/check-application
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@ class TestApplication(testlib.MachineCase):
b.wait_visible('#containers-images td[data-label="Name"]:contains("{0}")'.format(self.imageName))
checkImage(b, "localhost:5000/{0}:{1}".format(self.imageName, self.imageTag or "latest"), "system" if self.user == "system" else "admin")

# Confirm that no error has happened
b.wait_not_present('h4.pf-c-alert__title:contains("Failed to download image")')

# Find out this image ID
self.imageSha = execute(self.user == "system", "podman inspect --format '{{{{.Id}}}}' localhost:5000/{0}:{1}".format(self.imageName, self.imageTag or "latest")).strip()

Expand Down

0 comments on commit d4cdfa7

Please sign in to comment.