Status

Current state: Under Discussion

Discussion thread: https://lists.apache.org/thread/3gvsod6vrq5xb415yf0zs8cxry1lnfzf

JIRA:

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

KIP-133 introduced AlterConfigPolicy  to enforce validations when requesting configuration changes for Kafka entities (e.g. Topics), similar to how KIP-108 introduced policies for Topic creation.

At that time, the AlterConfigs  API included all the configurations to be applied (usually after gathering all the current configurations first using DescribeConfigs  call). This has changed after KIP-339 was introduced. With IncrementalAlterConfigs , only configurations to be changed are including to the request and changes are calculated on the broker-side.

Once incremental updates were adopted, only enables a very limited type of validations (e.g. config x  cannot not be y) as the current state is not included in the request, while most important validations have a dependency between configurations (e.g. if value of a=b  and c=d  then x  cannot be y). Even further, having some policies available only on creation but not when altering means the effort put to validate on creation is wasted on later changes.

The purpose of this KIP is to allow the same policies on incremental alter configs, considering all resulting configurations (similar to topic creation policies, and; to some extend; to legacy alter configs).


There has been related KIPs that included this proposal:

This KIP is intended to reduce the scope of the proposal for extending AlterConfigPolicy, without adding new interfaces.

This KIP borrows parts of KIP-170 discussion. If KIP-201 is resurrected, this changes shouldn't increase complexity of the KIP as it is just another field to map and same migration should apply.

Current workflow

At the moment there are 2 APIs for altering configs:

And alter config policy is treated somewhat different on each API.

The following workflows apply on each backend (ZK-based, and KRaft):

Workflows:



Where:


Some highlights:

Proposed Changes

Given the current limitations with the existing Alter Config policies, this KIP proposes to add a new version that explicitly considers the current (before alter) and updated (after alter) set of configurations.

Public Interfaces

1. Add AlterConfigV2Policy  including before and after configurations:

public interface AlterConfigV2Policy extends Configurable, AutoCloseable {

    class RequestMetadata {

        private final ConfigResource resource;
        private final Map<String, String> configsBefore;
        private final Map<String, String> configsAfter;

        public RequestMetadata(ConfigResource resource, Map<String, String> configsBefore, Map<String, String> configsAfter) {
            this.resource = resource;
            this.configsBefore = configsBefore;
            this.configsAfter = configsAfter;
        }

		// ...

        public Map<String, String> configsBefore() {
            return configsBefore;
        }
 
        public Map<String, String> configsAfter() {
            return configsAfter;
        }

        // ...

    void validate(RequestMetadata requestMetadata) throws PolicyViolationException;
}

Where:

Deleted configurations will either not appear or have null value on the configurations after alter, returning back to default value (if any).

Compatibility, Deprecation, and Migration Plan

None, it's a new API.

Current policy will be kept for compatibility. Later releases can consider deprecation.

No migration tools needed.

Outside the scope of this KIP.

Test Plan

Same as AlterConfigPolicy  tests.

Rejected Alternatives

If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.

Reuse existing AlterConfigPolicy

Extending the configs, and its semantics, would be a breaking change on behavior as existing deal with different meaning depending on the alter API used. To avoid dealing with existing issues/bugs a new API is proposed.