Skip to content

Commit 82b305d

Browse files
author
Jeff McCormick
committed
fix minor upgrade
1 parent 5f439b6 commit 82b305d

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

operator/cluster/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func AddClusterBase(clientset *kubernetes.Clientset, client *rest.RESTClient, cl
139139
if err != nil {
140140
log.Error("error in status patch " + err.Error())
141141
}
142-
err = util.Patch(client, "/spec/PrimaryStorage/pvcname", pvcName, crv1.PgclusterResourcePlural, cl.Spec.Name, namespace)
142+
err = util.Patch(client, "/spec/PrimaryStorage/name", pvcName, crv1.PgclusterResourcePlural, cl.Spec.Name, namespace)
143143
if err != nil {
144144
log.Error("error in pvcname patch " + err.Error())
145145
}

pgo/cmd/upgrade.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/spf13/cobra"
2525
"github.com/spf13/viper"
2626
"k8s.io/apimachinery/pkg/labels"
27+
"os"
2728

2829
kerrors "k8s.io/apimachinery/pkg/api/errors"
2930
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -406,11 +407,29 @@ func parseMajorVersion(st string) float64 {
406407
//OS = parts[0]
407408
//PGVERSION = parts[1]
408409
//CVERSION = parts[2]
410+
//PG10 makes this a bit harder given its versioning scheme
411+
// is different than PG9 e.g. 10.0 is sort of like 9.6.0
409412

410-
f, err := strconv.ParseFloat(parts[1], 64)
413+
fullversion := parts[1]
414+
fullversionparts := strings.Split(fullversion, ".")
415+
strippedversion := strings.Replace(fullversion, ".", "", -1)
416+
numericVersion, err := strconv.ParseFloat(strippedversion, 64)
411417
if err != nil {
412-
fmt.Println(err.Error())
418+
log.Error(err.Error())
419+
os.Exit(2)
420+
}
421+
422+
first := strings.Split(fullversion, ".")
423+
if first[0] == "10" {
424+
log.Debug("version 10 ")
425+
numericVersion = +numericVersion * 10
426+
} else {
427+
log.Debug("assuming version 9")
428+
numericVersion, err = strconv.ParseFloat(fullversionparts[0]+fullversionparts[1], 64)
413429
}
414-
return f
430+
431+
log.Debugf("parseMajorVersion is %f\n", numericVersion)
432+
433+
return numericVersion
415434

416435
}

0 commit comments

Comments
 (0)