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

Change action for config with restart in container_manage to created #743

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

cubeek
Copy link
Contributor

@cubeek cubeek commented Aug 30, 2024

Don't start container if restarted is set

If the container_manage is called with restart set, it means the
systemd handles the restart. In such case, we do not want containers to
be started because they will be started later by the systemd.

Resolves: OSPRH-9812

@bogdando
Copy link
Contributor

bogdando commented Sep 2, 2024

/lgtm

Copy link
Contributor

@slagle slagle left a comment

Choose a reason for hiding this comment

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

LGTM. the containers are started by the container_systemd task that follows this task, so everything will be started by systemd

@cubeek
Copy link
Contributor Author

cubeek commented Sep 5, 2024

I'm going to remove the WIP tag as this seems to be good to go.

@cubeek cubeek changed the title WIP: Change default action of container_manage to created Change default action of container_manage to created Sep 5, 2024
@openshift-ci openshift-ci bot removed the lgtm label Sep 5, 2024
Copy link
Contributor

openshift-ci bot commented Sep 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cubeek, slagle

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Sep 5, 2024
@slagle
Copy link
Contributor

slagle commented Sep 5, 2024

/retest

@@ -283,7 +283,7 @@ def exec_container(self, name, config):
def manage_container(self, name, config):
opts = {
'name': name,
'state': "started",
'state': "created",
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should add opts['state'] = "created" after L311 instead (i.e when systemd handles the restart) unless all containers in edpm are expected to be managed by systemd?

Copy link
Contributor

@rabi rabi Sep 6, 2024

Choose a reason for hiding this comment

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

This would also make start_order for containers irrelevant, though it seems we concurently manage every container individually with podman_container_manage and start_order we've in the configs is kind of useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean to override to created if the config comes with restart?

Copy link
Contributor

@rabi rabi Sep 10, 2024

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.

I'm not sure I understand. How I read the linked code is that it filters out configs from all_containers_hash based on restart=[some specific values]. But the all_containers_hash map comes from container_config_data module: https://github.com/openstack-k8s-operators/edpm-ansible/blob/main/roles/edpm_container_manage/tasks/main.yml#L30

As for the start_order - it confuses me again how is this related. The goal of this patch is to not start the containers after they are created because systemd will start them through its service files.

Copy link
Contributor

Choose a reason for hiding this comment

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

But the all_containers_hash map comes from container_config_data module

Thats right.. But, let me try to explain it better...

step 1: all_containers_hash comes from container_config_data module
step 2: edpm_container_manage module transforms that a container config and calls PodmanManager to create or start the containers.
step 3: container_systemd action plugin called to create the systemd units by fitering the containers that has restart=something.

What I'm suggesting is that rather than assuming that all containers would require systemd units and hence should only be created (state=created) by PodmanManager, we should only set state=created only for those configs that has restart=<always, unless-stopped> as those are the only ones where we would create systemd units and let PodmanManager start the other containers with (state=started).

Hope that calrifies.

Copy link
Contributor

@rabi rabi Oct 3, 2024

Choose a reason for hiding this comment

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

As for the start_order - it confuses me again how is this related

start_order is relevant as container configs are given to PodmanManager sorted by start_order . If you start all of the containers with systemd (and not by PodmanManager) there would be no order. However, start_order is not important atm in edpm-ansible (all configs have start_order 0) and I had removed them from all service container configs, as we start all services as standalone services individually one after the other and there is no order expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm still missing why would we need to override. The state is a parameter that can be passed from the caller. This patch just changes it to created by default but it still can be overridden by passing "state"="restarted" by the caller and it will be updated on L299. Those who do not want to manage container by the systemd can still pass "restarted". By setting the state after the ops.update() call we would take this functionality away, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

This patch just changes it to created by default in edpm-ansible

We're changing the default and not only for cases where we expect services to be managed by systemd. The default in podman module is started[1] and normally services don't specify state in config and this the behavior from tripleo-ansibe.

By setting the state after the ops.update() call we would take this functionality away, no?

When we want services to be managed by systemd, passing state='started/stopped' to this module has no meaning and for cleanup (state=absent), there is a separate role 'edpm_container_rm` that does not use this module[2].

If we still want to change this default, we should document that "By default containers are to be managed by systemd and have to provide restart=<>".Also, users have to use state=started when using this module if they don't want containers to be managed by systemd". If by chance user does not set restart=<> and state=started, the container would just be created and neither podman nor systemd would start it.

[1] https://github.com/containers/ansible-podman-collections/blob/master/plugins/module_utils/podman/podman_container_lib.py#L22
[2] https://github.com/openstack-k8s-operators/edpm-ansible/blob/main/roles/edpm_container_rm/tasks/edpm_podman_container_rm.yml#L87-L89

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Rabi for your patience. I hope I got it right

Copy link
Contributor

@rabi rabi left a comment

Choose a reason for hiding this comment

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

/lgtm

@rabi
Copy link
Contributor

rabi commented Oct 15, 2024

The commit message would need a change and also there is a merge commit in the PR.

@rabi rabi removed the lgtm label Oct 15, 2024
@cubeek
Copy link
Contributor Author

cubeek commented Oct 16, 2024

The commit message would need a change and also there is a merge commit in the PR.

Not sure if you meant really the commit message or the text in the PR. I copied the message from the commit message to be the same.

If the container_manage is called with `restart` set, it means the
systemd handles the restart. In such case, we do not want containers to
be started because they will be started later by the systemd.

Resolves: OSPRH-9812

Signed-off-by: Jakub Libosvar <[email protected]>
@rabi rabi changed the title Change default action of container_manage to created Change action for config with restart in container_manage to created Oct 16, 2024
@rabi
Copy link
Contributor

rabi commented Oct 16, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Oct 16, 2024
Copy link

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/f0fc96b47c444185a2d9f8895bbc2d26

✔️ openstack-k8s-operators-content-provider SUCCESS in 3h 31m 23s
podified-multinode-edpm-deployment-crc FAILURE in 1h 40m 24s
cifmw-crc-podified-edpm-baremetal FAILURE in 1h 41m 36s
edpm-ansible-tempest-multinode FAILURE in 1h 48m 22s
✔️ edpm-ansible-molecule-edpm_bootstrap SUCCESS in 5m 40s
✔️ edpm-ansible-molecule-edpm_podman SUCCESS in 4m 34s
✔️ edpm-ansible-molecule-edpm_module_load SUCCESS in 3m 57s
✔️ edpm-ansible-molecule-edpm_kernel SUCCESS in 7m 22s
✔️ edpm-ansible-molecule-edpm_libvirt SUCCESS in 7m 24s
✔️ edpm-ansible-molecule-edpm_nova SUCCESS in 8m 32s
✔️ edpm-ansible-molecule-edpm_frr SUCCESS in 6m 02s
✔️ edpm-ansible-molecule-edpm_iscsid SUCCESS in 4m 10s
✔️ edpm-ansible-molecule-edpm_ovn_bgp_agent SUCCESS in 6m 11s
✔️ edpm-ansible-molecule-edpm_ovs SUCCESS in 11m 24s
✔️ edpm-ansible-molecule-edpm_tripleo_cleanup SUCCESS in 3m 27s
✔️ edpm-ansible-molecule-edpm_tuned SUCCESS in 5m 56s
✔️ edpm-ansible-molecule-edpm_telemetry_power_monitoring SUCCESS in 6m 11s

@fao89
Copy link
Contributor

fao89 commented Oct 16, 2024

recheck

@openshift-merge-bot openshift-merge-bot bot merged commit d2f53c0 into openstack-k8s-operators:main Oct 16, 2024
35 checks passed
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.

5 participants