Bug 1466390 - [RFE] add selector option to oadm drain
Summary: [RFE] add selector option to oadm drain
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 3.5.0
Hardware: Unspecified
OS: Unspecified
medium
low
Target Milestone: ---
: 3.9.0
Assignee: Juan Vallejo
QA Contact: Xingxing Xia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-06-29 13:59 UTC by Sergi Jimenez Romero
Modified: 2018-06-19 08:16 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Feature: new flag added to the `oc adm drain` command to allow selecting nodes by label. Reason: There was a need to be able to drain multiple nodes, without having to perform the `drain` operation on each individual node. Result: `oc adm drain` now supports a "--selector" flag which results in all nodes matching a given label being drained.
Clone Of:
Environment:
Last Closed: 2018-06-18 18:16:33 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:2013 0 normal SHIPPED_LIVE Important: OpenShift Container Platform 3.9 security, bug fix, and enhancement update 2018-06-27 22:01:43 UTC

Description Sergi Jimenez Romero 2017-06-29 13:59:16 UTC
> 3. What is the nature and description of the request?  

Having to specify nodes one by one is cumbersome in big clusters when doing maintenances.

> 4. Why does the customer need this? (List the business requirements here)  

Given that evacuate option is being deprecated, it'd be useful to have `drain` to take `selector` as option.

> 5. How would the customer like to achieve this? (List the functional requirements here)  

It should be possible to use a selector when using `drain` sub-command.

> 6. For each functional requirement listed, specify how Red Hat and the customer can test to confirm the requirement is successfully implemented.  

Using --selector together with drain should take all nodes having the specified selector.


> 10. List any affected packages or components.

Command line interface.

Comment 3 Juan Vallejo 2017-09-19 22:52:50 UTC
Origin PR: https://github.com/openshift/origin/pull/16445

Comment 4 Juan Vallejo 2017-10-05 13:57:52 UTC
Upstream PR has merged [1]. Waiting on Origin PR.

1. https://github.com/kubernetes/kubernetes/pull/52917

Comment 5 Sergi Jimenez Romero 2017-10-27 17:04:18 UTC
Hi!

the Origin PR seems stuck at:

 Submit Queue — Will not auto merge because kind/bug is missing

Besides, do we already have a target release for this RFE?

Thanks!

Comment 9 Xingxing Xia 2018-01-10 10:48:32 UTC
Now in v3.9.0-0.16.0, it includes --selector
# oc adm drain -h
...
  -l, --selector='': Selector (label query) to filter on
...

And the flag works
# oc adm drain --selector router=enabled
node "172.16.120.33" cordoned
error: unable to drain node "172.16.120.33", aborting command...

There are pending nodes to be drained:
 172.16.120.33
error: pods with local storage (use --delete-local-data to override): mongodb-1-2scgl, nodejs-mongodb-example-1-build, django-ex-1-build; DaemonSet-managed pods (use --ignore-daemonsets to ignore): apiserver-dwv59

# oc adm drain --selector router=enabled --delete-local-data --ignore-daemonsets
node "172.16.120.33" already cordoned
WARNING: Deleting pods with local storage: mongodb-1-2scgl, nodejs-mongodb-example-1-build, django-ex-1-build; Ignoring DaemonSet-managed pods: apiserver-dwv59
pod "asb-1-deploy" evicted
pod "asb-etcd-1-deploy" evicted
pod "nodejs-mongodb-example-1-build" evicted
pod "django-ex-1-build" evicted
pod "router-1-zz7pq" evicted
pod "docker-registry-1-kbrcv" evicted
pod "django-ex-1-s2hp5" evicted
pod "mongodb-1-2scgl" evicted
pod "nodejs-mongodb-example-1-xc5sk" evicted
pod "registry-console-1-jncc6" evicted
node "172.16.120.33" drained

# oc get po --all-namespaces
NAMESPACE                           NAME                             READY     STATUS    RESTARTS   AGE
default                             docker-registry-1-fdjqv          0/1       Pending   0          1m
default                             registry-console-1-g74bq         0/1       Pending   0          1m
default                             router-1-s7dnq                   0/1       Pending   0          1m
kube-service-catalog                apiserver-5ccf9                  1/1       Running   0          9h
kube-service-catalog                controller-manager-zjmwc         1/1       Running   2          9h
openshift-template-service-broker   apiserver-bwcn6                  1/1       Running   0          9h
openshift-template-service-broker   apiserver-dwv59                  1/1       Running   0          9h


Note You need to log in before you can comment on or make changes to this bug.