Skip to content

Latest commit

 

History

History
242 lines (190 loc) · 9.1 KB

File metadata and controls

242 lines (190 loc) · 9.1 KB

Cloud-store-sdk v2.0.0 Upgrade - Implementation Verification

Status: ✅ ALL CODE CHANGES IMPLEMENTED AND IN PLACE

Date: February 23, 2026 Scope: Complete upgrade from cloud-store-sdk v1.4.8.1 → v2.0.0 with Guice StorageModule pattern


Implementation Checklist

✅ Core Implementation Files

1. StorageModule.java (NEW)

  • Location: platform-modules/mimetype-manager/src/main/java/modules/StorageModule.java
  • Status: ✅ Created
  • Details:
    • Guice AbstractModule with @Provides @Singleton method
    • provideStorageService() returns IStorageService (not BaseStorageService)
    • Uses StorageConfig.StorageType and StorageConfig.AuthType inner classes
    • Implements ACCESS_KEY vs OIDC switching logic
    • For ACCESS_KEY: reads cloud_storage_key and cloud_storage_secret from config
    • For OIDC: relies on Azure SDK's credential chain (Workload Identity)

2. StorageService.scala (MODIFIED)

  • Location: platform-modules/mimetype-manager/src/main/scala/org/sunbird/cloudstore/StorageService.scala
  • Status: ✅ Modified for constructor injection
  • Details:
    • @Singleton annotation from javax.inject
    • Constructor: @Inject()(storageService: IStorageService)
    • Parameter type: IStorageService (correct v2.0.0 interface)
    • getService: IStorageService method returns injected instance
    • All utility methods preserved (uploadFile, uploadDirectory, getSignedURL, etc.)

3. MimeTypeManagerFactory.scala (MODIFIED)

  • Location: platform-modules/mimetype-manager/src/main/scala/org/sunbird/mimetype/factory/MimeTypeManagerFactory.scala
  • Status: ✅ Updated to lazy Injector pattern
  • Details:
    • Changed from implicit val ss: StorageService = new StorageService to lazy initialization
    • Uses play.api.Play.current.injector.instanceOf[StorageService]
    • Enables deferred instantiation until Play context is available

4. IProcessor.scala (MODIFIED)

  • Location: platform-modules/mimetype-manager/src/main/scala/org/sunbird/mimetype/ecml/processor/IProcessor.scala
  • Status: ✅ Updated to lazy Injector pattern
  • Details:
    • Same lazy Injector pattern as MimeTypeManagerFactory
    • Abstract base class for ECML processors

5. Test Files Updated (9 files)

  • Status: ✅ All updated with constructor parameter injection
  • Files:
    1. platform-modules/mimetype-manager/src/test/scala/org/sunbird/cloudstore/StorageServiceTest.scala
    2. platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/impl/PluginMimeTypeMgrImplTest.scala
    3. platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/impl/DocumentMimeTypeMgrImplTest.scala
    4. platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/impl/HtmlMimeTypeMgrImplTest.scala
    5. platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/impl/CollectionMimeTypeMgrImplTest.scala
    6. platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/impl/YouTubeMimeTypeMgrImplTest.scala
    7. platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/impl/AssetMimeTypeMgrImplTest.scala
    8. platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/impl/H5PMimeTypeMgrImplTest.scala
    9. platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/BaseMimeTypeManagerTest.scala
  • Pattern: new StorageService(null.asInstanceOf[org.sunbird.cloud.storage.IStorageService])

✅ Dependency Management

pom.xml Files Updated

1. platform-modules/mimetype-manager/pom.xml

  • ✅ Added: javax.inject:javax.inject:1 (Guice annotations)
  • ✅ Added: org.sunbird:cloud-storage-sdk-api:2.0.0 (compile-time)
  • ✅ Added: org.sunbird:cloud-storage-sdk-azure:2.0.0 (runtime scope for ServiceLoader)

2. content-api/content-service/pom.xml

  • ✅ Same cloud-storage-sdk dependencies as mimetype-manager

3. knowlg-service/pom.xml

  • ✅ Added explicit cloud-storage-sdk dependencies (previously only transitive through content-actors)

✅ Application Configuration

content-api/content-service/conf/application.conf

  • play.modules.enabled += modules.StorageModule (line 140)
  • ✅ Cloud storage config block:
    cloud_storage_type="azure"
    cloud_storage_auth_type="ACCESS_KEY"
    cloud_storage_key=""
    cloud_storage_secret=""
    cloud_storage_container=""
    cloud_storage_dial_container=""

