Longhorn: Upgrade from 1.7.3 to 1.8.1

Change-Id: Ie2076df97ee3d00cbced65ad52888d3b467725d4
diff --git a/charts/longhorn/templates/crds.yaml b/charts/longhorn/templates/crds.yaml
index 3b78dd7..44a19b2 100644
--- a/charts/longhorn/templates/crds.yaml
+++ b/charts/longhorn/templates/crds.yaml
@@ -342,6 +342,9 @@
                       type: string
                     progress:
                       type: integer
+                    realSize:
+                      format: int64
+                      type: integer
                     senderManagerAddress:
                       type: string
                     sendingReference:
@@ -492,9 +495,20 @@
             properties:
               checksum:
                 type: string
+              dataEngine:
+                default: v1
+                enum:
+                - v1
+                - v2
+                type: string
               diskFileSpecMap:
                 additionalProperties:
                   properties:
+                    dataEngine:
+                      enum:
+                      - v1
+                      - v2
+                      type: string
                     evictionRequested:
                       type: boolean
                   type: object
@@ -541,6 +555,11 @@
               diskFileStatusMap:
                 additionalProperties:
                   properties:
+                    dataEngine:
+                      enum:
+                      - v1
+                      - v2
+                      type: string
                     lastStateTransitionTime:
                       type: string
                     message:
@@ -559,14 +578,26 @@
                 type: object
               ownerID:
                 type: string
+              realSize:
+                description: Real size of image in bytes, which may be smaller than
+                  the size when the file is a sparse file. Will be zero until known
+                  (e.g. while a backing image is uploading)
+                format: int64
+                type: integer
               size:
                 format: int64
                 type: integer
               uuid:
                 type: string
+              v2FirstCopyDisk:
+                type: string
+              v2FirstCopyStatus:
+                description: It is pending -> in-progress -> ready/failed
+                type: string
               virtualSize:
-                description: Virtual size of image, which may be larger than physical
-                  size. Will be zero until known (e.g. while a backing image is uploading)
+                description: Virtual size of image in bytes, which may be larger than
+                  physical size. Will be zero until known (e.g. while a backing image
+                  is uploading)
                 format: int64
                 type: integer
             type: object
@@ -643,6 +674,14 @@
             description: BackupBackingImageSpec defines the desired state of the Longhorn
               backing image backup
             properties:
+              backingImage:
+                description: |-
+                  The backing image name.
+                type: string
+              backupTargetName:
+                description: The backup target name.
+                nullable: true
+                type: string
               labels:
                 additionalProperties:
                   type: string
@@ -657,9 +696,9 @@
               userCreated:
                 description: |-
                   Is this CR created by user through API or UI.
-                  Required
                 type: boolean
             required:
+            - backingImage
             - userCreated
             type: object
           status:
@@ -711,6 +750,13 @@
               progress:
                 description: The backing image backup progress.
                 type: integer
+              secret:
+                description: Record the secret if this backup backing image is encrypted
+                type: string
+              secretNamespace:
+                description: Record the secret namespace if this backup backing image
+                  is encrypted
+                type: string
               size:
                 description: The backing image size.
                 format: int64
@@ -814,6 +860,10 @@
       jsonPath: .status.snapshotCreatedAt
       name: SnapshotCreatedAt
       type: string
+    - description: The backup target name
+      jsonPath: .status.backupTargetName
+      name: BackupTarget
+      type: string
     - description: The backup state
       jsonPath: .status.state
       name: State
@@ -876,6 +926,9 @@
               backupCreatedAt:
                 description: The snapshot backup upload finished time.
                 type: string
+              backupTargetName:
+                description: The backup target name.
+                type: string
               compressionMethod:
                 description: Compression method
                 type: string
@@ -1222,6 +1275,10 @@
     subresources:
       status: {}
   - additionalPrinterColumns:
+    - description: The backup target name
+      jsonPath: .spec.backupTargetName
+      name: BackupTarget
+      type: string
     - description: The backup volume creation time
       jsonPath: .status.createdAt
       name: CreatedAt
@@ -1264,11 +1321,18 @@
             description: BackupVolumeSpec defines the desired state of the Longhorn
               backup volume
             properties:
+              backupTargetName:
+                description: The backup target name that the backup volume was synced.
+                nullable: true
+                type: string
               syncRequestedAt:
                 description: The time to request run sync the remote backup volume.
                 format: date-time
                 nullable: true
                 type: string
+              volumeName:
+                description: The volume name that the backup volume was used to backup.
+                type: string
             type: object
           status:
             description: BackupVolumeStatus defines the observed state of the Longhorn
@@ -2056,6 +2120,14 @@
             properties:
               dataEngine:
                 type: string
+              dataEngineSpec:
+                properties:
+                  v2:
+                    properties:
+                      cpuMask:
+                        type: string
+                    type: object
+                type: object
               image:
                 type: string
               nodeID:
@@ -2075,8 +2147,39 @@
                 type: integer
               apiVersion:
                 type: integer
+              backingImages:
+                additionalProperties:
+                  properties:
+                    currentChecksum:
+                      type: string
+                    diskUUID:
+                      type: string
+                    message:
+                      type: string
+                    name:
+                      type: string
+                    progress:
+                      type: integer
+                    size:
+                      format: int64
+                      type: integer
+                    state:
+                      type: string
+                    uuid:
+                      type: string
+                  type: object
+                nullable: true
+                type: object
               currentState:
                 type: string
