Skip to content

Commit bc4cd90

Browse files
committed
make sure default version is set before validating cluster
1 parent dea05a6 commit bc4cd90

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

pkg/frontend/changefeed.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package frontend
55

66
import (
77
"context"
8+
"net/http"
89
"time"
910

1011
"github.com/Azure/ARO-RP/pkg/api"
@@ -118,6 +119,23 @@ func (f *frontend) updateOcpVersions(docs []*api.OpenShiftVersionDocument) {
118119
}
119120
}
120121

122+
func (f *frontend) waitOcpVersionsInitialized() error {
123+
timeout := time.After(80 * time.Second)
124+
ticker := time.NewTicker(500 * time.Millisecond)
125+
defer ticker.Stop()
126+
127+
for f.lastOcpVersionsChangefeed.Load() == nil {
128+
f.baseLog.Infof("OCP versions not yet initialized, waiting for it...")
129+
select {
130+
case <-ticker.C:
131+
case <-timeout:
132+
f.baseLog.Error("Server do not have initialized OCP version within timeout")
133+
return api.NewCloudError(http.StatusInternalServerError, api.CloudErrorCodeInternalServerError, "properties.clusterProfile.version", "No OpenShift version list defined on server side.")
134+
}
135+
}
136+
return nil
137+
}
138+
121139
func (f *frontend) updateFromIteratorRoleSets(ctx context.Context, ticker *time.Ticker, frontendIterator cosmosdb.PlatformWorkloadIdentityRoleSetDocumentIterator) {
122140
for {
123141
successful := true

pkg/frontend/openshiftcluster_putorpatch.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
256256
if err != nil {
257257
return nil, err
258258
}
259+
ext = putOrPatchClusterParameters.converter.ToExternal(doc.OpenShiftCluster)
259260

260261
err = f.ValidateNewCluster(ctx, subscription, doc.OpenShiftCluster, putOrPatchClusterParameters.staticValidator, ext, putOrPatchClusterParameters.path)
261262
if err != nil {

pkg/frontend/validate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ func validateAdminMasterVMSize(vmSize string) error {
231231
// validateInstallVersion validates the install version set in the clusterprofile.version
232232
// TODO convert this into static validation instead of this receiver function in the validation for frontend.
233233
func (f *frontend) validateInstallVersion(ctx context.Context, oc *api.OpenShiftCluster) error {
234+
if err := f.waitOcpVersionsInitialized(); err != nil {
235+
return err
236+
}
234237
f.ocpVersionsMu.RLock()
235238
defer f.ocpVersionsMu.RUnlock()
236239

0 commit comments

Comments
 (0)