Skip to content

Commit

Permalink
[FSTORE-588] Kafka Authoriser Update (logicalclocks#879)
Browse files Browse the repository at this point in the history
  • Loading branch information
bubriks authored Mar 2, 2023
1 parent 1a2e732 commit 89c69f8
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 44 deletions.
43 changes: 1 addition & 42 deletions files/default/sql/ddl/3.2.0__initial_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ CREATE TABLE `project_topics` (
`num_partitions` int(11) DEFAULT NULL,
`num_replicas` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `topic_name_UNIQUE` (`topic_name`),
UNIQUE KEY `topic_project` (`topic_name`,`project_id`),
CONSTRAINT `project_idx_proj_topics` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `subject_idx` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
Expand Down Expand Up @@ -1150,24 +1151,6 @@ CREATE TABLE `serving` (
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `shared_topics`
--

/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `shared_topics` (
`topic_name` varchar(255) COLLATE latin1_general_cs NOT NULL,
`project_id` int(11) NOT NULL,
`owner_id` int(11) NOT NULL,
`accepted` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`project_id`,`topic_name`),
KEY `topic_idx` (`topic_name`,`owner_id`),
CONSTRAINT `topic_idx_shared` FOREIGN KEY (`topic_name`,`owner_id`) REFERENCES `project_topics` (`topic_name`,`project_id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs
/*!50100 PARTITION BY KEY (topic_name) */;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `system_commands`
--
Expand Down Expand Up @@ -1228,30 +1211,6 @@ CREATE TABLE `tensorboard` (
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `topic_acls`
--

/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `topic_acls` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`topic_name` varchar(255) COLLATE latin1_general_cs NOT NULL,
`project_id` int(11) NOT NULL,
`username` varchar(150) COLLATE latin1_general_cs NOT NULL,
`principal` varchar(170) COLLATE latin1_general_cs NOT NULL,
`permission_type` varchar(255) COLLATE latin1_general_cs NOT NULL,
`operation_type` varchar(255) COLLATE latin1_general_cs NOT NULL,
`host` varchar(255) COLLATE latin1_general_cs NOT NULL,
`role` varchar(255) COLLATE latin1_general_cs NOT NULL,
PRIMARY KEY (`id`),
KEY `username` (`username`),
KEY `topic_idx` (`topic_name`,`project_id`),
CONSTRAINT `FK_262_338` FOREIGN KEY (`username`) REFERENCES `users` (`email`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `topic_idx_topic_acls` FOREIGN KEY (`topic_name`,`project_id`) REFERENCES `project_topics` (`topic_name`,`project_id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
/*!40101 SET character_set_client = @saved_cs_client */;


CREATE TABLE `feature_view` (
`id` int(11) NOT NULL AUTO_INCREMENT,
Expand Down
13 changes: 12 additions & 1 deletion files/default/sql/ddl/updates/3.2.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,15 @@ CREATE TABLE IF NOT EXISTS `hdfs_command_execution` (

ALTER TABLE `hopsworks`.`executions` MODIFY COLUMN `app_id` char(45) COLLATE latin1_general_cs DEFAULT NULL;

ALTER TABLE `hopsworks`.`maggy_driver` MODIFY COLUMN `app_id` char(45) COLLATE latin1_general_cs NOT NULL;
ALTER TABLE `hopsworks`.`maggy_driver` MODIFY COLUMN `app_id` char(45) COLLATE latin1_general_cs NOT NULL;

DROP TABLE `shared_topics`;
DROP TABLE `topic_acls`;

ALTER TABLE `hopsworks`.`project_topics` ADD UNIQUE KEY `topic_name_UNIQUE` (`topic_name`);

SET SQL_SAFE_UPDATES = 0;
UPDATE `project_team`
SET team_role = 'Data owner'
WHERE team_member = '[email protected]';
SET SQL_SAFE_UPDATES = 1;
50 changes: 50 additions & 0 deletions files/default/sql/ddl/updates/undo/3.2.0__undo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,53 @@ DROP TABLE IF EXISTS `hopsworks`.`hdfs_command_execution`;
ALTER TABLE `hopsworks`.`executions` MODIFY COLUMN `app_id` char(30) COLLATE latin1_general_cs DEFAULT NULL;

ALTER TABLE `hopsworks`.`maggy_driver` MODIFY COLUMN `app_id` char(30) COLLATE latin1_general_cs NOT NULL;

--
-- Table structure for table `shared_topics`
--

/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `shared_topics` (
`topic_name` varchar(255) COLLATE latin1_general_cs NOT NULL,
`project_id` int(11) NOT NULL,
`owner_id` int(11) NOT NULL,
`accepted` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`project_id`,`topic_name`),
KEY `topic_idx` (`topic_name`,`owner_id`),
CONSTRAINT `topic_idx_shared` FOREIGN KEY (`topic_name`,`owner_id`) REFERENCES `project_topics` (`topic_name`,`project_id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs
/*!50100 PARTITION BY KEY (topic_name) */;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `topic_acls`
--

/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `topic_acls` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`topic_name` varchar(255) COLLATE latin1_general_cs NOT NULL,
`project_id` int(11) NOT NULL,
`username` varchar(150) COLLATE latin1_general_cs NOT NULL,
`principal` varchar(170) COLLATE latin1_general_cs NOT NULL,
`permission_type` varchar(255) COLLATE latin1_general_cs NOT NULL,
`operation_type` varchar(255) COLLATE latin1_general_cs NOT NULL,
`host` varchar(255) COLLATE latin1_general_cs NOT NULL,
`role` varchar(255) COLLATE latin1_general_cs NOT NULL,
PRIMARY KEY (`id`),
KEY `username` (`username`),
KEY `topic_idx` (`topic_name`,`project_id`),
CONSTRAINT `FK_262_338` FOREIGN KEY (`username`) REFERENCES `users` (`email`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `topic_idx_topic_acls` FOREIGN KEY (`topic_name`,`project_id`) REFERENCES `project_topics` (`topic_name`,`project_id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
/*!40101 SET character_set_client = @saved_cs_client */;

ALTER TABLE `hopsworks`.`project_topics` DROP INDEX `topic_name_UNIQUE`;

SET SQL_SAFE_UPDATES = 0;
UPDATE `project_team`
SET team_role = 'Data scientist'
WHERE team_member = '[email protected]';
SET SQL_SAFE_UPDATES = 1;
4 changes: 3 additions & 1 deletion recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,12 @@
set -e
#{exec} -e \"CREATE USER IF NOT EXISTS \'#{node['kkafka']['mysql']['user']}\'@\'127.0.0.1\' IDENTIFIED BY \'#{node['kkafka']['mysql']['password']}\';\"
#{exec} -e \"GRANT NDB_STORED_USER ON *.* TO \'#{node['kkafka']['mysql']['user']}\'@\'127.0.0.1\';\"
#{exec} -e \"GRANT SELECT ON #{node['hopsworks']['db']}.topic_acls TO \'#{node['kkafka']['mysql']['user']}\'@\'127.0.0.1\';\"
#{exec} -e \"GRANT SELECT ON #{node['hopsworks']['db']}.project TO \'#{node['kkafka']['mysql']['user']}\'@\'127.0.0.1\'\"
#{exec} -e \"GRANT SELECT ON #{node['hopsworks']['db']}.users TO \'#{node['kkafka']['mysql']['user']}\'@\'127.0.0.1\';\"
#{exec} -e \"GRANT SELECT ON #{node['hopsworks']['db']}.project_team TO \'#{node['kkafka']['mysql']['user']}\'@\'127.0.0.1\';\"
#{exec} -e \"GRANT SELECT ON #{node['hopsworks']['db']}.project_topics TO \'#{node['kkafka']['mysql']['user']}\'@\'127.0.0.1\';\"
#{exec} -e \"GRANT SELECT ON #{node['hopsworks']['db']}.dataset_shared_with TO \'#{node['kkafka']['mysql']['user']}\'@\'127.0.0.1\';\"
#{exec} -e \"GRANT SELECT ON #{node['hopsworks']['db']}.dataset TO \'#{node['kkafka']['mysql']['user']}\'@\'127.0.0.1\';\"
EOF
end
rescue
Expand Down

0 comments on commit 89c69f8

Please sign in to comment.