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

Explore information passing from the workload container to the charm #6

Closed
mvlassis opened this issue Nov 22, 2024 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@mvlassis
Copy link
Collaborator

mvlassis commented Nov 22, 2024

Context

This exploration task follows #5.

This is the third part of the exploration for the github-profiles-automator charm. This part includes using the prototype charm that has been written in the second part, and expanding the following:

  • Writing charm code that watches for the Pebble notify event, and the respective event handler
  • Deciding and implementing how the charm code will access the information of the fetched repository that exists in the workload container

What needs to get done

  1. Look into Pebble notices and how we can watch for the event that is called by the wrapper script in the workload container
  2. Decide on a mechanism for passing the repository data from the charm code
  3. Implement the event handler code using functions from the library that @kimwnasptd is writing, see: Create the common library for Profiles Automator charm(s) #8)

Definition of Done

  • A prototype charm for github-profiles-automator that can pull from a repository, notify the charm, and the charm responding to the notification, and reconciling with the newly updated data.
@mvlassis mvlassis added the enhancement New feature or request label Nov 22, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/KF-6586.

This message was autogenerated

@mvlassis
Copy link
Collaborator Author

Information Passing

We can specify a storage object of type filesystem in the charmcraft.yaml file, which creates a PVC that can be accessed by both the workload and the charm container. We have to mount this PVC into the workload container using the mounts field in charmcraft.yaml, and specify the location that we use in the --root option of the git-sync command.

Pebble notices

We can use Pebble notices to pass a message from the workload container to the charm. I've written a very simple wrapper script that simply calls pebble notify:

#!/bin/sh
/charm/bin/pebble notify github-profile-automator.com/sync

Note that the notification key (in this case github-profies-automator.com/sync) must have a specific format as specified in the documentation.

We can then add an event handler in the charm, to execute code when it receives the pebble-custom-notice event. The handler will check that the notification has the expected key github-profies-automator.com/sync (and has not been activated from a different place), and in the final charm, the reconcile() function from #8 will be called.

@mvlassis mvlassis closed this as completed Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant