lahirujayathilake commented on code in PR #590: URL: https://github.com/apache/airavata-custos/pull/590#discussion_r4172009607
########## connectors/VAST/Storage-Provisioner/internal/subscribers/subscriber.go: ########## @@ -0,0 +1,100 @@ +// 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 subscribers creates the configured directories and quotas on VAST +// once COmanage has provisioned the account, since VAST resolves owners by name +// from the LDAP that COmanage feeds. Mounts are created in config order, so +// parents come first. +package subscribers + +import ( + "context" + "errors" + "log/slog" + "strings" + "time" + + "github.com/apache/airavata-custos/connectors/VAST/Storage-Provisioner/internal/client" + "github.com/apache/airavata-custos/pkg/events" + "github.com/apache/airavata-custos/pkg/models" + "github.com/apache/airavata-custos/pkg/service" +) + +// Mount is a directory created for each account. Path, Owner and Group are +// templates over {user}, the account's username; its quota is named after the path. +type Mount struct { + Path, Owner, Group string + Mode int + HardLimit, HardLimitInodes int64 +} + +type StorageSubscriber struct { + vms *client.Client + bus *events.Bus + core *service.Service + custosClusterID string + mounts []Mount +} + +func NewStorageSubscriber(vms *client.Client, bus *events.Bus, core *service.Service, custosClusterID string, mounts []Mount) *StorageSubscriber { + return &StorageSubscriber{vms: vms, bus: bus, core: core, custosClusterID: custosClusterID, mounts: mounts} +} + +// RegisterSubscribers waits for the "provisioned" update COmanage publishes, which alone releases the work. +func (s *StorageSubscriber) RegisterSubscribers(subscriber string) { + s.bus.SubscribeComputeClusterUserUpdated(subscriber, s.ensureUser) +} + +// ensureUser needs no approval check: COmanage provisions approved accounts only. +func (s *StorageSubscriber) ensureUser(ctx context.Context, cu models.ComputeClusterUser) error { Review Comment: Add audit events and slogs when creating quotas and folders (include the user details and other relevant props) -- 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]
