-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
The major changes here:
|
roles/lib_openshift/src/lib/base.py
Outdated
@@ -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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to remove rname
.
There was a problem hiding this 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: |
There was a problem hiding this comment.
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()] |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
43280d0
to
24a063e
Compare
@jarrpa, good catch. I pushed an update with rname removed. |
@kwoodson It would be good to replicate some of the changes being made to |
57543ae
to
43e6087
Compare
elif name is not None: | ||
cmd.append(name) | ||
else: | ||
raise OpenShiftCLIError('Either name or selector is required when calling delete.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
aos-ci-test |
@ewolinetz @ashcrow, I think this is ready now. |
aos-ci-test |
[test] |
- name: delete using selector | ||
oc_obj: | ||
namespace: test | ||
selector: name=mysql |
There was a problem hiding this comment.
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?
@kwoodson question regarding oc_obj test otherwise LGTM |
1965e75
to
4af5b18
Compare
Looks like another rebase has to occur. |
[merge] |
@ewolinetz @ashcrow would either of you mind 👍 on this? |
@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. |
@stevekuznetsov, the tests were failing randomly and intermittently.
I'm not sure why but the tests are the worst part about getting PRs into this repo. |
@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. |
[merge] |
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. |
aos-ci-test |
@arilivigni it looks like this PR status for |
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. |
aos-ci-test |
flake openshift/origin#10162 |
[merge] |
Evaluated for openshift ansible merge up to 92f3067 |
|
continuous-integration/openshift-jenkins/merge FAILURE (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_openshift_ansible/171/) (Base Commit: af85471) |
No description provided.