Skip to content

Commit ef85967

Browse files
authored
Log error when trying to clone from different storage class driver
1 parent a631a82 commit ef85967

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

core/concurrent_core.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,6 +2183,11 @@ func (o *ConcurrentTridentOrchestrator) cloneVolume(
21832183
return nil, errors.NotFoundError("backend for source volume %s not found", volConfig.CloneSourceVolume)
21842184
}
21852185

2186+
if volConfig.StorageClass != sourceVolume.Config.StorageClass {
2187+
Logc(ctx).Errorf("Clone volume %s from source volume %s with different storage classes is not recommended.",
2188+
volConfig.Name, volConfig.CloneSourceVolume)
2189+
}
2190+
21862191
if volConfig.Size != "" {
21872192
cloneSourceVolumeSize, err := strconv.ParseInt(sourceVolume.Config.Size, 10, 64)
21882193
if err != nil {
@@ -2367,6 +2372,11 @@ func (o *ConcurrentTridentOrchestrator) cloneVolumeRetry(
23672372

23682373
Logc(ctx).WithFields(logFields).Debug("Cloning volume.")
23692374

2375+
if cloneConfig.StorageClass != sourceVolConfig.StorageClass {
2376+
Logc(ctx).Errorf("Clone volume %s from source volume %s with different storage classes is not recommended.",
2377+
cloneConfig.Name, cloneConfig.CloneSourceVolume)
2378+
}
2379+
23702380
// Create the volume
23712381
createVolume := func() error {
23722382
if volume, err = backend.CloneVolume(ctx, sourceVolConfig, cloneConfig, pool, false); err != nil {

core/orchestrator_core.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,6 +2290,11 @@ func (o *TridentOrchestrator) cloneVolumeInitial(
22902290
return nil, errors.NotFoundError("source volume not found: %s", volumeConfig.CloneSourceVolume)
22912291
}
22922292

2293+
if volumeConfig.StorageClass != sourceVolume.Config.StorageClass {
2294+
Logc(ctx).Errorf("Clone volume %s from source volume %s with different storage classes is not recommended.",
2295+
volumeConfig.Name, volumeConfig.CloneSourceVolume)
2296+
}
2297+
22932298
Logc(ctx).WithFields(LogFields{
22942299
"Config.Size": sourceVolume.Config.Size,
22952300
}).Trace("Checking volume size.")
@@ -2525,6 +2530,11 @@ func (o *TridentOrchestrator) cloneVolumeRetry(
25252530
return nil, errors.NotFoundError("source volume not found: %s", cloneConfig.CloneSourceVolume)
25262531
}
25272532

2533+
if cloneConfig.StorageClass != sourceVolume.Config.StorageClass {
2534+
Logc(ctx).Errorf("Clone volume %s from source volume %s with different storage classes is not recommended.",
2535+
cloneConfig.Name, cloneConfig.CloneSourceVolume)
2536+
}
2537+
25282538
backend, found = o.backends[txn.VolumeCreatingConfig.BackendUUID]
25292539
if !found {
25302540
// Should never get here but just to be safe

0 commit comments

Comments
 (0)