Skip to content

Commit 4c7626d

Browse files
authored
Merge pull request #293 from cybozu-go/add-technical-note
KAIZEN: add comments explaining the developers' intent.
2 parents 0ac07f4 + 005beef commit 4c7626d

5 files changed

Lines changed: 21 additions & 6 deletions

File tree

api/v1/mantlebackup_types.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ type MantleBackupStatus struct {
5151
// 'snapSize' indicates SIZE of `rbd snap ls`
5252
SnapSize *int64 `json:"snapSize,omitempty"`
5353

54-
// 'transferPartSize' indicates the size of each part of the data
55-
// transferred from the primary to the secondary.
54+
// 'transferPartSize' indicates the size of each part of the data transferred
55+
// from the primary to the secondary.
56+
// Some jobs read the part size from this field rather than directly from the
57+
// mantle-controller command-line argument. This ensures that the part size
58+
// does not change while these jobs for a given MantleBackup are running.
5659
TransferPartSize *resource.Quantity `json:"transferPartSize,omitempty"`
5760
}
5861

charts/mantle-cluster-wide/templates/mantle.cybozu.io_mantlebackups.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,11 @@ spec:
142142
- type: integer
143143
- type: string
144144
description: |-
145-
'transferPartSize' indicates the size of each part of the data
146-
transferred from the primary to the secondary.
145+
'transferPartSize' indicates the size of each part of the data transferred
146+
from the primary to the secondary.
147+
Some jobs read the part size from this field rather than directly from the
148+
mantle-controller command-line argument. This ensures that the part size
149+
does not change while these jobs for a given MantleBackup are running.
147150
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
148151
x-kubernetes-int-or-string: true
149152
type: object

config/crd/bases/mantle.cybozu.io_mantlebackups.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,11 @@ spec:
142142
- type: integer
143143
- type: string
144144
description: |-
145-
'transferPartSize' indicates the size of each part of the data
146-
transferred from the primary to the secondary.
145+
'transferPartSize' indicates the size of each part of the data transferred
146+
from the primary to the secondary.
147+
Some jobs read the part size from this field rather than directly from the
148+
mantle-controller command-line argument. This ensures that the part size
149+
does not change while these jobs for a given MantleBackup are running.
147150
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
148151
x-kubernetes-int-or-string: true
149152
type: object

internal/controller/mantlebackup_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,9 @@ func calculateExportDataPVCSize(transferPartSize *resource.Quantity) (*resource.
15821582
return nil, fmt.Errorf("failed to convert status.transferPartSize to int64: %s", transferPartSize.String())
15831583
}
15841584

1585+
// The margin of the PVC size accounts for the filesystem metadata overhead required in addition
1586+
// to the backup data itself. The lower bound prevents the metadata from taking up a disproportionately
1587+
// large share of the PVC when the backup data size is small.
15851588
if pvcSizeI64 < 512*1024*1024 {
15861589
pvcSizeI64 = 512 * 1024 * 1024
15871590
}

internal/controller/script/job-export.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ write_endpoints
6060
if [ -e "/mantle/export-${PART_NUM}.bin" ]; then
6161
exit
6262
fi
63+
# The export-diff output is first saved to a temporary file and then renamed to the final file used for
64+
# uploading. This makes it easy to detect whether the job was interrupted during export-diff when the
65+
# export job is restarted after an interruption.
6366
rm -f /mantle/tmp.bin
6467
if [ -z "${FROM_SNAP_NAME}" ]; then
6568
rbd export-diff \

0 commit comments

Comments
 (0)