Skip to content

Commit

Permalink
fix: mongo dump backup failed with incorrect version (#8067)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei authored Sep 3, 2024
1 parent 8e6f092 commit c59de8c
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apis/apps/v1alpha1/backuppolicytemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ type ValueFrom struct {
//
// +optional
ComponentDef []ValueMapping `json:"componentDef,omitempty"`

// Determine the appropriate version of the backup tool image from ServiceVersion.
//
// +optional
ServiceVersion []ValueMapping `json:"serviceVersion,omitempty"`
}

type ValueMapping struct {
Expand Down
24 changes: 24 additions & 0 deletions config/crd/bases/apps.kubeblocks.io_backuppolicytemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,30 @@ spec:
the appropriate version of the backup tool image.
This mapping allows different versions of component images to correspond to specific versions of backup tool images.
items:
type: string
type: array
required:
- mappingValue
- names
type: object
type: array
serviceVersion:
description: Determine the appropriate version
of the backup tool image from ServiceVersion.
items:
properties:
mappingValue:
description: Specifies the appropriate
version of the backup tool image.
type: string
names:
description: |-
Represents an array of names of ClusterVersion or ComponentDefinition that can be mapped to
the appropriate version of the backup tool image.
This mapping allows different versions of component images to correspond to specific versions of backup tool images.
items:
type: string
Expand Down
9 changes: 9 additions & 0 deletions controllers/apps/transformer_cluster_backup_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,15 @@ func (r *clusterBackupPolicyTransformer) doEnvMapping(comp *appsv1alpha1.Cluster
Value: cm.MappingValue,
})
}
for _, sv := range v.ValueFrom.ServiceVersion {
if !slices.Contains(sv.Names, comp.ServiceVersion) {
continue
}
env = append(env, corev1.EnvVar{
Name: v.Key,
Value: sv.MappingValue,
})
}
}
return env
}
Expand Down
24 changes: 24 additions & 0 deletions deploy/helm/crds/apps.kubeblocks.io_backuppolicytemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,30 @@ spec:
the appropriate version of the backup tool image.
This mapping allows different versions of component images to correspond to specific versions of backup tool images.
items:
type: string
type: array
required:
- mappingValue
- names
type: object
type: array
serviceVersion:
description: Determine the appropriate version
of the backup tool image from ServiceVersion.
items:
properties:
mappingValue:
description: Specifies the appropriate
version of the backup tool image.
type: string
names:
description: |-
Represents an array of names of ClusterVersion or ComponentDefinition that can be mapped to
the appropriate version of the backup tool image.
This mapping allows different versions of component images to correspond to specific versions of backup tool images.
items:
type: string
Expand Down
14 changes: 14 additions & 0 deletions docs/developer_docs/api-reference/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -22074,6 +22074,20 @@ use the latest available version in ComponentVersion.</p>
<p>Determine the appropriate version of the backup tool image from ComponentDefinition.</p>
</td>
</tr>
<tr>
<td>
<code>serviceVersion</code><br/>
<em>
<a href="#apps.kubeblocks.io/v1alpha1.ValueMapping">
[]ValueMapping
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Determine the appropriate version of the backup tool image from ServiceVersion.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="apps.kubeblocks.io/v1alpha1.ValueMapping">ValueMapping
Expand Down

0 comments on commit c59de8c

Please sign in to comment.