Forum Discussion

Daniel_Wolf's avatar
May 20, 2025
Solved

Universal Persistence w. AS3 vs. SCF - the same but not the same

Hi community,

I have an odd issue. When I create the following config manually or with SCF the Universal Persistence works. I get records in the persistence table.

root@(ltm-apm)(cfg-sync Standalone)(Active)(/Common)(tmos)# show ltm persistence persist-records
Sys::Persistent Connections
universal  12345abcde  10.100.155.182:80  10.100.153.127:80  (tmm: 1)
universal  12345abcde  10.100.155.182:80  10.100.153.127:80  (tmm: 0)

This is the config as SCF (at least the relevant parts of it):

ltm virtual vs_persistence_test {
    destination 10.100.155.182:http
    ip-protocol tcp
    mask 255.255.255.255
    persist {
        uie_jsessionid {
            default yes
        }
    }
    pool pl_persistence_test
    profiles {
        f5-tcp-progressive { }
        http { }
    }
    serverssl-use-sni disabled
    source 0.0.0.0/0
    source-address-translation {
        pool snat_pool_internal
        type snat
    }
    translate-address enabled
    translate-port enabled
    vs-index 57
}
ltm persistence universal uie_jsessionid {
    app-service none
    defaults-from universal
    rule rule_uie_jsessionid
    timeout 300
}
ltm rule rule_uie_jsessionid {
when HTTP_RESPONSE {
  if { [HTTP::cookie exists "JSESSIONID"] } {
    persist add uie [HTTP::cookie "JSESSIONID"]
  }
}
when HTTP_REQUEST {
  if { [HTTP::cookie exists "JSESSIONID"] } {
    persist uie [HTTP::cookie "JSESSIONID"]
  }
}
}

Do I deploy the same with AS3, it doesn't seem to work. I cannot see any persistence records.

{
    "$schema": "https://raw.githubusercontent.com/F5Networks/f5-appsvcs-extension/main/schema/latest/as3-schema.json",
    "class": "AS3",
    "action": "deploy",
    "declaration": {
        "class": "ADC",
        "schemaVersion": "3.0.0",
        "remark": "Session persistency w JSESSIONID",
        "universal_persist_jsessionid": {
            "class":"Tenant",
            "App01": {
                "class": "Application",
                "service_http_80": {
                    "persistenceMethods": [{
                            "use": "uie_jsessionid"
                        }
                    ],
                    "pool": "pl_persistence_test",
                    "translateServerAddress": true,
                    "translateServerPort": true,
                    "class": "Service_HTTP",
                    "profileTCP": {
                        "bigip": "/Common/f5-tcp-progressive"
                    },
                    "profileHTTP": {
                        "bigip": "/Common/http"
                    },
                    "virtualAddresses": [
                        "10.100.155.182"
                    ],
                    "virtualPort": 80
                },
                "pl_persistence_test": {
                    "members": [
                        {
                            "servicePort": 80,
                            "serverAddresses": [
                                "10.100.153.126",
                                "10.100.153.127"
                            ]
                        }
                    ],
                    "monitors": [
                        {
                            "bigip": "/Common/http"
                        }
                    ],
                    "class": "Pool"
                },
                "uie_jsessionid": {
                    "duration": 300,
                    "class": "Persist",
                    "iRule": "persist_irule",
                    "persistenceMethod": "universal"
                },
                "persist_irule": {
                    "class": "iRule",
                    "iRule": {
                        "base64": "d2hlbiBIVFRQX1JFU1BPTlNFIHsKICBpZiB7IFtIVFRQOjpjb29raWUgZXhpc3RzICJKU0VTU0lPTklEIl0gfSB7CiAgICBwZXJzaXN0IGFkZCB1aWUgW0hUVFA6OmNvb2tpZSAiSlNFU1NJT05JRCJdCiAgfQp9CndoZW4gSFRUUF9SRVFVRVNUIHsKICBpZiB7IFtIVFRQOjpjb29raWUgZXhpc3RzICJKU0VTU0lPTklEIl0gfSB7CiAgICBwZXJzaXN0IHVpZSBbSFRUUDo6Y29va2llICJKU0VTU0lPTklEIl0KICB9Cn0="
                    }
                }
            }
        }
    }
}

