Anvil: Verifying Liveness of Cluster Management Controllers

Xudong Sun, Wenjie Ma, Jiawei Tyler Gu, Zicheng Ma, Tej Chajed, Jon Howell, Andrea Lattuada, Oded Padon, Lalith Suresh, Adriana Szekeres, Tianyin XuOSDI 2024

TL;DR

This paper introduces Anvil, a framework for formally verifying the liveness of Kubernetes cluster management controllers. It addresses the critical challenge of ensuring these controllers, which manage essential cloud infrastructure, behave correctly even in the face of failures and concurrency, a problem that traditional testing often misses. Anvil enables developers to write practical controllers in Rust and prove their correctness using a novel specification called "Eventually Stable Reconciliation."

What Problem Does This Paper Address?

Modern cloud infrastructure relies heavily on a vast number of "controllers" – specialized programs that continuously monitor the state of a system and work to bring it to a desired state. Think of them as the automated operators for your cloud services. These controllers manage everything from deploying applications to scaling resources. However, bugs in these controllers can lead to severe issues like system outages and data loss, as evidenced by numerous real-world incidents. The core problem is that ensuring the correctness of these controllers is incredibly difficult. Traditional testing methods often fail to uncover subtle bugs, especially those related to liveness properties (i.e., ensuring the system eventually reaches and stays in a desired state, even with failures and concurrency). This paper tackles this by providing a formal verification framework specifically designed for these complex, distributed systems.

Methods

The paper's core contribution is the Anvil framework. Anvil allows developers to:

  • Implement controllers in Rust: This leverages a modern, memory-safe language.
  • Define a state-machine model: Controllers are modeled as state machines, a common practice that also facilitates formal verification.
  • Formally verify "Eventually Stable Reconciliation (ESR)": This is a novel liveness property that captures the essential behavior of controllers: they must eventually reach a desired state and then maintain it, even with faults and concurrency. ESR is formalized using Temporal Logic of Actions (TLA).
  • Leverage Verus: Anvil is built on top of Verus, an SMT-based deductive verification tool for Rust, enabling formal proofs.
  • Provide a TLA embedding: Since Verus doesn't directly support temporal logic, Anvil provides an embedding to reason about liveness properties.
  • Model the environment: Anvil includes detailed models of the controller's environment, including the Kubernetes API, other controllers, and various fault scenarios (crashes, network issues).
  • Offer reusable lemmas: A library of pre-proven temporal reasoning and environment interaction lemmas significantly reduces the proof effort for developers.

Datasets

Not discussed in the paper. The paper focuses on verifying existing Kubernetes controllers and does not introduce new datasets for training or evaluation.

Key Insights and Ideas

  • Liveness is Crucial for Controllers: While safety properties (e.g., "never delete data") are important, liveness (e.g., "eventually reach the desired state") is fundamental to the correct operation of cluster management controllers. Bugs in liveness can be particularly insidious and hard to detect.
  • ESR as a General Specification: The "Eventually Stable Reconciliation" (ESR) property provides a powerful, general specification for controller correctness. It elegantly captures both progress (reaching the desired state) and stability (maintaining it) without making overly strong assumptions about system behavior.
  • Formal Verification is Pragmatic: The paper demonstrates that formal verification, often perceived as academic and impractical for real-world systems, can be applied pragmatically to complex software like Kubernetes controllers. Anvil makes this process manageable.
  • Bugs Missed by Testing: The verification process uncovered bugs in both the Anvil-verified controllers and their widely-used, unverified counterparts. This highlights the limitations of traditional testing and the power of formal methods for finding subtle errors.
  • Separation of Concerns in Proofs: The proof strategy of separating environment stability from controller liveness in a stable environment simplifies the verification process.

Key Results

  • Anvil Framework: A functional framework for developing and formally verifying Kubernetes controllers.
  • Three Verified Controllers: Anvil was used to implement and verify three practical Kubernetes controllers for ZooKeeper, RabbitMQ, and FluentBit. These controllers offer feature parity with existing solutions.
  • Manageable Verification Effort: The proof-to-code ratio ranged from 4.5 to 7.4, and verification times were under 3 minutes per controller on a modest laptop.
  • Bug Discovery: Verification efforts led to the discovery and fixing of several liveness and safety bugs, some of which were not found by extensive testing or were present in reference implementations.
  • Comparable Performance: The verified controllers exhibited performance comparable to their unverified counterparts, with no significant increase in load on the data store.

Limitations and Future Work

  • Trusted Components: Anvil relies on trusted components, including the environment model, external APIs, and the Verus verifier. The paper acknowledges that a bug in a trusted assumption (as found in the ZooKeeper controller) can lead to verification issues.
  • Interaction with Unverified Controllers: Anvil currently cannot reason about the interactions between verified controllers and other, unverified custom controllers in a Kubernetes cluster.
  • Future Work:
    • Gradually replacing existing unverified controllers with Anvil-verified ones.
  • Extending Anvil to verify interactions among multiple verified controllers.
  • Ensuring the quality of trusted components (environment model, shim layer, APIs) using lightweight formal methods.
  • Exploring techniques to improve proof automation, potentially by integrating ideas from tools like Ivy.

Summary updated

BibTeX
@inproceedings{sun2024anvil,
  author = {Xudong Sun and Wenjie Ma and Jiawei Tyler Gu and Zicheng Ma and Tej Chajed and Jon Howell and Andrea Lattuada and Oded Padon and Lalith Suresh and Adriana Szekeres and Tianyin Xu},
  title = {{Anvil: Verifying Liveness of Cluster Management Controllers}},
  booktitle = {OSDI},
  year = {2024},
  url = {https://openreview.net/forum?id=WgpNXD0zIG},
}
Figure