Skip to content

Commit

Permalink
feat(rebuilding): remove volume OfflineReplicaRebuilding from spec an…
Browse files Browse the repository at this point in the history
…d status fields

Longhorn 9090

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit committed Jul 29, 2024
1 parent 4929c7c commit ec68e48
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 56 deletions.
6 changes: 1 addition & 5 deletions controller/volume_rebuilding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,7 @@ func (vbc *VolumeRebuildingController) reconcile(volName string) (err error) {

rebuildingAttachmentTicketID := longhorn.GetAttachmentTicketID(longhorn.AttacherTypeVolumeRebuildingController, volName)

if vol.Status.OfflineReplicaRebuildingRequired {
createOrUpdateAttachmentTicket(va, rebuildingAttachmentTicketID, vol.Status.OwnerID, longhorn.TrueValue, longhorn.AttacherTypeVolumeRebuildingController)
} else {
delete(va.Spec.AttachmentTickets, rebuildingAttachmentTicketID)
}
delete(va.Spec.AttachmentTickets, rebuildingAttachmentTicketID)

return nil
}
Expand Down
10 changes: 0 additions & 10 deletions k8s/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4213,14 +4213,6 @@ spec:
type: array
numberOfReplicas:
type: integer
offlineReplicaRebuilding:
description: OfflineReplicaRebuilding is used to determine if the
offline replica rebuilding feature is enabled or not
enum:
- ignored
- disabled
- enabled
type: string
replicaAutoBalance:
enum:
- ignored
Expand Down Expand Up @@ -4382,8 +4374,6 @@ spec:
type: string
lastDegradedAt:
type: string
offlineReplicaRebuildingRequired:
type: boolean
ownerID:
type: string
pendingNodeID:
Expand Down
14 changes: 0 additions & 14 deletions k8s/pkg/apis/longhorn/v1beta2/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,6 @@ const (
DataEngineTypeAll = DataEngineType("all")
)

type OfflineReplicaRebuilding string

const (
OfflineReplicaRebuildingIgnored = OfflineReplicaRebuilding("ignored")
OfflineReplicaRebuildingEnabled = OfflineReplicaRebuilding("enabled")
OfflineReplicaRebuildingDisabled = OfflineReplicaRebuilding("disabled")
)

