Skip to content

Commit

Permalink
refact(upgrade): add support for 1.8.0 upgrades (openebs-archive#1624)
Browse files Browse the repository at this point in the history
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
  • Loading branch information
shubham14bajpai authored Mar 3, 2020
1 parent 32f19b5 commit f254609
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/openebs.io/v1alpha1/versionDetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
var (
validCurrentVersions = map[string]bool{
"1.0.0": true, "1.1.0": true, "1.2.0": true, "1.3.0": true,
"1.4.0": true, "1.5.0": true, "1.6.0": true,
"1.4.0": true, "1.5.0": true, "1.6.0": true, "1.7.0": true,
}
validDesiredVersion = version.GetVersion()
)
Expand Down
19 changes: 19 additions & 0 deletions pkg/upgrade/templates/v1/cstor_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ limitations under the License.
package templates

var (
// CSPPatch is used for patching cstor pool
CSPPatch = `{
"metadata": {
"labels": {
"openebs.io/version": "{{.UpgradeVersion}}"
}
},{{if lt .CurrentVersion "1.8.0"}}
"spec": {
"poolSpec": {
"roThresholdLimit": 85
}
},{{end}}
"versionDetails": {
"desired": "{{.UpgradeVersion}}",
"status": {
"state": "ReconcilePending"
}
}
}`
// CSPDeployPatch is used for patching cstor pool deployment
CSPDeployPatch = `{
"metadata": {
Expand Down
12 changes: 10 additions & 2 deletions pkg/upgrade/upgrader/csp_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ type cspDeployPatchDetails struct {
BaseDir, PoolMgmtImage, MExporterImage, SPCName string
}

type cspPatchDetails struct {
CurrentVersion, UpgradeVersion string
}

func getCSPDeployPatchDetails(
d *appsv1.Deployment,
) (*cspDeployPatchDetails, error) {
Expand Down Expand Up @@ -118,14 +122,18 @@ func getCSPDeployment(cspName, openebsNamespace string) (*appsv1.Deployment, err
}

func patchCSP(cspObj *apis.CStorPool) error {
patchDetails := cspPatchDetails{
CurrentVersion: currentVersion,
UpgradeVersion: upgradeVersion,
}
cspVersion := cspObj.Labels["openebs.io/version"]
if cspVersion == currentVersion {
tmpl, err := template.New("cspPatch").
Parse(templates.VersionDetailsPatch)
Parse(templates.CSPPatch)
if err != nil {
return errors.Wrapf(err, "failed to create template for csp patch")
}
err = tmpl.Execute(&buffer, upgradeVersion)
err = tmpl.Execute(&buffer, patchDetails)
if err != nil {
return errors.Wrapf(err, "failed to populate template for csp patch")
}
Expand Down

0 comments on commit f254609

Please sign in to comment.