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

Fix using the default network manager in reset.yml #11678

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

KubeKyrie
Copy link
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:
Restart network using the active network management service. Not the one that are default for the OS.

Which issue(s) this PR fixes:

Fixes #11579

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Fix using the default network manager in reset.yml

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 31, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @KubeKyrie. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 31, 2024
@KubeKyrie KubeKyrie changed the title Fix using the default network manager in reset.yml [WIP]Fix using the default network manager in reset.yml Oct 31, 2024
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 31, 2024
@KubeKyrie KubeKyrie force-pushed the enhance-reset-network branch from f1c8098 to 0df2560 Compare November 1, 2024 04:05
@KubeKyrie KubeKyrie changed the title [WIP]Fix using the default network manager in reset.yml Fix using the default network manager in reset.yml Nov 1, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 1, 2024
@KubeKyrie
Copy link
Contributor Author

Test results:

TASK [reset : Restart active network services] *********************************************************************
task path: /kubespray/roles/reset/tasks/main.yml:432
changed: [controller-1] => (item={'changed': False, 'stdout': 'active', 'stderr': '', 'rc': 0, 'cmd': 'systemctl is-active systemd-networkd', 'start': '2024-11-01 11:55:06.687265', 'end': '2024-11-01 11:55:06.703373', 'delta': '0:00:00.016108', 'msg': '', 'invocation': {'module_args': {'_raw_params': 'systemctl is-active systemd-networkd', '_uses_shell': True, 'expand_argument_vars': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['active'], 'stderr_lines': [], 'failed': False, 'item': 'systemd-networkd', 'ansible_loop_var': 'item'}) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "daemon_reexec": false,
            "daemon_reload": false,
            "enabled": null,
            "force": null,
            "masked": null,
            "name": "systemd-networkd",
            "no_block": false,
            "scope": "system",
            "state": "restarted"
        }
    },
    "item": {
        "ansible_loop_var": "item",
        "changed": false,
        "cmd": "systemctl is-active systemd-networkd",
        "delta": "0:00:00.016108",
        "end": "2024-11-01 11:55:06.703373",
        "failed": false,
        "invocation": {
            "module_args": {
                "_raw_params": "systemctl is-active systemd-networkd",
                "_uses_shell": true,
                "argv": null,
                "chdir": null,
                "creates": null,
                "executable": null,
                "expand_argument_vars": true,
                "removes": null,
                "stdin": null,
                "stdin_add_newline": true,
                "strip_empty_ends": true
            }
        },
        "item": "systemd-networkd",
        "msg": "",
        "rc": 0,
        "start": "2024-11-01 11:55:06.687265",
        "stderr": "",
        "stderr_lines": [],
        "stdout": "active",
        "stdout_lines": [
            "active"
        ]
    },
root@controller-1:~# systemctl status systemd-networkd
● systemd-networkd.service - Network Service
     Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2024-11-01 11:55:08 CST; 27s ago
TriggeredBy: ● systemd-networkd.socket
       Docs: man:systemd-networkd.service(8)
   Main PID: 1552329 (systemd-network)
     Status: "Processing requests..."
      Tasks: 1 (limit: 9440)
     Memory: 2.1M
     CGroup: /system.slice/systemd-networkd.service
             └─1552329 /lib/systemd/systemd-networkd

@tico88612
Copy link
Member

@KubeKyrie Thanks for the PR, but pre-commit has some failed messages. Could you check for this?

@KubeKyrie KubeKyrie force-pushed the enhance-reset-network branch 2 times, most recently from 4974282 to 9b523bc Compare November 4, 2024 09:14
@tico88612
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 4, 2024
@KubeKyrie
Copy link
Contributor Author

@tico88612 Ok, Thanks.

@yankay
Copy link
Member

yankay commented Nov 7, 2024

Great Idea, Thanks @KubeKyrie
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KubeKyrie, yankay

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 7, 2024
Comment on lines 418 to 423
vars:
network_services:
- NetworkManager
- systemd-networkd
- networking
- network
Copy link
Contributor

Choose a reason for hiding this comment

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

drop this var and just specify the list directly in the loop below.

block:
- name: Gather active network services
# noqa command-instead-of-module
command: systemctl is-active {{ item }}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use the systemd module with only name to check for status.

systemd:
  name: <service>
register: service

service.status.ActivateState == 'active'

systemd:
name: "{{ item.item }}"
state: restarted
loop: "{{ service_status.results }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
loop: "{{ service_status.results }}"
loop: "{{ service_status.results | selectattr('status.ActiveState', '==', 'active') | map(attribute='item' }}"

+ drop the when

Copy link
Member

Choose a reason for hiding this comment

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

Hello @KubeKyrie

Would you please check it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, thanks, I will check it.

@VannTen VannTen force-pushed the enhance-reset-network branch from 78bebbc to e3eca66 Compare December 10, 2024 21:47
@VannTen
Copy link
Contributor

VannTen commented Dec 10, 2024

/cc @tico88612

@VannTen VannTen force-pushed the enhance-reset-network branch from e3eca66 to 87f1efd Compare December 10, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reset.yml presume OS default network manager
5 participants