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

Refactor k8s_service to use new module_utils code #327

Conversation

alinabuzachis
Copy link
Contributor

SUMMARY

Refactor k8s_service to use new module_utils code

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

k8s_service

@alinabuzachis
Copy link
Contributor Author

recheck

Signed-off-by: Alina Buzachis <[email protected]>
Signed-off-by: Alina Buzachis <[email protected]>
Copy link
Member

@gravesm gravesm left a comment

Choose a reason for hiding this comment

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

Unfortunately, we can't use run_module() here as it's currently written. The selector, type, and ports parameters get lost. We should also force the kind value. I'll need to think about whether we want to change that function and how. It may be easiest for now to just replicate what you need from run_module() here. We don't need the continue on error functionality because this module currently only works with a single resource definition.

@alinabuzachis alinabuzachis force-pushed the migrate_k8s_service branch 3 times, most recently from fdd3251 to 4852313 Compare January 18, 2022 11:13
Signed-off-by: Alina Buzachis <[email protected]>
@alinabuzachis
Copy link
Contributor Author

recheck

Copy link
Member

@gravesm gravesm left a comment

Choose a reason for hiding this comment

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

It may be worth adding one or two tests for this module at the very least just as a smoke test.

Comment on lines 219 to 220
if module.params["validate"] is not None:
module.warnings = validate(svc.client, module, definition)
Copy link
Member

Choose a reason for hiding this comment

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

This module does not support the validate param. I was a bit surprised to see that this passed CI since it should throw an AttributeError exception. Upon further investigation, I found that there is only a single test for this module and it uses ignore_errors: yes. 😱

Copy link
Contributor Author

@alinabuzachis alinabuzachis Jan 19, 2022

Choose a reason for hiding this comment

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

😭I wanted to replicate some things from the runner... but I didn't pay attention at the naming and the other things... my fault!
I also noticed k8s_service is not fully covered with integration tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gravesm Can we open some issues for the modules that are not fully covered by integration tests?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, definitely.

except CoreException as e:
if module.warnings:
e["msg"] += "\n" + "\n ".join(module.warnings)
module.fail_json(msg=e)
Copy link
Member

Choose a reason for hiding this comment

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

I think msg needs to be a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it needs. Thanks!


try:
result = perform_action(svc, definition, module.params)
Copy link
Member

Choose a reason for hiding this comment

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

This function is infinitely recursive as it just keeps calling itself. Did you mean to import the perform_action() function from runner.py?

Copy link
Contributor Author

@alinabuzachis alinabuzachis Jan 19, 2022

Choose a reason for hiding this comment

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

It should replicate perform_action() from runner. But I did it wrong and trying to check if possible.

@alinabuzachis alinabuzachis force-pushed the migrate_k8s_service branch 4 times, most recently from 33a81e9 to 43c4f7f Compare January 19, 2022 16:20
Signed-off-by: Alina Buzachis <[email protected]>
Copy link

@ansible-zuul ansible-zuul bot left a comment

Choose a reason for hiding this comment

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

LGTM!

@alinabuzachis
Copy link
Contributor Author

recheck

1 similar comment
@alinabuzachis
Copy link
Contributor Author

recheck

@Akasurde
Copy link
Member

recheck

1 similar comment
@alinabuzachis
Copy link
Contributor Author

recheck

@ansible-zuul ansible-zuul bot merged commit e390d80 into ansible-collections:2.x-refactor Jan 25, 2022
gravesm pushed a commit to gravesm/kubernetes.core that referenced this pull request May 26, 2022
…s#327)

Refactor k8s_service to use new module_utils code

SUMMARY

Refactor k8s_service to use new module_utils code

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

k8s_service

Reviewed-by: Mike Graves <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants