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

ifcfg files reading issue fix #487

Conversation

Jaganathancse
Copy link
Contributor

No description provided.

@openshift-ci openshift-ci bot requested review from abays and stuggi November 8, 2023 11:53
@Jaganathancse Jaganathancse force-pushed the kernel-args-reboot-issue branch from f7c2ef8 to 96a93d5 Compare November 8, 2023 11:59
@Jaganathancse
Copy link
Contributor Author

recheck

@Jaganathancse
Copy link
Contributor Author

/retest-required

@Jaganathancse
Copy link
Contributor Author

recheck

@Jaganathancse
Copy link
Contributor Author

/retest-required

@@ -62,8 +62,7 @@
# This condition will list all the interfaces except the one with valid IP (which is Provisioning network at this stage)
# Simpler Version - hostvars[inventory_hostname]['ansible_' + iface_name ]['ipv4'] is undefined
- hostvars[inventory_hostname]['ansible_facts'][item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_')]['ipv4'] is undefined
loop:
- "{{ ifcfg_files.files }}"
loop: "{{ ifcfg_files.files | flatten(levels=1) }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is flatten needed? Can you explain in a more detailed commit message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@slagle this task requires looping ifcfg files and not list of ifcfg files list, missing file parameters in looping var 'item'. so changed to loop only list of ifcfg files and tested working fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

ifcfg_file.files is the list of files, call it X. flatten would take any of those X list items and if that item Y is also a list, it will take the list items of Y and add them to X.

See sample output:

shell-el7.hosts.prod.upshift.rdu2.redhat.com | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "examined": 35,
    "files": [
        {
            "atime": 1701142182.7918751,
            "ctime": 1602802230.2658126,
            "dev": 64768,
            "gid": 0,
            "gr_name": "root",
            "inode": 67198113,
            "isblk": false,
            "ischr": false,
            "isdir": false,
            "isfifo": false,
            "isgid": false,
            "islnk": false,
            "isreg": true,
            "issock": false,
            "isuid": false,
            "mode": "0644",
            "mtime": 1590144273.0,
            "nlink": 1,
            "path": "/etc/sysconfig/network-scripts/ifcfg-lo",
            "pw_name": "root",
            "rgrp": true,
            "roth": true,
            "rusr": true,
            "size": 254,
            "uid": 0,
            "wgrp": false,
            "woth": false,
            "wusr": true,
            "xgrp": false,
            "xoth": false,
            "xusr": false
        },
        {
            "atime": 1701142182.7958753,
            "ctime": 1563746161.165,
            "dev": 64768,
            "gid": 0,
            "gr_name": "root",
            "inode": 67455073,
            "isblk": false,
            "ischr": false,
            "isdir": false,
            "isfifo": false,
            "isgid": false,
            "islnk": false,
            "isreg": true,
            "issock": false,
            "isuid": false,
            "mode": "0644",
            "mtime": 1563746161.165,
            "nlink": 1,
            "path": "/etc/sysconfig/network-scripts/ifcfg-eth0",
            "pw_name": "root",
            "rgrp": true,
            "roth": true,
            "rusr": true,
            "size": 211,
            "uid": 0,
            "wgrp": false,
            "woth": false,
            "wusr": true,
            "xgrp": false,
            "xoth": false,
            "xusr": false
        }
    ],
    "matched": 2,
    "msg": "All paths examined",
    "skipped_paths": {}
}

Can you provide more details about the actual error, with a sample of the error and describe how this fixes it, all in the commit message, that would be helpful in pushing this one forward.

Copy link
Contributor Author

@Jaganathancse Jaganathancse Nov 29, 2023

Choose a reason for hiding this comment

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

ifcfg_files.files is the list of dictionary, so looping works. issue item is again list item and not dictionary item when we use ' - "{{ ifcfg_files.files }}"'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we use '- "{{ ifcfg_files.files }}"', getting path is not found in item error. and working fine if we use only '{{ ifcfg_files.files }}'

Copy link
Contributor

Choose a reason for hiding this comment

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

You were likely getting the path is not found in item error because you were nesting the files lists in a new list passed to loop

Try just this:

loop: "{{ ifcfg_files.files }}"

instead of:

loop:
  - "{{ ifcfg_files.files }}"

then the flatten is likely not even necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated and working with no flatten.

@Jaganathancse Jaganathancse force-pushed the kernel-args-reboot-issue branch from 96a93d5 to e7925d5 Compare November 30, 2023 06:47
Copy link
Contributor

openshift-ci bot commented Nov 30, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Jaganathancse, rebtoor

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-merge-bot openshift-merge-bot bot merged commit cce7511 into openstack-k8s-operators:main Nov 30, 2023
29 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.

3 participants