Skip to content

Copy Max-Age cookie attribute to VCAP_ID unconditionally #429

@hoffmaen

Description

@hoffmaen

Current Behavior

With the current implementation of session handling, Gorouter sets a __VCAP_ID__ cookie in the response when a session cookie (by default JSESSIONID) is present in the application response. Some cookie attributes, such as the Expires timestamp and the Partitioned flag, are copied from the session cookie to __VCAP_ID__. However, the Max-Age attribute is only copied if its value is negative (internally represented as MaxAge < 0 in Go's cookie implementation). This is inconsistent behavior, as the Expires attribute is always copied, and Max-Age takes precedence over Expires.

This leads to unexpected and undesired behavior: When an application provides a positive Max-Age value for the session cookie, the session cookie expires once Max-Age seconds have elapsed, but the __VCAP_ID__ cookie remains valid as a session cookie (no expiration). In the next request, Gorouter will not consider the __VCAP_ID__ cookie because the expired session cookie is missing. As a result, the request is routed to an arbitrary application instance, breaking sticky session routing.

The conditional Max-Age copying was introduced 10 years ago in a bugfix that resolved an issue preventing sticky session re-establishment.

Desired Behavior

The Max-Age cookie attribute should be unconditionally copied from the session cookie to the __VCAP_ID__ cookie, regardless of whether its value is negative or positive. This ensures that both cookies have synchronized expiration behavior.

Affected Version

Current main branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions