manager: Disallow upgrade replica count when migration or upgrading
@@ -577,6 +577,18 @@ func (m *VolumeManager) UpdateReplicaCount(name string, count int) (v *longhorn.
return nil, err
}
+ if v.Spec.NodeID == "" || v.Status.State != types.VolumeStateAttached {
+ return nil, fmt.Errorf("invalid volume state to update replica count%v", v.Status.State)
+ }
+ if v.Status.Robustness != types.VolumeRobustnessHealthy {
+ return nil, fmt.Errorf("volume must be healthy to update replica count")
+ }
+ if v.Spec.EngineImage != v.Status.CurrentImage {
+ return nil, fmt.Errorf("upgrading in process, cannot update replica count")
+ }
+ if v.Spec.MigrationNodeID != "" {
+ return nil, fmt.Errorf("migration in process, cannot update replica count")
+ }
v.Spec.NumberOfReplicas = count
v, err = m.ds.UpdateVolume(v)
