Bug 1429364

Summary: clear-route-status.sh can not clean the route status using option 'ALL' when there are more than 2 routes
Product: OpenShift Container Platform Reporter: zhaozhanqi <zzhao>
Component: NetworkingAssignee: Jacob Tanenbaum <jtanenba>
Networking sub component: router QA Contact: zhaozhanqi <zzhao>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: medium CC: aos-bugs, bbennett, eparis, tdawson, yadu
Version: 3.5.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: The command to create a list of routes was incorrect Consequence: Route statuses did not get deleted Fix: Improved the logic enumerating routes Result: Route statuses are correctly cleared
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-10 05:18:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description zhaozhanqi 2017-03-06 08:40:53 UTC
Description of problem:
When using 'ALL' option. eg. './clear-route-status.sh default ALL',it cannot clean the routes status when there are more than 2 routes

Version-Release number of selected component (if applicable):
openshift v3.5.0.37
kubernetes v1.5.2+43a9be4
etcd 3.1.0


How reproducible:
always

Steps to Reproduce:
1. Create two router
    oadm router router1
    oadm router router2
2. Create some route test1 test2

3. delete the router2
   oc delete dc router2
4. get the script 
  wget https://raw.githubusercontent.com/openshift/origin/master/images/router/clear-route-status.sh
5. Clean all routes status 'router2'
./clear-route-status.sh default ALL

6. Check the route stauts 'router2' if has been delted. 
 oc get route -o json | grep router2
  

Actual results:

the status of routerName 'router2'  still exist in all routes

Expected results:

router2 should be deleted for all routes

Additional info:

Comment 1 Jacob Tanenbaum 2017-03-06 14:16:46 UTC
origin PR: https://github.com/openshift/origin/pull/13246

Comment 2 openshift-github-bot 2017-03-07 19:57:15 UTC
Commit pushed to master at https://github.com/openshift/origin

https://github.com/openshift/origin/commit/edef4d133bcaf5c06668c12252122b2800c2df09
correct the ways that routes are iterated over to be cleared

there was an oversight in the way that the clear route status iterated
over the routes returned by

oc get routes -o jsonpath='{.items[*].metadata.name}' --namespace="${namespace}" 2>/dev/null

currently all routes are presented as one string that the server cannot find. Changed that
so that the routes are returned into an array and correctly iterated over so that the server
is given one route name at a time

Bug 1429364
Bug 1429398

Comment 3 Yan Du 2017-03-15 06:11:55 UTC
Test on latest OCP env V3.5.0.52 with the latest script in https://github.com/openshift/origin/pull/13246

Multiple routes in one project could be cleared normally by the script. but after the clear operation, the time of "exposed on router router1 5 minutes ago" have been changed.

Before clear: exposed on router router1 5 minutes ago
$  oc describe route route1 -n d1
Name:			route1
Namespace:		d1
Created:		6 minutes ago
Labels:			name=service-unsecure
Annotations:		openshift.io/host.generated=true
Requested Host:		route1-d1.0313-vn8.qe.rhcloud.com
			  exposed on router router 6 minutes ago
			  exposed on router router1 5 minutes ago  <=========

$ ./clear-route-status.sh d1 ALL
route status for route route1 in namespace d1 cleared
route status for route route2 in namespace d1 cleared
route status for route route3 in namespace d1 cleared

After clear: exposed on router router1 11 seconds ago
$ oc describe route route1 -n d1
Name:			route1
Namespace:		d1
Created:		7 minutes ago
Labels:			name=service-unsecure
Annotations:		openshift.io/host.generated=true
Requested Host:		route1-d1.0313-vn8.qe.rhcloud.com
			  exposed on router router1 11 seconds ago <=========

Comment 4 Eric Paris 2017-03-17 17:22:00 UTC
https://github.com/openshift/origin/issues/13246

Comment 6 Jacob Tanenbaum 2017-04-05 18:23:55 UTC
Yan Du this is expected behaviour, the user is clearing all route statuses and the router has to rewrite it. When writing the status the field retains no state.

Comment 7 Troy Dawson 2017-04-11 21:21:07 UTC
This has been merged into ocp and is in OCP v3.6.27 or newer.

Comment 9 Yan Du 2017-04-12 05:59:21 UTC
Test on latest OCP env, multiple routes in one project could be cleared normally.
oc v3.6.27
kubernetes v1.5.2+43a9be4

# ./clear-route-status.sh d1 ALL
route status for route route1 in namespace d1 cleared
route status for route route2 in namespace d1 cleared
route status for route route3 in namespace d1 cleared

Comment 11 errata-xmlrpc 2017-08-10 05:18:47 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2017:1716