(the "Amazon Resource Name", a unique identifier used to reference the topic).
To update a topic, use the same command that you used to create it (but when
updating, use the name of an existing topic and different endpoint values).
+Topic names must contain only alphanumeric characters, hyphens, and underscores,
+and must be between 1 and 256 characters long. To relax these requirements, use:
+
+.. confval:: rgw_relaxed_topic_names
.. tip:: Any notification already associated with the topic must be re-created
in order for the topic to update.
flags:
- startup
with_legacy: true
+- name: rgw_relaxed_topic_names
+ type: bool
+ level: advanced
+ desc: RGW enable relaxed topic names
+ long_desc: RGW enable relaxed topic names to allow changing existing topics
+ that were created before validation rules were implemented. This also allows re-creating
+ topics that were deleted, but match names that are already used externally (e.g. in Kafka)
+ default: false
+ services:
+ - rgw
+ with_legacy: true
- name: rgw_lua_max_memory_per_state
type: uint
level: advanced
int get_params() {
topic_name = s->info.args.get("Name");
- if (!validate_topic_name(topic_name, s->err.message)) {
+ if (topic_name.empty() ||
+ (!s->get_cct()->_conf.get_val<bool>("rgw_relaxed_topic_names") &&
+ !validate_topic_name(topic_name, s->err.message))
+ ) {
return -EINVAL;
}
list_topics(0, tenant)
+@pytest.mark.manual_test
+def test_topic_name():
+ """ test topic name validation """
+ conn = connection()
+ # make sure there are no leftover topics
+ delete_all_topics(conn, '', get_config_cluster())
+
+ zonegroup = get_config_zonegroup()
+ bucket_name = gen_bucket_name()
+ invalid_topic_name = bucket_name + '+' + TOPIC_SUFFIX
+ rgw_client = f'client.rgw.{get_config_port()}'
+
+ # fail to create topic
+ endpoint_address = 'http://127.0.0.1:7001/'
+ endpoint_args = 'push-endpoint='+endpoint_address+'&persistent=true'
+ topic_conf = PSTopicS3(conn, invalid_topic_name, zonegroup, endpoint_args=endpoint_args)
+ pytest.raises(Exception, topic_conf.set_config)
+
+ # relax topic name validation
+ set_rgw_config_option(rgw_client, 'rgw_relaxed_topic_names', 'true', get_config_cluster())
+ # create topic
+ expected_arn = 'arn:aws:sns:' + zonegroup + '::' + invalid_topic_name
+ topic_arn = topic_conf.set_config()
+ assert topic_arn == expected_arn
+
+ set_rgw_config_option(rgw_client, 'rgw_relaxed_topic_names', 'false', get_config_cluster())
+
+ # get topic (should be possible regardless of the relaxed topic name setting)
+ parsed_result = get_topic(invalid_topic_name)
+ assert parsed_result['arn'] == expected_arn
+
+ # delete topic
+ status = topic_conf.del_config()
+ assert status == 200
+
+ # maks sure that empty topic names are invalid regardless of flag
+ empty_topic_conf = PSTopicS3(conn, "", zonegroup, endpoint_args=endpoint_args)
+ pytest.raises(Exception, empty_topic_conf.set_config)
+
+
@pytest.mark.basic_test
def test_topic_admin():
""" test topics set/get/delete """