Forum Discussion

HankLiu_159320's avatar
HankLiu_159320
Icon for Nimbostratus rankNimbostratus
Nov 21, 2014

Unable to delete and create virtual server in the same transaction via iControl api

Hello guys! I'm hitting this issue and is a bit frustrating... Any help is appreciated!

 

I'm trying to simulate an "update" virtual server feature by combining the removal and creation of virtual server in one transaction.

 

I'm able to a 1.) start transaction, 2.) create an virtual server, 3.) delete the virtual server, 4.) submit transaction, no problem at all. But the reverse (delete, then recreate) will fail every time. It works fine if transaction not used.

 

Actual flow:

 

  1. start_transaction();
  2. delete_virtual_server(...);
  3. //setup resources/definitions required in create()
  4. create(...,...,...,...)
  5. submit_transaction();

Error: The requested virtual server profile (/Common/Relay-test /Common/tcp) already exists in partition Common.

 

7 Replies

  • The error you posted suggests that in your create you are trying to create a profile that already exists, /Common/tcp. I would verify that your create statement isn't trying to recreate the built in /Common/tcp profile.

     

  • @Brad Parker

     

    Thanks for taking interest in this post. Duplicate profile was my initial thought as well. But running the code without transactions works fine, which suggests that there is more to it. I think we're on the right track, but the create(serveDef, wMasks, serveRes, serverProf) method does not create* the profiles based on args passed in, it just creates the virtual servers with the profiles passed in as arg according to docs. https://devcentral.f5.com/wiki/iControl.LocalLB__VirtualServer__create.ashx

     

    btw the args in create() were prepared before the transaction began so it occurs real-time and no errors were thrown because of them.

     

    • shaggy's avatar
      shaggy
      Icon for Nimbostratus rankNimbostratus
      can you provide the commands that reference /Common/tcp and /Common/Relay-test? do you only refer to them with the 'create ltm virtual' commands?
    • HankLiu_159320's avatar
      HankLiu_159320
      Icon for Nimbostratus rankNimbostratus
      I'm not using the TMSH commands. I'm making iControl api call in Java. The code where it is breaking is as simple as this... interfaces.getSystemSession().start_transaction(); interfaces.getLocalLBVirtualServer().delete_virtual_server(vServers); interfaces.getLocalLBVirtualServer().create(serveDef, wMasks, serveRes, serverProf); interfaces.getSystemSession().submit_transaction();
  • The code where it is breaking is as simple as this... interfaces.getSystemSession().start_transaction(); interfaces.getLocalLBVirtualServer().delete_virtual_server(vServers); interfaces.getLocalLBVirtualServer().create(serveDef, wMasks, serveRes, serverProf); interfaces.getSystemSession().submit_transaction();
  • I'm not sure this would work. From a logical perspective, the VS exists before the transaction, then doesn't exist, then does again. Can the deletion be rolled back if the roll back (on a failure) and a successful transaction both produce the same result (the VS exists).

     

    I'd suggest it would be better (or at least possible) to add and remove profiles as necessary. More code but something that can be reasonably rolled back.

     

  • Hello What Lies Beneath!

     

    Thanks for your response. I think you're on the right track with the profile. However, i'm not convinced that adding & removing VS in the same transaction shouldn't* work. I think one of the core motivations behind the transaction was to bridge the gap between "remove" and "add" by emulating a "update" feature since iControl does not provide atomic operations for updating numerous objects.

     

    https://devcentral.f5.com/articles/v11-icontrol-transactions This post discusses the behavior of transaction and shows that pools are added and then removed, which highlights both failure and success "produce the same result". I can also confirm that deleting an iRule and then creating it (repeated several times) in the same transaction works flawlessly.

     

    Having said that, I think you're right about the profile. I don't mind writing additional code if I can recreate virtual server and then add the protocol client/server profiles immediately after (it'll just have to be in the same transaction). However, the docs for create virtual server requires associated profiles to be specified in the args. In fact, if you attempt to remove the client profile, it would default to "TCP" and if you try to remove the server profile, it would default to "client profile". The reason, i believe, is that the protocol profiles are required for the virtual server to behave properly. See post on similar issue: https://devcentral.f5.com/questions/virtualserveradd_profile-cannot-set-a-new-client-protocol-profile

     

    In the end, what I really need is a way to update a virtual server in one atomic operation or with rollback feature in order to eliminate risk of outage. If you have a workaround, even better if it is compatible with f5 v9/10, that would be awesome! Thanks!