You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2026/05/21 21:10:03 UTC
(airavata-custos) 04/04: Drop compute_cluster_users.status field
This is an automated email from the ASF dual-hosted git repository.
DImuthuUpe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
commit 623760c7ecd139afb1ac894fc1213cb5fd7ea661
Author: lahiruj <la...@gmail.com>
AuthorDate: Thu May 21 16:46:42 2026 -0400
Drop compute_cluster_users.status field
---
.../000016_compute_cluster_users_status.down.sql | 20 -------------
.../000016_compute_cluster_users_status.up.sql | 20 -------------
...es.down.sql => 000016_user_identities.down.sql} | 0
...tities.up.sql => 000016_user_identities.up.sql} | 0
internal/server/server.go | 15 ----------
internal/store/compute_cluster_user_store.go | 20 ++++---------
internal/store/store.go | 2 --
pkg/models/allocation.go | 9 +++---
pkg/service/compute_cluster_user.go | 33 ----------------------
9 files changed, 10 insertions(+), 109 deletions(-)
diff --git a/internal/db/migrations/000016_compute_cluster_users_status.down.sql b/internal/db/migrations/000016_compute_cluster_users_status.down.sql
deleted file mode 100644
index fe9eea446..000000000
--- a/internal/db/migrations/000016_compute_cluster_users_status.down.sql
+++ /dev/null
@@ -1,20 +0,0 @@
--- 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.
-
-ALTER TABLE compute_cluster_users
- DROP KEY idx_compute_cluster_users_status,
- DROP COLUMN status;
diff --git a/internal/db/migrations/000016_compute_cluster_users_status.up.sql b/internal/db/migrations/000016_compute_cluster_users_status.up.sql
deleted file mode 100644
index 5cbeae23e..000000000
--- a/internal/db/migrations/000016_compute_cluster_users_status.up.sql
+++ /dev/null
@@ -1,20 +0,0 @@
--- 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.
-
-ALTER TABLE compute_cluster_users
- ADD COLUMN status VARCHAR(32) NOT NULL DEFAULT 'ACTIVE' AFTER local_username,
- ADD KEY idx_compute_cluster_users_status (status);
diff --git a/internal/db/migrations/000017_user_identities.down.sql b/internal/db/migrations/000016_user_identities.down.sql
similarity index 100%
rename from internal/db/migrations/000017_user_identities.down.sql
rename to internal/db/migrations/000016_user_identities.down.sql
diff --git a/internal/db/migrations/000017_user_identities.up.sql b/internal/db/migrations/000016_user_identities.up.sql
similarity index 100%
rename from internal/db/migrations/000017_user_identities.up.sql
rename to internal/db/migrations/000016_user_identities.up.sql
diff --git a/internal/server/server.go b/internal/server/server.go
index 9844b8d3a..086e8de64 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -70,7 +70,6 @@ func (s *Server) routes() {
s.mux.HandleFunc("POST /compute-cluster-users", s.createComputeClusterUser)
s.mux.HandleFunc("GET /compute-cluster-users/{id}", s.getComputeClusterUser)
s.mux.HandleFunc("PUT /compute-cluster-users/{id}", s.updateComputeClusterUser)
- s.mux.HandleFunc("PUT /compute-cluster-users/{id}/status", s.updateComputeClusterUserStatus)
s.mux.HandleFunc("DELETE /compute-cluster-users/{id}", s.deleteComputeClusterUser)
s.mux.HandleFunc("GET /compute-clusters/{id}/users", s.listComputeClusterUsersByCluster)
s.mux.HandleFunc("GET /compute-clusters/{id}/users/{userId}", s.getComputeClusterUserByPair)
@@ -907,20 +906,6 @@ func (s *Server) updateProjectStatus(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, p)
}
-func (s *Server) updateComputeClusterUserStatus(w http.ResponseWriter, r *http.Request) {
- var req statusUpdateRequest
- if err := decodeJSON(r, &req); err != nil {
- writeError(w, http.StatusBadRequest, err)
- return
- }
- cu, err := s.svc.UpdateComputeClusterUserStatus(r.Context(), r.PathValue("id"), models.AllocationStatus(req.Status))
- if err != nil {
- writeServiceError(w, err)
- return
- }
- writeJSON(w, http.StatusOK, cu)
-}
-
func (s *Server) createUserIdentity(w http.ResponseWriter, r *http.Request) {
var e models.UserIdentity
if err := decodeJSON(r, &e); err != nil {
diff --git a/internal/store/compute_cluster_user_store.go b/internal/store/compute_cluster_user_store.go
index c345d0330..8e56b0c60 100644
--- a/internal/store/compute_cluster_user_store.go
+++ b/internal/store/compute_cluster_user_store.go
@@ -36,7 +36,7 @@ func NewComputeClusterUserStore(db *sqlx.DB) ComputeClusterUserStore {
return &mysqlComputeClusterUserStore{db: db}
}
-const computeClusterUserColumns = `id, compute_cluster_id, user_id, local_username, status`
+const computeClusterUserColumns = `id, compute_cluster_id, user_id, local_username`
func (s *mysqlComputeClusterUserStore) FindByID(ctx context.Context, id string) (*models.ComputeClusterUser, error) {
var c models.ComputeClusterUser
@@ -95,9 +95,9 @@ func (s *mysqlComputeClusterUserStore) FindByUser(ctx context.Context, userID st
func (s *mysqlComputeClusterUserStore) Create(ctx context.Context, tx *sql.Tx, c *models.ComputeClusterUser) error {
_, err := tx.ExecContext(ctx,
- `INSERT INTO compute_cluster_users (id, compute_cluster_id, user_id, local_username, status)
- VALUES (?, ?, ?, ?, ?)`,
- c.ID, c.ComputeClusterID, c.UserID, c.LocalUsername, c.Status)
+ `INSERT INTO compute_cluster_users (id, compute_cluster_id, user_id, local_username)
+ VALUES (?, ?, ?, ?)`,
+ c.ID, c.ComputeClusterID, c.UserID, c.LocalUsername)
return err
}
@@ -106,17 +106,9 @@ func (s *mysqlComputeClusterUserStore) Update(ctx context.Context, tx *sql.Tx, c
`UPDATE compute_cluster_users
SET compute_cluster_id = ?,
user_id = ?,
- local_username = ?,
- status = ?
+ local_username = ?
WHERE id = ?`,
- c.ComputeClusterID, c.UserID, c.LocalUsername, c.Status, c.ID)
- return err
-}
-
-func (s *mysqlComputeClusterUserStore) UpdateStatus(ctx context.Context, tx *sql.Tx, id string, status models.AllocationStatus) error {
- _, err := tx.ExecContext(ctx,
- `UPDATE compute_cluster_users SET status = ? WHERE id = ?`,
- status, id)
+ c.ComputeClusterID, c.UserID, c.LocalUsername, c.ID)
return err
}
diff --git a/internal/store/store.go b/internal/store/store.go
index f3a7a6b00..231393634 100644
--- a/internal/store/store.go
+++ b/internal/store/store.go
@@ -88,8 +88,6 @@ type ComputeClusterUserStore interface {
Create(ctx context.Context, tx *sql.Tx, c *models.ComputeClusterUser) error
// Update replaces mutable fields of an existing mapping within the provided transaction.
Update(ctx context.Context, tx *sql.Tx, c *models.ComputeClusterUser) error
- // UpdateStatus sets the lifecycle status of an existing mapping within the provided transaction.
- UpdateStatus(ctx context.Context, tx *sql.Tx, id string, status models.AllocationStatus) error
// ReassignUser moves every mapping owned by fromUserID over to toUserID,
// dropping fromUserID's rows on clusters where toUserID already has one.
ReassignUser(ctx context.Context, tx *sql.Tx, fromUserID, toUserID string) error
diff --git a/pkg/models/allocation.go b/pkg/models/allocation.go
index 9fb9e94f5..a8fcd3976 100644
--- a/pkg/models/allocation.go
+++ b/pkg/models/allocation.go
@@ -16,11 +16,10 @@ type ComputeCluster struct {
}
type ComputeClusterUser struct {
- ID string `json:"id" db:"id"`
- ComputeClusterID string `json:"compute_cluster_id" db:"compute_cluster_id"`
- UserID string `json:"user_id" db:"user_id"`
- LocalUsername string `json:"local_username" db:"local_username"` // The username of the user on the compute cluster, which may be different from their Airavata Custos username.
- Status AllocationStatus `json:"status" db:"status"`
+ ID string `json:"id" db:"id"`
+ ComputeClusterID string `json:"compute_cluster_id" db:"compute_cluster_id"`
+ UserID string `json:"user_id" db:"user_id"`
+ LocalUsername string `json:"local_username" db:"local_username"` // The username of the user on the compute cluster, which may be different from their Airavata Custos username.
}
type ComputeAllocation struct {
diff --git a/pkg/service/compute_cluster_user.go b/pkg/service/compute_cluster_user.go
index b3b268ae4..b8311bbf4 100644
--- a/pkg/service/compute_cluster_user.go
+++ b/pkg/service/compute_cluster_user.go
@@ -45,9 +45,6 @@ func (s *Service) CreateComputeClusterUser(ctx context.Context, cu *models.Compu
if cu.ID == "" {
cu.ID = newID()
}
- if cu.Status == "" {
- cu.Status = models.ACTIVE
- }
if cluster, err := s.clusters.FindByID(ctx, cu.ComputeClusterID); err != nil {
return nil, fmt.Errorf("lookup compute cluster: %w", err)
@@ -157,9 +154,6 @@ func (s *Service) UpdateComputeClusterUser(ctx context.Context, cu *models.Compu
if cu.LocalUsername == "" {
cu.LocalUsername = existing.LocalUsername
}
- if cu.Status == "" {
- cu.Status = existing.Status
- }
if err := s.inTx(ctx, func(tx *sql.Tx) error {
return s.clusterUsers.Update(ctx, tx, cu)
}); err != nil {
@@ -170,33 +164,6 @@ func (s *Service) UpdateComputeClusterUser(ctx context.Context, cu *models.Compu
return nil
}
-// UpdateComputeClusterUserStatus sets the lifecycle status of the mapping
-// identified by id. Other fields are preserved.
-func (s *Service) UpdateComputeClusterUserStatus(ctx context.Context, id string, status models.AllocationStatus) (*models.ComputeClusterUser, error) {
- if id == "" {
- return nil, fmt.Errorf("%w: compute cluster user id is required", ErrInvalidInput)
- }
- if status == "" {
- return nil, fmt.Errorf("%w: status is required", ErrInvalidInput)
- }
- existing, err := s.clusterUsers.FindByID(ctx, id)
- if err != nil {
- return nil, fmt.Errorf("lookup compute cluster user: %w", err)
- }
- if existing == nil {
- return nil, ErrNotFound
- }
- if err := s.inTx(ctx, func(tx *sql.Tx) error {
- return s.clusterUsers.UpdateStatus(ctx, tx, id, status)
- }); err != nil {
- return nil, fmt.Errorf("update compute cluster user status: %w", err)
- }
- existing.Status = status
-
- s.eventBus.Publish(events.ComputeClusterUserUpdateEvent, existing)
- return existing, nil
-}
-
// DeleteComputeClusterUser removes a compute-cluster user mapping by ID.
func (s *Service) DeleteComputeClusterUser(ctx context.Context, id string) error {
if id == "" {