Skip to content

Commit

Permalink
refactor(*): drop Cassandra specifics from plugins (#10833)
Browse files Browse the repository at this point in the history
* refactor: drop requirment to specify cassandra

To support a phased out removal of Cassandra, this commmit removes the
validation for Cassandra. Once all migrations associated with Cassandra
are removed, the schema for migrations will be updated to not allow any
Cassandra fields.
This is done to avoid a large patch that removes all migrations in one
go.

* refactor: drop Cassandra specifics from plugins

This patch is part of a series of patches removing Cassandra support
from Kong. This patch removes all Cassandra specifics from bundled
plugins.
  • Loading branch information
hbagdi authored May 17, 2023
1 parent 5e0d466 commit 95a4343
Show file tree
Hide file tree
Showing 54 changed files with 108 additions and 685 deletions.
2 changes: 1 addition & 1 deletion kong/db/migrations/core/010_210_to_211.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local operations = require "kong.db.migrations.operations.210_to_211"

return {
postgres = {
up = [[]],
up = [[ SELECT 1 ]],
},
cassandra = {
up = [[]],
Expand Down
5 changes: 2 additions & 3 deletions kong/db/schema/others/migrations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ return {
},
{
cassandra = {
type = "record", required = true,
type = "record",
fields = {
{ up = { type = "string", len_min = 0 } },
{ up_f = { type = "function" } },
Expand All @@ -26,8 +26,7 @@ return {
entity_checks = {
{
at_least_one_of = {
"postgres.up", "postgres.up_f", "postgres.teardown",
"cassandra.up", "cassandra.up_f", "cassandra.teardown"
"postgres.up", "postgres.up_f", "postgres.teardown"
},
},
},
Expand Down
15 changes: 0 additions & 15 deletions kong/plugins/acl/migrations/000_base_acl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,4 @@ return {
END$$;
]],
},

cassandra = {
up = [[
CREATE TABLE IF NOT EXISTS acls(
id uuid PRIMARY KEY,
created_at timestamp,
consumer_id uuid,
group text,
cache_key text
);
CREATE INDEX IF NOT EXISTS ON acls(group);
CREATE INDEX IF NOT EXISTS ON acls(consumer_id);
CREATE INDEX IF NOT EXISTS ON acls(cache_key);
]],
},
}
5 changes: 0 additions & 5 deletions kong/plugins/acl/migrations/002_130_to_140.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ return {
]],
},
cassandra = {
up = [[
ALTER TABLE acls ADD tags set<text>;
]],
}
}
5 changes: 0 additions & 5 deletions kong/plugins/acl/migrations/003_200_to_210.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,4 @@ return {
up = ws_migration_up(operations.postgres.up),
teardown = ws_migration_teardown(operations.postgres.teardown),
},

cassandra = {
up = ws_migration_up(operations.cassandra.up),
teardown = ws_migration_teardown(operations.cassandra.teardown),
},
}
5 changes: 0 additions & 5 deletions kong/plugins/acl/migrations/004_212_to_213.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,4 @@ return {
up = "",
teardown = ws_migration_teardown(operations.postgres.teardown),
},

cassandra = {
up = "",
teardown = ws_migration_teardown(operations.cassandra.teardown),
},
}
12 changes: 0 additions & 12 deletions kong/plugins/acme/migrations/000_base_acme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,4 @@ return {
);
]],
},

cassandra = {
up = [[
CREATE TABLE IF NOT EXISTS acme_storage (
id uuid PRIMARY KEY,
key text,
value text,
created_at timestamp
);
CREATE INDEX IF NOT EXISTS acme_storage_key_idx ON acme_storage(key);
]],
},
}
3 changes: 0 additions & 3 deletions kong/plugins/acme/migrations/001_280_to_300.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@ return {
CREATE INDEX IF NOT EXISTS "acme_storage_ttl_idx" ON "acme_storage" ("ttl");
]],
},
cassandra = {
up = "",
}
}
3 changes: 0 additions & 3 deletions kong/plugins/acme/migrations/002_320_to_330.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ return {
END$$;
]],
},
cassandra = {
up = "",
}
}
14 changes: 0 additions & 14 deletions kong/plugins/basic-auth/migrations/000_base_basic_auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,4 @@ return {
END$$;
]],
},

cassandra = {
up = [[
CREATE TABLE IF NOT EXISTS basicauth_credentials (
id uuid PRIMARY KEY,
created_at timestamp,
consumer_id uuid,
password text,
username text
);
CREATE INDEX IF NOT EXISTS ON basicauth_credentials(username);
CREATE INDEX IF NOT EXISTS ON basicauth_credentials(consumer_id);
]],
},
}
5 changes: 0 additions & 5 deletions kong/plugins/basic-auth/migrations/002_130_to_140.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ return {
]],
},
cassandra = {
up = [[
ALTER TABLE basicauth_credentials ADD tags set<text>;
]],
}
}
5 changes: 0 additions & 5 deletions kong/plugins/bot-detection/migrations/001_200_to_210.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,4 @@ return {
up = "",
teardown = ws_migration_teardown(operations.postgres.teardown),
},

cassandra = {
up = "",
teardown = ws_migration_teardown(operations.cassandra.teardown),
},
}
14 changes: 0 additions & 14 deletions kong/plugins/hmac-auth/migrations/000_base_hmac_auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,4 @@ return {
END$$;
]],
},

cassandra = {
up = [[
CREATE TABLE IF NOT EXISTS hmacauth_credentials(
id uuid PRIMARY KEY,
created_at timestamp,
consumer_id uuid,
username text,
secret text
);
CREATE INDEX IF NOT EXISTS ON hmacauth_credentials(username);
CREATE INDEX IF NOT EXISTS ON hmacauth_credentials(consumer_id);
]],
},
}
5 changes: 0 additions & 5 deletions kong/plugins/hmac-auth/migrations/002_130_to_140.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ return {
]],
},
cassandra = {
up = [[
ALTER TABLE hmacauth_credentials ADD tags set<text>;
]],
}
}
5 changes: 0 additions & 5 deletions kong/plugins/http-log/migrations/001_280_to_300.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,4 @@ return {
up = "",
teardown = ws_migration_teardown(operations.postgres.teardown),
},

cassandra = {
up = "",
teardown = ws_migration_teardown(operations.cassandra.teardown),
},
}
5 changes: 0 additions & 5 deletions kong/plugins/ip-restriction/migrations/001_200_to_210.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,4 @@ return {
up = "",
teardown = ws_migration_teardown(operations.postgres.teardown),
},

cassandra = {
up = "",
teardown = ws_migration_teardown(operations.cassandra.teardown),
},
}
17 changes: 0 additions & 17 deletions kong/plugins/jwt/migrations/000_base_jwt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,4 @@ return {
END$$;
]],
},

cassandra = {
up = [[
CREATE TABLE IF NOT EXISTS jwt_secrets(
id uuid PRIMARY KEY,
created_at timestamp,
consumer_id uuid,
algorithm text,
rsa_public_key text,
key text,
secret text
);
CREATE INDEX IF NOT EXISTS ON jwt_secrets(key);
CREATE INDEX IF NOT EXISTS ON jwt_secrets(secret);
CREATE INDEX IF NOT EXISTS ON jwt_secrets(consumer_id);
]],
},
}
5 changes: 0 additions & 5 deletions kong/plugins/jwt/migrations/002_130_to_140.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ return {
]],
},
cassandra = {
up = [[
ALTER TABLE jwt_secrets ADD tags set<text>;
]],
}
}
13 changes: 0 additions & 13 deletions kong/plugins/key-auth/migrations/000_base_key_auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,4 @@ return {
END$$;
]],
},

cassandra = {
up = [[
CREATE TABLE IF NOT EXISTS keyauth_credentials(
id uuid PRIMARY KEY,
created_at timestamp,
consumer_id uuid,
key text
);
CREATE INDEX IF NOT EXISTS ON keyauth_credentials(key);
CREATE INDEX IF NOT EXISTS ON keyauth_credentials(consumer_id);
]],
},
}
5 changes: 0 additions & 5 deletions kong/plugins/key-auth/migrations/002_130_to_140.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,4 @@ return {
]],
},
cassandra = {
up = [[
ALTER TABLE keyauth_credentials ADD tags set<text>;
]],
}
}
3 changes: 0 additions & 3 deletions kong/plugins/key-auth/migrations/004_320_to_330.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ return {
END$$;
]],
},
cassandra = {
up = [[]],
}
}
53 changes: 0 additions & 53 deletions kong/plugins/oauth2/migrations/000_base_oauth2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,57 +101,4 @@ return {
END$$;
]],
},

