|
7 | 7 | "strings" |
8 | 8 | "time" |
9 | 9 |
|
| 10 | + "github.com/pkg/errors" |
| 11 | + |
10 | 12 | api "github.com/percona/percona-xtradb-cluster-operator/pkg/apis/pxc/v1" |
11 | 13 | vsc "github.com/percona/percona-xtradb-cluster-operator/pkg/version/client" |
12 | 14 | "github.com/percona/percona-xtradb-cluster-operator/pkg/version/client/models" |
@@ -66,51 +68,47 @@ func (vs VersionServiceClient) GetExactVersion(cr *api.PerconaXtraDBCluster, end |
66 | 68 |
|
67 | 69 | pxcVersion, err := getVersion(resp.Payload.Versions[0].Matrix.Pxc) |
68 | 70 | if err != nil { |
69 | | - return DepVersion{}, err |
| 71 | + return DepVersion{}, errors.Wrapf(err, "get pxc version") |
70 | 72 | } |
71 | 73 |
|
72 | 74 | backupVersion, err := getVersion(resp.Payload.Versions[0].Matrix.Backup) |
73 | 75 | if err != nil { |
74 | | - return DepVersion{}, err |
| 76 | + return DepVersion{}, errors.Wrapf(err, "get backup version") |
75 | 77 | } |
76 | 78 |
|
77 | 79 | pmmVersion, err := getPMMVersion(resp.Payload.Versions[0].Matrix.Pmm, opts.PMM3Enabled) |
78 | 80 | if err != nil { |
79 | | - return DepVersion{}, err |
| 81 | + return DepVersion{}, errors.Wrapf(err, "get pmm version") |
80 | 82 | } |
81 | 83 |
|
82 | 84 | proxySqlVersion, err := getVersion(resp.Payload.Versions[0].Matrix.Proxysql) |
83 | 85 | if err != nil { |
84 | | - return DepVersion{}, err |
| 86 | + return DepVersion{}, errors.Wrapf(err, "get proxysql version") |
85 | 87 | } |
86 | 88 |
|
87 | 89 | haproxyVersion, err := getVersion(resp.Payload.Versions[0].Matrix.Haproxy) |
88 | 90 | if err != nil { |
89 | | - return DepVersion{}, err |
| 91 | + return DepVersion{}, errors.Wrap(err, "haproxy version") |
90 | 92 | } |
91 | 93 |
|
92 | | - dv := DepVersion{ |
93 | | - PXCImage: resp.Payload.Versions[0].Matrix.Pxc[pxcVersion].ImagePath, |
94 | | - PXCVersion: pxcVersion, |
95 | | - BackupImage: resp.Payload.Versions[0].Matrix.Backup[backupVersion].ImagePath, |
96 | | - BackupVersion: backupVersion, |
97 | | - ProxySqlImage: resp.Payload.Versions[0].Matrix.Proxysql[proxySqlVersion].ImagePath, |
98 | | - ProxySqlVersion: proxySqlVersion, |
99 | | - PMMImage: resp.Payload.Versions[0].Matrix.Pmm[pmmVersion].ImagePath, |
100 | | - PMMVersion: pmmVersion, |
101 | | - HAProxyImage: resp.Payload.Versions[0].Matrix.Haproxy[haproxyVersion].ImagePath, |
102 | | - HAProxyVersion: haproxyVersion, |
103 | | - } |
104 | | - |
105 | | - if cr.CompareVersionWith("1.7.0") >= 0 { |
106 | | - logCollectorVersion, err := getVersion(resp.Payload.Versions[0].Matrix.LogCollector) |
107 | | - if err != nil { |
108 | | - return DepVersion{}, err |
109 | | - } |
110 | | - |
111 | | - dv.LogCollectorVersion = logCollectorVersion |
112 | | - dv.LogCollectorImage = resp.Payload.Versions[0].Matrix.LogCollector[logCollectorVersion].ImagePath |
| 94 | + logCollectorVersion, err := getVersion(resp.Payload.Versions[0].Matrix.LogCollector) |
| 95 | + if err != nil { |
| 96 | + return DepVersion{}, errors.Wrap(err, "get logcollector version") |
| 97 | + } |
113 | 98 |
|
| 99 | + dv := DepVersion{ |
| 100 | + PXCImage: resp.Payload.Versions[0].Matrix.Pxc[pxcVersion].ImagePath, |
| 101 | + PXCVersion: pxcVersion, |
| 102 | + BackupImage: resp.Payload.Versions[0].Matrix.Backup[backupVersion].ImagePath, |
| 103 | + BackupVersion: backupVersion, |
| 104 | + ProxySqlImage: resp.Payload.Versions[0].Matrix.Proxysql[proxySqlVersion].ImagePath, |
| 105 | + ProxySqlVersion: proxySqlVersion, |
| 106 | + PMMImage: resp.Payload.Versions[0].Matrix.Pmm[pmmVersion].ImagePath, |
| 107 | + PMMVersion: pmmVersion, |
| 108 | + HAProxyImage: resp.Payload.Versions[0].Matrix.Haproxy[haproxyVersion].ImagePath, |
| 109 | + HAProxyVersion: haproxyVersion, |
| 110 | + LogCollectorVersion: logCollectorVersion, |
| 111 | + LogCollectorImage: resp.Payload.Versions[0].Matrix.LogCollector[logCollectorVersion].ImagePath, |
114 | 112 | } |
115 | 113 |
|
116 | 114 | return dv, nil |
@@ -150,7 +148,7 @@ func getPMMVersion(versions map[string]models.VersionVersion, isPMM3 bool) (stri |
150 | 148 |
|
151 | 149 | func getVersion(versions map[string]models.VersionVersion) (string, error) { |
152 | 150 | if len(versions) != 1 { |
153 | | - return "", fmt.Errorf("response has multiple or zero versions") |
| 151 | + return "", fmt.Errorf("response has multiple or zero versions %v", versions) |
154 | 152 | } |
155 | 153 |
|
156 | 154 | for k := range versions { |
|
0 commit comments