knowlg-service/conf/application.conf

  • play.modules.enabled += modules.StorageModule (line 212)
  • ✅ Cloud storage config block with same defaults
  • ✅ Removed legacy GCP-specific configuration keys
  • ✅ Changed cloud_storage_type=""cloud_storage_type="azure"

taxonomy-api/taxonomy-service/conf/application.conf

  • ✅ Added standard cloud storage config block (StorageModule NOT enabled — no cloud-using actors)

assessment-api/assessment-service/conf/application.conf

  • ✅ Added standard cloud storage config block (StorageModule NOT enabled)

search-api/search-service/conf/application.conf

  • ✅ Added standard cloud storage config block (StorageModule NOT enabled)

✅ Docker Configuration

build/content-service/Dockerfile

  • ✅ Environment variables set:
    ENV cloud_storage_type=azure
    ENV cloud_storage_auth_type=OIDC

build/knowlg-service/Dockerfile

  • ✅ Environment variables set:
    ENV cloud_storage_type=azure
    ENV cloud_storage_auth_type=OIDC

Configuration Switching Guide

Local Development (Developer/CI)

# In application.conf or as environment variables:
cloud_storage_type="azure"
cloud_storage_auth_type="ACCESS_KEY"
cloud_storage_key="<azure-storage-account-name>"
cloud_storage_secret="<azure-storage-account-key>"

Production (Kubernetes)

# In Dockerfile (already set):
ENV cloud_storage_type=azure
ENV cloud_storage_auth_type=OIDC

# Azure Workload Identity Environment Variables (injected by Kubernetes):
AZURE_CLIENT_ID=<...>
AZURE_TENANT_ID=<...>
AZURE_FEDERATED_TOKEN_FILE=/var/run/secrets/workload-identity-token

Architecture Changes Summary

Aspect Before (v1.4.8.1) After (v2.0.0)
SDK Type Monolithic Scala artifact Multi-module Java SDK
Service Class BaseStorageService (public) IStorageService (interface)
Initialization Lazy init in StorageService Guice @Provides @Singleton
Dependency Injection Manual via factory Guice constructor injection
DI Pattern Not consistent Play Framework DI
Auth Type Hardcoded Configurable (ACCESS_KEY/OIDC)
CSP Discovery Manual imports Java ServiceLoader
Config Source Inline builder Play Config object

Verification Steps (After Maven Installation)

1. Compilation Verification

cd /Users/mahesh/Code/Sunbird-Knowlg/knowledge-platform
mvn clean install -DskipTests

Expected: All modules compile without errors, especially:

  • platform-modules/mimetype-manager
  • content-api/content-service
  • knowlg-service

2. Unit Tests

mvn test -pl platform-modules/mimetype-manager

Expected: 5 getMimeType tests + 1 getContainerName exception test pass

3. Local Development Run

export cloud_storage_auth_type=ACCESS_KEY
export cloud_storage_key=<azure-account-name>
export cloud_storage_secret=<azure-account-key>
cd content-api/content-service && mvn play2:run
curl http://localhost:9000/health

Expected: Service starts without errors, health check responds

4. Docker Build

docker build -f build/content-service/Dockerfile .
docker build -f build/knowlg-service/Dockerfile .

Expected: Docker images build successfully with OIDC defaults


Known Limitations & Notes

  1. Maven Requirement: Project build requires Maven 3.9+ (not yet installed in current environment)
  2. ServiceLoader Discovery: CSP implementations are discovered at runtime; ensure appropriate CSP jar is on runtime classpath
  3. Credentials Visibility: ACCESS_KEY credentials should never be committed to version control; use environment variables or local config overrides
  4. Test Null Stubs: Unit tests pass null for IStorageService parameter because they don't invoke getService() or mock it entirely

Files Modified/Created Summary

File Action Type
modules/StorageModule.java CREATE Core Module
StorageService.scala MODIFY Core Service
MimeTypeManagerFactory.scala MODIFY Factory
IProcessor.scala MODIFY Abstract Base
9 test files MODIFY Tests
4 pom.xml files MODIFY Dependencies
5 application.conf files MODIFY Configuration
2 Dockerfile files MODIFY Docker

Total Changes: 24 files modified/created across 2 major versions


Next Steps

  1. Install Maven 3.9+ on your development machine
  2. Run mvn clean install -DskipTests to verify compilation
  3. Run mvn test -pl platform-modules/mimetype-manager to verify tests
  4. Run services locally with ACCESS_KEY credentials for development
  5. Deploy to Kubernetes with OIDC-enabled Dockerfile