FYI, I decided to use base64 for the iRule in AS3.
However, if I do a diff of the iRules in plaintext - they are the same.

BIG-IP version: 17.1.2.1

Now my questions are.

  1. Am I missing something here?
  2. Did anybody come accross the same issue?
  3. Why is it not working?

Thanks for your help
Daniel

  • Never mind, I managed to figure it out on my own.

    Option 1: Use the REST API:

    daniel@ubuntu-vm:~$ curl -sk -u admin:<password> GET https://172.31.254.240/mgmt/tm/ltm/persistence/persist-records | jq.exe . -M
    {
      "kind": "tm:ltm:persistence:persist-records:persist-recordsstats",
      "selfLink": "https://localhost/mgmt/tm/ltm/persistence/persist-records?ver=17.1.2.1",
      "apiRawValues": {
        "apiAnonymous": "Sys::Persistent Connections\nuniversal  12345abcde  10.100.155.182:80  10.100.153.127:80  (tmm: 1)\nuniversal  abcde12345  10.100.155.182:80  10.100.153.126:80  (tmm: 0)\nTotal records returned: 2\n"
      }
    }

    Option 2: Don't be me... change to the right partition

    root@(bigip)(cfg-sync Standalone)(Active)(/Common)(tmos)# cd /universal_persist_jsessionid/
    root@(bigip)(cfg-sync Standalone)(Active)(/universal_persist_jsessionid)(tmos)# show ltm persistence persist-records
    Sys::Persistent Connections
    universal  12345abcde  10.100.155.182:80  10.100.153.127:80  (tmm: 1)
    universal  abcde12345  10.100.155.182:80  10.100.153.126:80  (tmm: 0)
    Total records returned: 2

     

     

5 Replies

  • Have you checked that irule is applied on Virtual Server correctly?

    Have not played a lot with AS3, but shouldn't you apply irule also under "service_http_80"?

     

    for example

    "service_http_80": {
    	"persistenceMethods": [{
                "use": "uie_jsessionid"
            }
        ],
    	"iRules": ["persist_irule"],
        "pool": "pl_persistence_test",
        "translateServerAddress": true,
        "translateServerPort": true,
        "class": "Service_HTTP",
    	..........
    	..........

     

    • Daniel_Wolf's avatar
      Daniel_Wolf
      Icon for MVP rankMVP

      Thanks Injeyan_Kostas​, but that is not the issue.
      When using Universal Persistence the iRule is applied to the persistence profile, not to the virtual.
      I can also see from the statistics that the iRule is executed. No tcl errors in /var/log/ltm either.

  • Never mind, I managed to figure it out on my own.

    Option 1: Use the REST API:

    daniel@ubuntu-vm:~$ curl -sk -u admin:<password> GET https://172.31.254.240/mgmt/tm/ltm/persistence/persist-records | jq.exe . -M
    {
      "kind": "tm:ltm:persistence:persist-records:persist-recordsstats",
      "selfLink": "https://localhost/mgmt/tm/ltm/persistence/persist-records?ver=17.1.2.1",
      "apiRawValues": {
        "apiAnonymous": "Sys::Persistent Connections\nuniversal  12345abcde  10.100.155.182:80  10.100.153.127:80  (tmm: 1)\nuniversal  abcde12345  10.100.155.182:80  10.100.153.126:80  (tmm: 0)\nTotal records returned: 2\n"
      }
    }

    Option 2: Don't be me... change to the right partition

    root@(bigip)(cfg-sync Standalone)(Active)(/Common)(tmos)# cd /universal_persist_jsessionid/
    root@(bigip)(cfg-sync Standalone)(Active)(/universal_persist_jsessionid)(tmos)# show ltm persistence persist-records
    Sys::Persistent Connections
    universal  12345abcde  10.100.155.182:80  10.100.153.127:80  (tmm: 1)
    universal  abcde12345  10.100.155.182:80  10.100.153.126:80  (tmm: 0)
    Total records returned: 2

     

     

  • Hey Daniel_Wolf​  nice topic! I wonder if you reference an existing uie persistance with "bigip" like you did for the profiles maybe the records will be in the Common partition.