lahirujayathilake commented on code in PR #748:
URL: https://github.com/apache/airavata-custos/pull/748#discussion_r4591914493


##########
internal/db/migrations/000010_storages.up.sql:
##########
@@ -0,0 +1,53 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+CREATE TABLE IF NOT EXISTS storages
+(
+    id                 VARCHAR(255)   NOT NULL,
+    compute_cluster_id VARCHAR(255)   NOT NULL,
+    type               VARCHAR(32)    NOT NULL DEFAULT '',
+    path               TEXT           NOT NULL,
+    username           VARCHAR(255)   NOT NULL DEFAULT '',
+    allocation_id      VARCHAR(255),
+    allocation_name    VARCHAR(255),

Review Comment:
   if a record of this table link with an allocation isn't it better to have a 
foreign key from `compute_allocation_memberships` and remove some columns?



##########
internal/db/migrations/000010_storages.up.sql:
##########
@@ -0,0 +1,53 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+CREATE TABLE IF NOT EXISTS storages
+(
+    id                 VARCHAR(255)   NOT NULL,
+    compute_cluster_id VARCHAR(255)   NOT NULL,
+    type               VARCHAR(32)    NOT NULL DEFAULT '',
+    path               TEXT           NOT NULL,
+    username           VARCHAR(255)   NOT NULL DEFAULT '',
+    allocation_id      VARCHAR(255),
+    allocation_name    VARCHAR(255),
+    start_time         TIMESTAMPTZ(6),
+    end_time           TIMESTAMPTZ(6),
+    owner              VARCHAR(255)   NOT NULL,
+    "group"            VARCHAR(255)   NOT NULL,
+    mode               TEXT           NOT NULL,
+    quota_bytes        BIGINT         NOT NULL DEFAULT 0,
+    quota_inodes       BIGINT         NOT NULL DEFAULT 0,
+    quota_until        TIMESTAMPTZ(6),
+    status             VARCHAR(16)    NOT NULL DEFAULT 'active',
+    PRIMARY KEY (id),
+    CONSTRAINT chk_storages_status CHECK (status IN ('active', 
'pending_deletion')),
+    CONSTRAINT uq_storages_path UNIQUE (compute_cluster_id, path)
+);
+
+-- Moves the folders the VAST connector tracked before storages moved to core.
+DO $$ BEGIN
+IF to_regclass('vast_folders') IS NOT NULL THEN

Review Comment:
   core shouldn't hold any code related to connectors



##########
pkg/models/storage.go:
##########
@@ -0,0 +1,78 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package models
+
+import "time"
+
+// StorageType names what a storage is for, and so whose it is: an account's, 
an allocation's, or a member's in it.
+type StorageType string
+
+const (
+       StorageUserHome      StorageType = "user_home"
+       StorageUserScratch   StorageType = "user_scratch"
+       StorageProject       StorageType = "project"
+       StorageProjectShared StorageType = "project_shared"
+       StorageProjectUser   StorageType = "project_user"
+)
+
+// StorageTypes lists every type; a path two types give goes to the first.
+var StorageTypes = []StorageType{StorageUserHome, StorageUserScratch, 
StorageProject, StorageProjectShared, StorageProjectUser}
+
+// BelongsToUser holds for a type made per account, alone or in an allocation.
+func (t StorageType) BelongsToUser() bool {
+       return t == StorageUserHome || t == StorageUserScratch || t == 
StorageProjectUser
+}
+
+// BelongsToAllocation holds for a type made per allocation, alone or per 
member.
+func (t StorageType) BelongsToAllocation() bool {
+       return t == StorageProject || t == StorageProjectShared || t == 
StorageProjectUser
+}
+
+// StorageTarget says how a cluster's storage of one type is made. Path, Owner 
and Group are templates over {user},
+// the account's username, and {allocation}, the allocation's group. A zero 
HardLimitSize means no quota of its own,
+// so the storage counts against the one above it.
+type StorageTarget struct {
+       Path            string `yaml:"path"`
+       Owner           string `yaml:"owner"`
+       Group           string `yaml:"group"`
+       Mode            string `yaml:"mode"` // Octal permission bits, such as 
"0700".
+       HardLimitSize   int64  `yaml:"hard_limit_size"`
+       HardLimitInodes int64  `yaml:"hard_limit_inodes"`
+}
+
+// Storage is one owner's storage on a cluster, as a storage connector makes 
it. Username and the allocation fields say
+// who it is for; the allocation fields are a copy, so they outlive the 
allocation. A zero quota means none of its own.
+type Storage struct {

Review Comment:
   fyi - https://github.com/apache/airavata-custos/pull/748/changes#r4591914493



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to