Forum Discussion

Sergei_Genchev_'s avatar
Sergei_Genchev_
Icon for Nimbostratus rankNimbostratus
Jan 24, 2015

How to efficiently delete a node from LTM?

Hi,

 

I am trying to delete a node from F5 LTM as part of our decommission process. I cannot delete a node until I remove all pool members that refer to it. The only way I know how to get pool members is to get all pools and then, for each pool, get members, and see if the IP address of a member matches. With thousands of pools we have this takes thousands of web requests. It is seriously slow even on local network but if I try to do it to our LB on another continent over 160ms round-trip link, it literally takes 15+minutes. So, is there more efficient way to delete a node? Maybe get a list of all back-references to a node? Or a list of all members of all pools in one shot? Or something else I did not think about? I am not even trying to tackle nodes used in iRules and other non-pool objects at this time (though it would be cool). I did try to delete node first and parse a 400 response but: - response only has one pool out of possibly many. - the name of the pool in response is within an arbitrary text "message" string. This string is already different between 11.4 and 11.5, and, since it is not part of API, can change at any hotfix.

 

9 Replies

  • If you try to do it from the CLI, you could use a command like

    tmsh list ltm pool one-line | grep nodename
    . That should give you a list of pools that contain the specified nodename. Then you can parse the config list that's returned.

  • Hi Sergei,

    if you have figured out the related pools you can use tmsh as well to delete a specific pool member:

    tmsh modify ltm pool  members delete { : }
    

    Combining this with the answer from Michael J you can use a one liner to parse all pools and create the syntax to modify all pools on your system. Just replace the value of node with the node´s name:

    node="10.131.131.5"; tmsh list ltm pool one-line | grep -E "${node}:[[:alnum:]]" | \
    sed -r 's/ltm pool ([^ ]+).*members.*('${node}':[[:alnum:]]+).*/tmsh modify ltm pool \1 members delete { \2 }/g'
    

    By adding "bash -x" the output will be executed immediately. Please be very careful!:

    node="10.131.131.5"; tmsh list ltm pool one-line | grep -E "${node}:[[:alnum:]]" | \
    sed -r 's/ltm pool ([^ ]+).*members.*('${node}':[[:alnum:]]+).*/tmsh modify ltm pool \1 members delete { \2 }/g' | bash -x
    

    As this only modifies the running configuration you need to save to startup configuration afterwards and config-sync:

    tmsh save sys config  
    tmsh run cm config-sync to-group 
    

    The syntax above can be enhanced to support administrative partitions and routing domains. Please let me know, if this is an additional requirement.

    Thanks, Stephan

    PS: Of course I recommend a config backup before applying all kind of change ...

    • VFB's avatar
      VFB
      Icon for Cirrus rankCirrus

      This is super close. I ran it, but it wasn't able to identify all the pools. I did notice that the pools that the node wasn't removed from is either offline or disabled in the pool. 

  • Thank you guys very much for the answers. I was hoping I could be able to do it with iControl but I may need to revert to pre-sharing ssh keys and tmsh, like I did before with bigpipe. I was really hopeful for the rest APIs but I find more and more that they are not made or the scenarios I need in real life. Thanks again!

     

  • If you wanted to find out what pools are using a specific node (through name or ip address) with iControlREST and wanted to user PowerShell, you could use this script...

     Get the credentials for the BIG-IP
    $cred = Get-Credential;
     iControlREST url for pools (expand sub references)
    $url = "https://example.com/mgmt/tm/ltm/pool?expandSubcollections=true"
     Get the pools
    $pools = Invoke-RestMethod -Method GET -URI $url -Credential $cred;
     Specify which node you're looking for (name or ip)
    $node = "1.1.1.1";
     Filter the pools based on containing the specified node (wildcard search on name and ip)
    $poolsF = @($pools.items | ?{$_.membersReference.items | ?{ $_.name -like "*$($node)*" -or $_.address -like "*$($node)*" } };)
     Get an array of the pool names containg the node
    $poolNames = $poolsF | Select -ExpandProperty name;
    
  • Thanks Michael, To me removing members is not an issue, once member is found. Finding it is what takes long time.

     

  • Answering my own question. It pays to read documentation ;-) If I pass expandSubccollections=true while making REST call, like https://lb.example.com/mgmt/tm/ltm/pool?expandSubcollections=true, then LTM returns all pools with all their members. I can get everything I need from a single GET instead of thousands. Takes me now ~3 seconds instead of 15+ minutes to delete node from remote LTM. Thank you all for your help!

     

    • StephanManthey's avatar
      StephanManthey
      Icon for MVP rankMVP
      Hi Sergei, thanks for sharing this information. :) Enjoy weekend, Stephan
  • I have another question on this thread. As you describe Sergei I can get all pool members with "expandSubccollections=true", but if I would like to only show the once that contains a certain node? I tried with "filter" but im not sure of the syntax as i want to filter on "memberReference->items->name"? I have only seen examples to filter on partition, name for the pool etc. not subcollections. Is this even possible or do i need to get the full list and handle the search in my script?

     

    Cheers! // Mattias