Skip to content

Commit 603964e

Browse files
committed
cincinnati: add arch parameter to requests
OpenShift is going to be gaining support for architectures other than AMD64 soon. In order to make sure that the updates provided to a cluster are compatible with the underlying architecture(s), we are adding an "arch" parameter to the Cincinnati upstream queries. This new parameter will contain a set of architectures, separated by commas, that need to be supported by a release image in order for it to be applied to the cluster. In a homogeneous deployment, the set of architectures will only contain a single architecture (this is what this patch implements). Eventually, once heterogeneous deployments are supported, the set may contain multiple architectures. The details of heterogeneous deployments and their constraints haven't been fully fleshed out, so this scheme may change over time.
1 parent b57ee63 commit 603964e

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

pkg/cincinnati/cincinnati.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ type Update node
4141
// finding all of the children. These children are the available updates for
4242
// the current version and their payloads indicate from where the actual update
4343
// image can be downloaded.
44-
func (c Client) GetUpdates(upstream string, channel string, version semver.Version) ([]Update, error) {
44+
func (c Client) GetUpdates(upstream string, arch string, channel string, version semver.Version) ([]Update, error) {
4545
transport := http.Transport{}
4646
// Prepare parametrized cincinnati query.
4747
cincinnatiURL, err := url.Parse(upstream)
4848
if err != nil {
4949
return nil, fmt.Errorf("failed to parse upstream URL: %s", err)
5050
}
5151
queryParams := cincinnatiURL.Query()
52+
queryParams.Add("arch", arch)
5253
queryParams.Add("channel", channel)
5354
queryParams.Add("id", c.id.String())
5455
queryParams.Add("version", version.String())

pkg/cincinnati/cincinnati_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
func TestGetUpdates(t *testing.T) {
1919
clientID := uuid.Must(uuid.Parse("01234567-0123-0123-0123-0123456789ab"))
20+
arch := "test-arch"
2021
channelName := "test-channel"
2122
tests := []struct {
2223
name string
@@ -28,26 +29,26 @@ func TestGetUpdates(t *testing.T) {
2829
}{{
2930
name: "one update available",
3031
version: "4.0.0-4",
31-
expectedQuery: "channel=test-channel&id=01234567-0123-0123-0123-0123456789ab&version=4.0.0-4",
32+
expectedQuery: "arch=test-arch&channel=test-channel&id=01234567-0123-0123-0123-0123456789ab&version=4.0.0-4",
3233
available: []Update{
3334
{semver.MustParse("4.0.0-5"), "quay.io/openshift-release-dev/ocp-release:4.0.0-5"},
3435
},
3536
}, {
3637
name: "two updates available",
3738
version: "4.0.0-5",
38-
expectedQuery: "channel=test-channel&id=01234567-0123-0123-0123-0123456789ab&version=4.0.0-5",
39+
expectedQuery: "arch=test-arch&channel=test-channel&id=01234567-0123-0123-0123-0123456789ab&version=4.0.0-5",
3940
available: []Update{
4041
{semver.MustParse("4.0.0-6"), "quay.io/openshift-release-dev/ocp-release:4.0.0-6"},
4142
{semver.MustParse("4.0.0-6+2"), "quay.io/openshift-release-dev/ocp-release:4.0.0-6+2"},
4243
},
4344
}, {
4445
name: "no updates available",
4546
version: "4.0.0-0.okd-0",
46-
expectedQuery: "channel=test-channel&id=01234567-0123-0123-0123-0123456789ab&version=4.0.0-0.okd-0",
47+
expectedQuery: "arch=test-arch&channel=test-channel&id=01234567-0123-0123-0123-0123456789ab&version=4.0.0-0.okd-0",
4748
}, {
4849
name: "unknown version",
4950
version: "4.0.0-3",
50-
expectedQuery: "channel=test-channel&id=01234567-0123-0123-0123-0123456789ab&version=4.0.0-3",
51+
expectedQuery: "arch=test-arch&channel=test-channel&id=01234567-0123-0123-0123-0123456789ab&version=4.0.0-3",
5152
err: "currently installed version 4.0.0-3 not found in the \"test-channel\" channel",
5253
}}
5354
for _, test := range tests {
@@ -126,7 +127,7 @@ func TestGetUpdates(t *testing.T) {
126127

127128
c := NewClient(clientID, proxyURL, tlsConfig)
128129

129-
updates, err := c.GetUpdates(ts.URL, channelName, semver.MustParse(test.version))
130+
updates, err := c.GetUpdates(ts.URL, arch, channelName, semver.MustParse(test.version))
130131
if test.err == "" {
131132
if err != nil {
132133
t.Fatalf("expected nil error, got: %v", err)

pkg/cvo/availableupdates.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/x509"
66
"fmt"
77
"net/url"
8+
"runtime"
89
"time"
910

1011
"github.com/blang/semver"
@@ -30,6 +31,7 @@ func (optr *Operator) syncAvailableUpdates(config *configv1.ClusterVersion) erro
3031
usedDefaultUpstream = true
3132
upstream = optr.defaultUpstreamServer
3233
}
34+
arch := runtime.GOARCH
3335
channel := config.Spec.Channel
3436

3537
// updates are only checked at most once per minimumUpdateCheckInterval or if the generation changes
@@ -50,7 +52,7 @@ func (optr *Operator) syncAvailableUpdates(config *configv1.ClusterVersion) erro
5052
}
5153
}
5254

53-
updates, condition := calculateAvailableUpdatesStatus(string(config.Spec.ClusterID), proxyURL, tlsConfig, upstream, channel, optr.releaseVersion)
55+
updates, condition := calculateAvailableUpdatesStatus(string(config.Spec.ClusterID), proxyURL, tlsConfig, upstream, arch, channel, optr.releaseVersion)
5456

5557
if usedDefaultUpstream {
5658
upstream = ""
@@ -117,14 +119,21 @@ func (optr *Operator) getAvailableUpdates() *availableUpdates {
117119
return optr.availableUpdates
118120
}
119121

120-
func calculateAvailableUpdatesStatus(clusterID string, proxyURL *url.URL, tlsConfig *tls.Config, upstream, channel, version string) ([]configv1.Update, configv1.ClusterOperatorStatusCondition) {
122+
func calculateAvailableUpdatesStatus(clusterID string, proxyURL *url.URL, tlsConfig *tls.Config, upstream, arch, channel, version string) ([]configv1.Update, configv1.ClusterOperatorStatusCondition) {
121123
if len(upstream) == 0 {
122124
return nil, configv1.ClusterOperatorStatusCondition{
123125
Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse, Reason: "NoUpstream",
124126
Message: "No upstream server has been set to retrieve updates.",
125127
}
126128
}
127129

130+
if len(arch) == 0 {
131+
return nil, configv1.ClusterOperatorStatusCondition{
132+
Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse, Reason: "NoArchitecture",
133+
Message: "The set of architectures has not been configured.",
134+
}
135+
}
136+
128137
if len(version) == 0 {
129138
return nil, configv1.ClusterOperatorStatusCondition{
130139
Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse, Reason: "NoCurrentVersion",
@@ -148,7 +157,7 @@ func calculateAvailableUpdatesStatus(clusterID string, proxyURL *url.URL, tlsCon
148157
}
149158
}
150159

151-
updates, err := checkForUpdate(clusterID, proxyURL, tlsConfig, upstream, channel, currentVersion)
160+
updates, err := checkForUpdate(clusterID, proxyURL, tlsConfig, upstream, arch, channel, currentVersion)
152161
if err != nil {
153162
klog.V(2).Infof("Upstream server %s could not return available updates: %v", upstream, err)
154163
return nil, configv1.ClusterOperatorStatusCondition{
@@ -173,7 +182,7 @@ func calculateAvailableUpdatesStatus(clusterID string, proxyURL *url.URL, tlsCon
173182
}
174183
}
175184

176-
func checkForUpdate(clusterID string, proxyURL *url.URL, tlsConfig *tls.Config, upstream, channel string, currentVersion semver.Version) ([]cincinnati.Update, error) {
185+
func checkForUpdate(clusterID string, proxyURL *url.URL, tlsConfig *tls.Config, upstream, arch, channel string, currentVersion semver.Version) ([]cincinnati.Update, error) {
177186
uuid, err := uuid.Parse(string(clusterID))
178187
if err != nil {
179188
return nil, err
@@ -182,7 +191,7 @@ func checkForUpdate(clusterID string, proxyURL *url.URL, tlsConfig *tls.Config,
182191
if len(upstream) == 0 {
183192
return nil, fmt.Errorf("no upstream URL set for cluster version")
184193
}
185-
return cincinnati.NewClient(uuid, proxyURL, tlsConfig).GetUpdates(upstream, channel, currentVersion)
194+
return cincinnati.NewClient(uuid, proxyURL, tlsConfig).GetUpdates(upstream, arch, channel, currentVersion)
186195
}
187196

188197
// getHTTPSProxyURL returns a url.URL object for the configured

pkg/start/start_integration_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"reflect"
1515
"regexp"
1616
"strings"
17+
"runtime"
1718
"testing"
1819
"time"
1920

@@ -692,7 +693,7 @@ metadata:
692693
t.Logf("latest version:\n%s", printCV(lastCV))
693694
t.Fatal("no request received at upstream URL")
694695
}
695-
expectedQuery := fmt.Sprintf("channel=test-channel&id=%s&version=0.0.1", id.String())
696+
expectedQuery := fmt.Sprintf("arch=%s&channel=test-channel&id=%s&version=0.0.1", runtime.GOARCH, id.String())
696697
expectedQueryValues, err := url.ParseQuery(expectedQuery)
697698
if err != nil {
698699
t.Fatalf("could not parse expected query: %v", err)

0 commit comments

Comments
 (0)