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

apt packages from config #35

Closed
wants to merge 10 commits into from
Closed

apt packages from config #35

wants to merge 10 commits into from

Conversation

yanksyoon
Copy link
Contributor

Applicable spec: N/A

Overview

Allow installing apt packages through configuration.

Rationale

To automate setup of agents.

Juju Events Changes

  • on config changed: install apt packages from charm config.

Module Changes

  • service: Added method to install apt packages.

Library Changes

None.

Checklist

@yanksyoon yanksyoon requested a review from a team as a code owner May 8, 2024 04:11
src/charm.py Outdated Show resolved Hide resolved
self.jenkins_agent_service.install_apt_packages(self.state.apt_packages)
except service.PackageInstallError as exc:
logger.error("Error installing apt packages %s", exc)
self.model.unit.status = ops.BlockedStatus("Error installing apt packages: %s")
Copy link

Choose a reason for hiding this comment

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

Does service.PackageInstallError excludes network-related errors?
I would think network-related error would not need to go to block state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The apt lib provided uses subprocess.run under the hood so there's not much ways to differentiate the network related errors. What the lib does expose are errors like PackageNotFound, which was suitable for user to unblock by re-configuring the config option.
Do you think ErrorState might be more well-fitting for both cases?

Copy link

Choose a reason for hiding this comment

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

For error that requires config change, it should be in block state.
If the PackageNotFound only is thrown when user need to unblock it, then it should use BlockedState.

For network-related it should be error state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since network related errors would not be caught (subprocess error would be raised here) - it should fallthrough and go into ErroredState automatically.

Copy link
Contributor

github-actions bot commented May 9, 2024

Test coverage for 442c9bd

Name                    Stmts   Miss Branch BrPart  Cover   Missing
-------------------------------------------------------------------
src/agent_observer.py      42      0      4      0   100%
src/charm.py               69      0     10      0   100%
src/charm_state.py         66      4     12      1    94%   116, 191-193
src/service.py            109      5     16      5    92%   95-97, 109->121, 154, 186, 223->227, 225->223
-------------------------------------------------------------------
TOTAL                     286      9     42      6    95%

Static code analysis report

Run started:2024-05-09 06:11:22.008866

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 1260
  Total lines skipped (#nosec): 0
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

@yanksyoon
Copy link
Contributor Author

Closing - the apt packages should be installed via jobs

@yanksyoon yanksyoon closed this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants