Skip to content

Conversation

@pgvishnuram
Copy link
Contributor

@pgvishnuram pgvishnuram commented Oct 29, 2021

Problem:

  • pgbouncer_exporter run as non root
  • alpine version 3.13 vulnerabilities

How does this PR fix the problem above:

  • this commit adds a non root user and allows the pgbouncer exporter image to as non root user
  • migrating alpine image to latest version

^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

* update alpine base image to newer version
* changes to default version of pgbouncer exporter build script
* tag in values.yaml
'
@boring-cyborg boring-cyborg bot added area:helm-chart Airflow Helm Chart area:production-image Production image improvements and fixes labels Oct 29, 2021
LABEL maintainer="Apache Airflow Community <dev@airflow.apache.org>"

# Add a non root user
RUN addgroup -S pgbouncer_exporter \
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we are defining userid's in securityContext: , if the securityContext is left black or id's are in range of openshift we wont have any issues.

Copy link
Member

Choose a reason for hiding this comment

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

How about using user "nobody" (Like in the pgbouncer itself). I think this case is not the same as airflow - in airflow often people want to use different user or use the "arbitrary user id" to avoid some potential "user' clashes between containers running on the same machine and they evn might want to choose a specific ID because they can have volumes mounted with specific users etc. So it makes sense to support the "arbitrary user id". We also created a home directory there because airflow workers might spawn pretty much arbitrary operators (thus any external libraries/binaries) and many of those extarnal binaries/librraries might rely on the ${HOME} directory set and present (and writeable) - for example when they do any caching, they often do that in the ${HOME} dir.

But pgbouncer_exporter is really simple, "standalone" binary tool that is rather simple - it connects to pgbouncer, queries it for stats and exposes to prometheus via non-priviledged port (9127 which is > 1024) - so there is no need for any special priviledges, also it is unlikely it needs HOME directory (we can check that likely).

This is nobody user:

nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin

WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

If we use nobody, it makes a bit simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah both approaches are right and USER nobody option is simpler this service just exposes metrics on http endpoint. Thanks @potiuk

Copy link
Member

Choose a reason for hiding this comment

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

Can you make that change @pgvishnuram so we can merge this PR

@kaxil
Copy link
Member

kaxil commented Nov 3, 2021

ping @pgvishnuram Can you rebase the PR on the latest main and address the comment please

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Dec 19, 2021
@github-actions github-actions bot closed this Dec 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:helm-chart Airflow Helm Chart area:production-image Production image improvements and fixes stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants