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

better handling of exceptions from AWS/S3 #1643

Merged
merged 1 commit into from
May 23, 2024
Merged

better handling of exceptions from AWS/S3 #1643

merged 1 commit into from
May 23, 2024

Conversation

ab77
Copy link
Contributor

@ab77 ab77 commented May 21, 2024

.. required (ideally) by balena-io/open-balena#141

We have two contracts repos, one is private and the other public.

So open-balena-api can't access the private repo, to check which device types are private, but it can enumerate the entire images bucket, which has with public List ACL enabled. Since it can see private devices in the enumerated list, the API will try to access various assets, but will get back a 403 from S3 API, since the objects themselves don't have public-read enabled. This behaviour produces a lot of exceptions in the API logs and this is what this PR attempts to make better.

A more complete solution would probably require rethinking private/public DT handling in open-balena-api vs. balena-api.

.. in any case, events now reflected in the logs as follows:

...
May 21 19:30:31 45abc1b164c4 api[22260]: Forbidden (403): images/coral-dev/2.101.1+rev1/IGNORE belongs to a private device type or has incorrect permissions
May 21 19:30:31 45abc1b164c4 api[22260]: Forbidden (403): images/asus-tinker-edge-t/2.101.1+rev1/IGNORE belongs to a private device type or has incorrect permissions
...
May 21 22:58:39 45abc1b164c4 api[46805]: AccessDenied (403): images/imx8mmebcrs08a2/2.108.1+rev3/device-type.json belongs to a private device type or has incorrect permissions
May 21 22:58:39 45abc1b164c4 api[46805]: AccessDenied (403): images/bigmak-imx8m-plus/2.114.6/device-type.json belongs to a private device type or has incorrect permissions

@ab77 ab77 requested a review from a team May 21, 2024 23:37
@flowzone-app flowzone-app bot enabled auto-merge May 21, 2024 23:47
@ab77 ab77 requested a review from joshbwlng May 22, 2024 21:38
.. otherwise when processing device types and hitting private DTs,
openBalena generates lots of noise/exceptions in the logs

* also correct systemd unit

Co-authored-by: Josh Bowling <45343541+joshbwlng@users.noreply.github.com>

change-type: patch
@@ -2,6 +2,7 @@
Description=open-balena-api
Requires=confd.service
After=confd.service
StartLimitIntervalSec=0
Copy link
Contributor

Choose a reason for hiding this comment

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

Just leaving a note here about the change. Apparently StartLimitIntervalSec is in fact a unit option and not a service option:

@flowzone-app flowzone-app bot merged commit 11388b0 into master May 23, 2024
47 checks passed
@flowzone-app flowzone-app bot deleted the ab77/patch branch May 23, 2024 21:14
return await req.promise();
} catch (err) {
// catch errors for private device types when running unauthenticated
logUnauthenticatedWarning(s3Client, s3Path, err);
Copy link
Member

Choose a reason for hiding this comment

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

@ab77 This atm silences ALL errors. Shouldn't we re-throw the error when this is a different type of error that logUnauthenticatedWarning didn't handle?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair point, we should make sure other errors aren't ignored

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants