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

Adding ability to delete by selector. Also variable name cleanup and update to use .format. #3840

Merged
merged 4 commits into from
Apr 6, 2017

Conversation

kwoodson
Copy link
Contributor

@kwoodson kwoodson commented Apr 3, 2017

No description provided.

@kwoodson kwoodson changed the title Adding ability to delete by selector. Also variable name cleanup. Adding ability to delete by selector. Also variable name cleanup and update to use .format. Apr 3, 2017
@kwoodson kwoodson requested review from ashcrow and tbielawa April 3, 2017 18:28
@kwoodson kwoodson self-assigned this Apr 3, 2017
@kwoodson
Copy link
Contributor Author

kwoodson commented Apr 3, 2017

The major changes here:

  • lib/base.py: These changes allow specifically oc_obj to delete by name or by selector. They propagated to all files as a consequence. PR looks large but change set is small.
  • I did not like rname as it used to conflict with the way ansible import * was required which conflicted with the name variable. I renamed back to name as we no longer do the import the same way.
  • I added an integration/oc_obj.yml test file. It failed first, then it passed when my changes were added.
  • I removed the restriction set on deletion requiring a name being passed in class/oc_obj.py.

@@ -95,11 +95,15 @@ def _create(self, fname):
'''call oc create on a filename'''
return self.openshift_cmd(['create', '-f', fname])

def _delete(self, resource, rname, selector=None):
def _delete(self, resource, name=None, selector=None):
'''call oc delete on a resource'''
cmd = ['delete', resource, rname]
Copy link
Contributor

Choose a reason for hiding this comment

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

Forgot to remove rname.

Copy link
Member

@ashcrow ashcrow left a comment

Choose a reason for hiding this comment

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

❤️ the move to format()!

'''call oc delete on a resource'''
cmd = ['delete', resource, rname]
if selector:
cmd.append('--selector=%s' % selector)
if selector is not None:
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -941,7 +945,7 @@ def _process(self, template_name, create=False, params=None, template_data=None)
else:
cmd.append(template_name)
if params:
param_str = ["%s=%s" % (key, value) for key, value in params.items()]
param_str = ["{}={}".format(key, value) for key, value in params.items()]
Copy link
Member

Choose a reason for hiding this comment

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

👍

cmd.append('--selector=%s' % selector)
elif rname:
cmd.append(rname)
if selector is not None:
Copy link
Member

Choose a reason for hiding this comment

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

Is this a "one or the other" thing as well? If so, should it raise if both are provided? Same question for other similar operations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ashcrow, good question. I just tried a query with both given and it is an error when both are supplied.

oc get template mysql --selector=template=mysql-ephemeral-template --all-namespaces
error: name cannot be provided when a selector is specified

I will update the module params to be mutually-exclusive.

@kwoodson kwoodson force-pushed the oc_obj_delete_selector branch from 43280d0 to 24a063e Compare April 3, 2017 20:19
@kwoodson
Copy link
Contributor Author

kwoodson commented Apr 3, 2017

@jarrpa, good catch. I pushed an update with rname removed.

@jarrpa
Copy link
Contributor

jarrpa commented Apr 3, 2017

@kwoodson It would be good to replicate some of the changes being made to _delete() in _get(), though that's a different PR. :)

@kwoodson kwoodson force-pushed the oc_obj_delete_selector branch from 57543ae to 43e6087 Compare April 3, 2017 20:37
elif name is not None:
cmd.append(name)
else:
raise OpenShiftCLIError('Either name or selector is required when calling delete.')
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@ashcrow
Copy link
Member

ashcrow commented Apr 3, 2017

************ Module oc_obj
roles/lib_openshift/library/oc_obj.py:1453: [C0330(bad-continuation), ] Wrong continued indentation before block.
           '\"%s\" not found' % self.name in results['stderr']):
           ^|   |
roles/lib_openshift/library/oc_obj.py:1650: [C0326(bad-whitespace), ] Exactly one space required after comma
        mutually_exclusive=[["content", "files"],["selector", "name"]],

@kwoodson
Copy link
Contributor Author

kwoodson commented Apr 4, 2017

aos-ci-test

@kwoodson
Copy link
Contributor Author

kwoodson commented Apr 4, 2017

@ewolinetz @ashcrow, I think this is ready now.

@ashcrow
Copy link
Member

ashcrow commented Apr 4, 2017

aos-ci-test

@ashcrow
Copy link
Member

ashcrow commented Apr 4, 2017

[test]

- name: delete using selector
oc_obj:
namespace: test
selector: name=mysql
Copy link
Contributor

Choose a reason for hiding this comment

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

does this work as a selector? I would expect that the DC you specify above would have a value here:
https://github.com/openshift/openshift-ansible/pull/3840/files#diff-a1c29b1eb7b762844f88ac765306d442R138

Can we add a list operation right before this delete to verify that we see the object before we delete it as we do on 194?

@ewolinetz
Copy link
Contributor

@kwoodson question regarding oc_obj test otherwise LGTM

@openshift-bot
Copy link

success: aos-ci-jenkins/OS_unit_tests for 54c6226 (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.4_NOT_containerized, aos-ci-jenkins/OS_3.4_NOT_containerized_e2e_tests" for 54c6226 (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.4_containerized, aos-ci-jenkins/OS_3.4_containerized_e2e_tests" for 54c6226 (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.5_NOT_containerized, aos-ci-jenkins/OS_3.5_NOT_containerized_e2e_tests" for 54c6226 (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.5_containerized, aos-ci-jenkins/OS_3.5_containerized_e2e_tests" for 54c6226 (logs)

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 5, 2017
@kwoodson kwoodson force-pushed the oc_obj_delete_selector branch 2 times, most recently from 1965e75 to 4af5b18 Compare April 5, 2017 13:22
@ashcrow
Copy link
Member

ashcrow commented Apr 5, 2017

Looks like another rebase has to occur.

@kwoodson
Copy link
Contributor Author

kwoodson commented Apr 5, 2017

[merge]

@kwoodson
Copy link
Contributor Author

kwoodson commented Apr 5, 2017

@ewolinetz @ashcrow would either of you mind 👍 on this?

@stevekuznetsov
Copy link
Contributor

@kwoodson you ran the tests a number of times over and over here without changing code -- what was the issue? If there are flakes in the tests, we should all be making issues and tracking the flakes so we can adequately prioritize fixing high-frequency flakes.

@kwoodson
Copy link
Contributor Author

kwoodson commented Apr 5, 2017

@stevekuznetsov, the tests were failing randomly and intermittently.

  • No such file or directory
  • error: aos-ci-jenkins/OS_3.5_containerized for 92f3067 (logs)

I'm not sure why but the tests are the worst part about getting PRs into this repo.

@stevekuznetsov
Copy link
Contributor

@kwoodson a test failing intermittently is the textbook definition of a flake. Please log issues for them and help the organization work on eliminating them.

@kwoodson
Copy link
Contributor Author

kwoodson commented Apr 5, 2017

[merge]

@sdodson
Copy link
Member

sdodson commented Apr 5, 2017

comments above say unit tests were fine, but the status in github is marked failed. I really hate to do this, but lets give this one more shot.

@sdodson
Copy link
Member

sdodson commented Apr 5, 2017

aos-ci-test

@openshift-bot
Copy link

success: aos-ci-jenkins/OS_unit_tests for 92f3067 (logs)

@openshift-bot
Copy link

error: aos-ci-jenkins/OS_3.6_containerized for 92f3067 (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.5_NOT_containerized, aos-ci-jenkins/OS_3.5_NOT_containerized_e2e_tests" for 92f3067 (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.5_containerized, aos-ci-jenkins/OS_3.5_containerized_e2e_tests" for 92f3067 (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.6_NOT_containerized, aos-ci-jenkins/OS_3.6_NOT_containerized_e2e_tests" for 92f3067 (logs)

@stevekuznetsov
Copy link
Contributor

@arilivigni it looks like this PR status for aos-ci-jenkins/OS_unit_tests can't recover from having failed once before

@sdodson
Copy link
Member

sdodson commented Apr 6, 2017

I don't actually see the unit tests having failed at any time in the past week. I made a change to add system container jobs, i'm going to revert that.

@sdodson
Copy link
Member

sdodson commented Apr 6, 2017

aos-ci-test

@kwoodson
Copy link
Contributor Author

kwoodson commented Apr 6, 2017

flake openshift/origin#10162

@kwoodson
Copy link
Contributor Author

kwoodson commented Apr 6, 2017

[merge]

@openshift-bot
Copy link

Evaluated for openshift ansible merge up to 92f3067

@openshift-bot
Copy link

success: aos-ci-jenkins/OS_unit_tests for 92f3067 (logs)

@sdodson
Copy link
Member

sdodson commented Apr 6, 2017

I just pushed the context smashing fix, so that merge is going to fail, aborting it.
Nevermind, I'll let the bots race and hope that aos ci test wins.

@openshift-bot
Copy link

error: aos-ci-jenkins/OS_3.6_containerized for 92f3067 (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.6_NOT_containerized, aos-ci-jenkins/OS_3.6_NOT_containerized_e2e_tests" for 92f3067 (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.5_NOT_containerized, aos-ci-jenkins/OS_3.5_NOT_containerized_e2e_tests" for 92f3067 (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.5_containerized, aos-ci-jenkins/OS_3.5_containerized_e2e_tests" for 92f3067 (logs)

@openshift-bot
Copy link

continuous-integration/openshift-jenkins/merge FAILURE (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_openshift_ansible/171/) (Base Commit: af85471)

@sdodson sdodson merged commit ff988ba into openshift:master Apr 6, 2017
@kwoodson kwoodson deleted the oc_obj_delete_selector branch September 18, 2017 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants