Bug 1466390 - [RFE] add selector option to oadm drain
[RFE] add selector option to oadm drain
Product: OpenShift Container Platform
Classification: Red Hat
Component: Command Line Interface (Show other bugs)
Unspecified Unspecified
medium Severity low
: ---
: 3.9.0
Assigned To: Juan Vallejo
Xingxing Xia
Depends On:
  Show dependency treegraph
Reported: 2017-06-29 09:59 EDT by Sergi Jimenez Romero
Modified: 2018-01-10 05:48 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Sergi Jimenez Romero 2017-06-29 09:59:16 EDT
> 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 18:52:50 EDT
Origin PR: https://github.com/openshift/origin/pull/16445
Comment 4 Juan Vallejo 2017-10-05 09:57:52 EDT
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 13:04:18 EDT

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?

Comment 9 Xingxing Xia 2018-01-10 05:48:32 EST
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 "" cordoned
error: unable to drain node "", aborting command...

There are pending nodes to be drained:
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 "" 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 "" 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.