cassandra = {
up = [[
CREATE TABLE IF NOT EXISTS oauth2_credentials(
id uuid PRIMARY KEY,
created_at timestamp,
consumer_id uuid,
client_id text,
client_secret text,
name text,
redirect_uris set<text>
);
CREATE INDEX IF NOT EXISTS ON oauth2_credentials(client_id);
CREATE INDEX IF NOT EXISTS ON oauth2_credentials(consumer_id);
CREATE INDEX IF NOT EXISTS ON oauth2_credentials(client_secret);
CREATE TABLE IF NOT EXISTS oauth2_authorization_codes(
id uuid PRIMARY KEY,
created_at timestamp,
service_id uuid,
credential_id uuid,
authenticated_userid text,
code text,
scope text
) WITH default_time_to_live = 300;
CREATE INDEX IF NOT EXISTS ON oauth2_authorization_codes(code);
CREATE INDEX IF NOT EXISTS ON oauth2_authorization_codes(service_id);
CREATE INDEX IF NOT EXISTS ON oauth2_authorization_codes(credential_id);
CREATE INDEX IF NOT EXISTS ON oauth2_authorization_codes(authenticated_userid);
CREATE TABLE IF NOT EXISTS oauth2_tokens(
id uuid PRIMARY KEY,
created_at timestamp,
service_id uuid,
credential_id uuid,
access_token text,
authenticated_userid text,
refresh_token text,
scope text,
token_type text,
expires_in int
);
CREATE INDEX IF NOT EXISTS ON oauth2_tokens(service_id);
CREATE INDEX IF NOT EXISTS ON oauth2_tokens(access_token);
CREATE INDEX IF NOT EXISTS ON oauth2_tokens(refresh_token);
CREATE INDEX IF NOT EXISTS ON oauth2_tokens(credential_id);
CREATE INDEX IF NOT EXISTS ON oauth2_tokens(authenticated_userid);
]],
},
}
5 changes: 0 additions & 5 deletions kong/plugins/oauth2/migrations/003_130_to_140.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,4 @@ return {
]],
},
cassandra = {
up = [[
ALTER TABLE oauth2_credentials ADD tags set<text>;
]],
}
}
11 changes: 0 additions & 11 deletions kong/plugins/oauth2/migrations/004_200_to_210.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,4 @@ return {

teardown = ws_migration_teardown(operations.postgres.teardown),
},

cassandra = {
up = [[
ALTER TABLE oauth2_authorization_codes ADD challenge text;
ALTER TABLE oauth2_authorization_codes ADD challenge_method text;
ALTER TABLE oauth2_credentials ADD client_type text;
ALTER TABLE oauth2_credentials ADD hash_secret boolean;
]] .. assert(ws_migration_up(operations.cassandra.up)),

teardown = ws_migration_teardown(operations.cassandra.teardown),
},
}
27 changes: 1 addition & 26 deletions kong/plugins/oauth2/migrations/005_210_to_211.lua
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
local operations = require "kong.db.migrations.operations.210_to_211"


local plugin_entities = {
{
name = "oauth2_credentials",
unique_keys = {"client_id"},
},
{
name = "oauth2_authorization_codes",
unique_keys = {"code"},
},
{
name = "oauth2_tokens",
unique_keys = {"access_token", "refresh_token"},
},
}


return {
postgres = {
up = [[]],
up = [[ SELECT 1 ]],
},
cassandra = {
up = [[]],
teardown = function(connector)
return operations.clean_cassandra_fields(connector, plugin_entities)
end
}
}
3 changes: 0 additions & 3 deletions kong/plugins/oauth2/migrations/006_320_to_330.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,4 @@ return {
END$$;
]],
},
cassandra = {
up = [[]],
}
}
Loading

1 comment on commit 95a4343

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:95a434302352d6ec300cd15f2144c669e53ed2e6
Artifacts available https://github.com/Kong/kong/actions/runs/5005815883

Please sign in to comment.