Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error and success handling on image pull #642

Merged
merged 1 commit into from
Jan 4, 2021
Merged
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
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