+              dataEngineStatus:
+                properties:
+                  v2:
+                    properties:
+                      cpuMask:
+                        type: string
+                    type: object
+                type: object
               instanceEngines:
                 additionalProperties:
                   properties:
@@ -2484,6 +2587,12 @@
                       type: string
                     instanceManagerName:
                       type: string
+                    scheduledBackingImage:
+                      additionalProperties:
+                        format: int64
+                        type: integer
+                      nullable: true
+                      type: object
                     scheduledReplica:
                       additionalProperties:
                         format: int64
@@ -3022,6 +3131,11 @@
                 type: string
               logRequested:
                 type: boolean
+              migrationEngineName:
+                description: |-
+                  MigrationEngineName is indicating the migrating engine which current connected to this replica. This is only
+                  used for live migration of v2 data engine
+                type: string
               nodeID:
                 type: string
               rebuildRetryCount:
@@ -3429,7 +3543,6 @@
                 description: |-
                   the volume that this snapshot belongs to.
                   This field is immutable after creation.
-                  Required
                 type: string
             required:
             - volume
@@ -4155,6 +4268,10 @@
                 - lz4
                 - gzip
                 type: string
+              backupTargetName:
+                description: The backup target name that the volume will be backed
+                  up to or is synced.
+                type: string
               dataEngine:
                 enum:
                 - v1
diff --git a/charts/longhorn/templates/default-resource.yaml b/charts/longhorn/templates/default-resource.yaml
new file mode 100644
index 0000000..2d67201
--- /dev/null
+++ b/charts/longhorn/templates/default-resource.yaml
@@ -0,0 +1,17 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: longhorn-default-resource
+  namespace: {{ include "release_namespace" . }}
+  labels: {{- include "longhorn.labels" . | nindent 4 }}
+data:
+  default-resource.yaml: |-
+    {{- if not (kindIs "invalid" .Values.defaultBackupStore.backupTarget) }}
+    backup-target: {{ .Values.defaultBackupStore.backupTarget }}
+    {{- end }}
+    {{- if not (kindIs "invalid" .Values.defaultBackupStore.backupTargetCredentialSecret) }}
+    backup-target-credential-secret: {{ .Values.defaultBackupStore.backupTargetCredentialSecret }}
+    {{- end }}
+    {{- if not (kindIs "invalid" .Values.defaultBackupStore.pollInterval) }}
+    backupstore-poll-interval: {{ .Values.defaultBackupStore.pollInterval }}
+    {{- end }}
diff --git a/charts/longhorn/templates/default-setting.yaml b/charts/longhorn/templates/default-setting.yaml
index 72463f1..e0419dc 100644
--- a/charts/longhorn/templates/default-setting.yaml
+++ b/charts/longhorn/templates/default-setting.yaml
@@ -6,12 +6,6 @@
   labels: {{- include "longhorn.labels" . | nindent 4 }}
 data:
   default-setting.yaml: |-
-    {{- if not (kindIs "invalid" .Values.defaultSettings.backupTarget) }}
-    backup-target: {{ .Values.defaultSettings.backupTarget }}
-    {{- end }}
-    {{- if not (kindIs "invalid" .Values.defaultSettings.backupTargetCredentialSecret) }}
-    backup-target-credential-secret: {{ .Values.defaultSettings.backupTargetCredentialSecret }}
-    {{- end }}
     {{- if not (kindIs "invalid" .Values.defaultSettings.allowRecurringJobWhileVolumeDetached) }}
     allow-recurring-job-while-volume-detached: {{ .Values.defaultSettings.allowRecurringJobWhileVolumeDetached }}
     {{- end }}
@@ -39,6 +33,9 @@
     {{- if not (kindIs "invalid" .Values.defaultSettings.upgradeChecker) }}
     upgrade-checker: {{ .Values.defaultSettings.upgradeChecker }}
     {{- end }}
+    {{- if not (kindIs "invalid" .Values.defaultSettings.upgradeResponderURL) }}
+    upgrade-responder-url: {{ .Values.defaultSettings.upgradeResponderURL }}
+    {{- end }}
     {{- if not (kindIs "invalid" .Values.defaultSettings.defaultReplicaCount) }}
     default-replica-count: {{ .Values.defaultSettings.defaultReplicaCount }}
     {{- end }}
@@ -48,9 +45,6 @@
     {{- if not (kindIs "invalid" .Values.defaultSettings.defaultLonghornStaticStorageClass) }}
     default-longhorn-static-storage-class: {{ .Values.defaultSettings.defaultLonghornStaticStorageClass }}
     {{- end }}
-    {{- if not (kindIs "invalid" .Values.defaultSettings.backupstorePollInterval) }}
-    backupstore-poll-interval: {{ .Values.defaultSettings.backupstorePollInterval }}
-    {{- end }}
     {{- if not (kindIs "invalid" .Values.defaultSettings.failedBackupTTL) }}
     failed-backup-ttl: {{ .Values.defaultSettings.failedBackupTTL }}
     {{- end }}
@@ -245,3 +239,6 @@
     {{- if not (kindIs "invalid" .Values.defaultSettings.rwxVolumeFastFailover) }}
     rwx-volume-fast-failover: {{ .Values.defaultSettings.rwxVolumeFastFailover}}
     {{- end }}
+    {{- if not (kindIs "invalid" .Values.defaultSettings.v2DataEngineCPUMask) }}
+    v2-data-engine-cpu-mask: {{ .Values.defaultSettings.v2DataEngineCPUMask }}
+    {{- end }}