type KubernetesStatus struct {
// +optional
PVName string `json:"pvName"`
Expand Down Expand Up @@ -302,10 +294,6 @@ type VolumeSpec struct {
// +kubebuilder:validation:Enum=v1;v2
// +optional
DataEngine DataEngineType `json:"dataEngine"`
// OfflineReplicaRebuilding is used to determine if the offline replica rebuilding feature is enabled or not
// +kubebuilder:validation:Enum=ignored;disabled;enabled
// +optional
OfflineReplicaRebuilding OfflineReplicaRebuilding `json:"offlineReplicaRebuilding"`
// +optional
SnapshotMaxCount int `json:"snapshotMaxCount"`
// +kubebuilder:validation:Type=string
Expand Down Expand Up @@ -365,8 +353,6 @@ type VolumeStatus struct {
ShareEndpoint string `json:"shareEndpoint"`
// +optional
ShareState ShareManagerState `json:"shareState"`
// +optional
OfflineReplicaRebuildingRequired bool `json:"offlineReplicaRebuildingRequired"`
}

// +genclient
Expand Down
1 change: 0 additions & 1 deletion manager/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ func (m *VolumeManager) Create(name string, spec *longhorn.VolumeSpec, recurring
ReplicaZoneSoftAntiAffinity: spec.ReplicaZoneSoftAntiAffinity,
ReplicaDiskSoftAntiAffinity: spec.ReplicaDiskSoftAntiAffinity,
DataEngine: spec.DataEngine,
OfflineReplicaRebuilding: spec.OfflineReplicaRebuilding,
FreezeFilesystemForSnapshot: spec.FreezeFilesystemForSnapshot,
},
}
Expand Down
9 changes: 0 additions & 9 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,15 +856,6 @@ func ValidateStorageNetwork(value string) (err error) {
return nil
}

func ValidateOfflineReplicaRebuilding(mode string) error {
if mode != string(longhorn.OfflineReplicaRebuildingIgnored) &&
mode != string(longhorn.OfflineReplicaRebuildingEnabled) &&
mode != string(longhorn.OfflineReplicaRebuildingDisabled) {
return fmt.Errorf("invalid offline replica rebuilding mode: %v", mode)
}
return nil
}

func ValidateSnapshotDataIntegrity(mode string) error {
if mode != string(longhorn.SnapshotDataIntegrityDisabled) &&
mode != string(longhorn.SnapshotDataIntegrityEnabled) &&
Expand Down
3 changes: 0 additions & 3 deletions upgrade/v14xto150/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ func upgradeVolumes(namespace string, lhClient *lhclientset.Clientset, resourceM
if v.Spec.BackendStoreDriver == "" {
v.Spec.BackendStoreDriver = longhorn.BackendStoreDriverTypeV1
}
if v.Spec.OfflineReplicaRebuilding == "" {
v.Spec.OfflineReplicaRebuilding = longhorn.OfflineReplicaRebuildingDisabled
}
if v.Status.PendingNodeID != "" {
v.Status.PendingNodeID = ""
}
Expand Down
2 changes: 0 additions & 2 deletions upgrade/v16xto170/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ func upgradeVolumes(namespace string, lhClient *lhclientset.Clientset, resourceM
}

for _, v := range volumeMap {
v.Spec.OfflineReplicaRebuilding = longhorn.OfflineReplicaRebuildingDisabled

if v.Spec.FreezeFilesystemForSnapshot == "" {
v.Spec.FreezeFilesystemForSnapshot = longhorn.FreezeFilesystemForSnapshotDefault
}
Expand Down
6 changes: 0 additions & 6 deletions webhook/resources/volume/mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,6 @@ func (v *volumeMutator) Create(request *admission.Request, newObj runtime.Object
if volume.Spec.ReplicaDiskSoftAntiAffinity != longhorn.ReplicaDiskSoftAntiAffinityDisabled {
patchOps = append(patchOps, fmt.Sprintf(`{"op": "replace", "path": "/spec/replicaDiskSoftAntiAffinity", "value": "%s"}`, longhorn.ReplicaDiskSoftAntiAffinityDefault))
}
if volume.Spec.OfflineReplicaRebuilding != longhorn.OfflineReplicaRebuildingDisabled {
patchOps = append(patchOps, fmt.Sprintf(`{"op": "replace", "path": "/spec/offlineReplicaRebuilding", "value": "%s"}`, longhorn.OfflineReplicaRebuildingDisabled))
}
}

var patchOpsInCommon admission.PatchOps
Expand Down Expand Up @@ -328,9 +325,6 @@ func mutate(newObj runtime.Object, moreLabels map[string]string) (admission.Patc
if string(volume.Spec.DataEngine) == "" {
patchOps = append(patchOps, fmt.Sprintf(`{"op": "replace", "path": "/spec/dataEngine", "value": "%s"}`, longhorn.DataEngineTypeV1))
}
if volume.Spec.OfflineReplicaRebuilding != longhorn.OfflineReplicaRebuildingDisabled {
patchOps = append(patchOps, fmt.Sprintf(`{"op": "replace", "path": "/spec/offlineReplicaRebuilding", "value": "%s"}`, longhorn.OfflineReplicaRebuildingDisabled))
}
if volume.Spec.DataLocality == longhorn.DataLocalityStrictLocal {
patchOps = append(patchOps, `{"op": "replace", "path": "/spec/revisionCounterDisabled", "value": true}`)
}
Expand Down
6 changes: 0 additions & 6 deletions webhook/resources/volume/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,6 @@ func (v *volumeValidator) Update(request *admission.Request, oldObj runtime.Obje
}
}

if newVolume.Spec.OfflineReplicaRebuilding != longhorn.OfflineReplicaRebuildingDisabled {
err := fmt.Errorf("changing offline replica rebuilding for volume %v is not supported for data engine %v",
newVolume.Name, newVolume.Spec.DataEngine)
return werror.NewInvalidError(err.Error(), "")
}

// prevent the changing v.Spec.MigrationNodeID to different node when the volume is doing live migration (when v.Status.CurrentMigrationNodeID != "")
if newVolume.Status.CurrentMigrationNodeID != "" &&
newVolume.Spec.MigrationNodeID != oldVolume.Spec.MigrationNodeID &&
Expand Down

0 comments on commit ec68e48

Please sign in to comment.