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

[Bug][zos_apf] Ensure idempotency in zos_apf when a library is added or removed #1893

Merged
merged 18 commits into from
Feb 5, 2025

Conversation

Rohitcodes28
Copy link
Collaborator

SUMMARY

Added ignore error in the apf add and delete

Fixes #1662

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

zos_apf

ADDITIONAL INFORMATION
add to the apf list with rc code 0 
ok: [zos_host] => {
    "apf_result": {
        "changed": true,
        "failed": false,
        "rc": 0,
        "stderr": "BGYSC4710E Add error: Dataset OMVSADM.TEST.TOUCH2 on volume 333333 is already present in APF list.\n",
        "stderr_lines": [
            "BGYSC4710E Add error: Dataset OMVSADM.TEST.TOUCH2 on volume 333333 is already present in APF list."
        ],
        "stdout": "",
        "stdout_lines": []
    }
}
 delete from the apf list with rc code0 

ok: [zos_host] => {
    "apf_delete": {
        "changed": true,
        "failed": false,
        "rc": 0,
        "stderr": "",
        "stderr_lines": [],
        "stdout": "EC01248A   2025022  21:45:54.00             ISF031I CONSOLE OMVS0000 ACTIVATED\nEC01248A   2025022  21:45:54.00            -SETPROG APF,DELETE,DSNAME=OMVSADM.TEST.TOUCH2,VOLUME=333333 \nEC01248A   2025022  21:45:54.00             CSV410I DATA SET OMVSADM.TEST.TOUCH2 ON VOLUME 333333 DELETED FROM APF LIST\n",
        "stdout_lines": [
            "EC01248A   2025022  21:45:54.00             ISF031I CONSOLE OMVS0000 ACTIVATED",
            "EC01248A   2025022  21:45:54.00            -SETPROG APF,DELETE,DSNAME=OMVSADM.TEST.TOUCH2,VOLUME=333333 ",
            "EC01248A   2025022  21:45:54.00             CSV410I DATA SET OMVSADM.TEST.TOUCH2 ON VOLUME 333333 DELETED FROM APF LIST"
        ]
    }
}

@Rohitcodes28 Rohitcodes28 marked this pull request as ready for review January 23, 2025 06:54
Copy link
Collaborator

@fernandofloresg fernandofloresg left a comment

Choose a reason for hiding this comment

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

Just a couple of comments.

plugins/modules/zos_apf.py Outdated Show resolved Hide resolved
@@ -0,0 +1,3 @@
bugfixes:
- zos_apf - if dataset present in the apf list it will not fail the command on addition or deletion to the list
Copy link
Collaborator

Choose a reason for hiding this comment

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

We try to (mostly) stick to the ansible development lifecycle guidelines. https://docs.ansible.com/ansible/latest/community/development_process.html, for bugfixes recommendation is to Use past tense to describe the problem and present tense to describe the fix..

When trying to add a library into the APF list that was already added the module would fail. Fix now won't fail the module and inform the user that the library was already in the APF list.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added the change logs as per the instructions

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest getting rid of the contraction: ...'Fix now will not fail the module, and will inform the user that the library is alread on the APF list."

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you @richp405 That sounds better. @Rohitcodes28 Can you update it ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure @fernandofloresg updated as per the suggestion.

@Rohitcodes28
Copy link
Collaborator Author

Rohitcodes28 commented Jan 29, 2025

It is also tested for delete as the -i option is described as " Ignore errors if dataset is already present during add operation or missing during delete operation. "
test_del_not_present test case output is attached below
test_del_not_present

Copy link
Collaborator

@richp405 richp405 left a comment

Choose a reason for hiding this comment

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

Nice start! There are suggestions for the changelog fragment and a code recommendation for zos_apf.py. Glad to see you starting to do code already.

tests/functional/modules/test_zos_apf_func.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@fernandofloresg fernandofloresg left a comment

Choose a reason for hiding this comment

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

Thanks for updating this just have another request, in this case when is added and is already present changed should be false.

 {
    "apf_result": {
        "changed": true,
        "failed": false,
        "rc": 0,
        "stderr": "BGYSC4710E Add error: Dataset OMVSADM.TEST.TOUCH2 on volume 333333 is already present in APF list.\n",
        "stderr_lines": [
            "BGYSC4710E Add error: Dataset OMVSADM.TEST.TOUCH2 on volume 333333 is already present in APF list."
        ],
        "stdout": "",
        "stdout_lines": []
    }
}

For the negative case, it should be the same case, when you try to remove it from the APF list and is not present, show changed false.

Sorry did not notice this before.

@Rohitcodes28
Copy link
Collaborator Author

It is tested that chaged False is coming if the file is already present while addition and same if file not present while deletion.
add duplicate
delete duplicate

Copy link
Collaborator

@fernandofloresg fernandofloresg left a comment

Choose a reason for hiding this comment

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

Just requested one change to the test case, overall is looking good. Please run the test cases in the ansible core pipeline. As an advice, zos_apf can fail in some volumes, so use the same EC you are using to test locally.

# Return code 16 if ZOAU < 1.2.0 and RC is 8 if ZOAU >= 1.2.0
assert result.get("rc") == 16 or result.get("rc") == 8
assert result.get("rc") == 0 or result.get("rc") == 16 or result.get("rc") == 8
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you do these checks by zoau version? Like if version 1.3.4 assert rc == 0 if lower rc == 16 or 8 .

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Version check is added along with testing the pipeline on the latest commits to the branch. both are successfulScreenshot 2025-02-03 at 9 05 48 PM
Screenshot 2025-02-03 at 9 33 42 PM

Copy link
Collaborator

@fernandofloresg fernandofloresg left a comment

Choose a reason for hiding this comment

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

LGTM!

@fernandofloresg
Copy link
Collaborator

Thanks for addressing the requested changes.

@fernandofloresg fernandofloresg changed the title Bug fix/1662/zos apf [Bug][zos_apf] Ensure idempotency in zos_apf when a library is added or removed Feb 4, 2025
@Rohitcodes28 Rohitcodes28 requested a review from richp405 February 5, 2025 13:59
Copy link
Collaborator

@richp405 richp405 left a comment

Choose a reason for hiding this comment

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

One spelling issue in the changelog file. Code looks fine.

@Rohitcodes28 Rohitcodes28 requested a review from richp405 February 5, 2025 17:10
@fernandofloresg fernandofloresg merged commit c5ce1fe into dev Feb 5, 2025
5 checks passed
@fernandofloresg fernandofloresg deleted the bug_fix/1662/zos_apf branch February 5, 2025 20:02
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.

[Bug] zos_apf fails if the dataset is already on the APF list
3 participants