Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

PATCH IRule REST API in transaction not executed

Hello,

When I do a PATCH request to edit an IRule in an Transaction then the change is not executed. When I do a PATCH request without a transaction the change is executed. I do the change together with an Persistence change. Both changes are in the same transaction, the persistence change is executed the IRule is unchanged.The Transaction validate and transaction commit gives both a HTTP 200 result.

Do I miss something or is this a bug in the BIG IP REST API interface in cobination with F5 Transactions?

URL: mgmt/tm/ltm/rule/~Common~irule_persist_universal_example.test.nl-any-443

JSON payload:

{\"apiAnonymous\":\"when HTTP_REQUEST {\\n    
   if { [HTTP::cookie exists \\\"JSESSIONID\\\"] } {\\n
          persist uie [HTTP::cookie \\\"JSESSIONID\\\"] 9292\\n
   }\\n 
}\"}
0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Try this:

#!/bin/bash

USERPASS='admin:admin'

## create a transaction and return the transaction ID
transid=`curl -sk -u $USERPASS -H 'Accept: application/json' -H 'Content-Type: application/json' https://localhost/mgmt/tm/transaction -d '{}' |awk -F"," '{ print $1 }' |awk -F":" '{ print $2 }'`

## modify the iRule
curl -sk -u $USERPASS -H "X-F5-REST-Coordination-Id: $transid" -H "Accept: application/json" -H "Content-Type: application/json" -X PATCH https://localhost/mgmt/tm/ltm/rule/~Common~test1-rule -d@irule.txt

## modify persistence
curl -sk -u $USERPASS -H "X-F5-REST-Coordination-Id: $transid" -H "Accept: application/json" -H 'Content-Type: application/json' -X PATCH -d '{"persist":[{"name":"cookie"}]}' https://localhost/mgmt/tm/ltm/virtual/webserver-vip

## commit the transaction
curl -sk -u $USERPASS -H "Accept: application/json" -H "Content-Type: application/json" -X PUT https://localhost/mgmt/tm/transaction/$transid -d '{ "state":"VALIDATING" }'

where irule.txt is your iRule payload.

{
"apiAnonymous":"# this is a test\n
when HTTP_REQUEST {\n
  log local0. \"Hello World\"\n
}"
}
0
Comments on this Answer
Comment made 1 month ago by martijnbrands 1

Kevin, thank you for your reply.

But that is exactly what we do. The persistence change is accepted but the IRule is not changed.

I replay this scenario in Postman change only the IRule.

The change is not executed an still see the old IRule. I get no errors at all. When I do the change without a transaction the change is normally executed en visible in the BigIp GUI.

When I Do a Get on the Transaction .../1539674177242309/commands I see that the change of the IRule is in the transaction.

To me it seems as a bug. We use transactions everywhere. Poolmembers, Nodes, HttpProfiles etc. This is the first issue we have. We are on version BIG-IP 12.1.3.2

0
Comment made 1 month ago by Kevin Stewart

Are you submitting the iRule inline? I used a separate file and "-d@irule.txt", and that worked for me.

0
Comment made 1 month ago by martijnbrands 1

I don't use curl, but it is a normal JSON body. The body must be OK because without a transaction the change is accepted. Only with transaction it is not working. On wihich version of BIG-IP you are?

0
Comment made 1 month ago by Kevin Stewart

I tested on 13.1 and 14.0 using a separate iRule file (vs. inline code).

0
Comment made 1 month ago by martijnbrands 1

Hello Kevin,

We have updated one testloadbalancer to version 13.1. Here I have no problems when I do an IRule change within a transaction. So version 12.1.3.2 has a bug. Can you confirm that this is fixed in version X... because we have a lot of loadbalancers.

Thanks for your help.

0
Comment made 1 month ago by Kevin Stewart

There are a number of REST updates in the 13.0 release notes, which is the next version after 12.1.3.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

F5 dropped the ball on this one..it's a 12.X bug; works on 13.X code.

0