Skip to content

Commit 76b5acb

Browse files
committed
WIP
1 parent 60469af commit 76b5acb

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

pkg/cvo/availableupdates.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,31 @@ import (
2020
"github.com/openshift/cluster-version-operator/pkg/cincinnati"
2121
)
2222

23+
// AvailableUpdatesRequest is a request for available updates for a given cluster.
24+
type AvailableUpdatesRequest {
25+
// ClusterID uniquely identifies this cluster.
26+
ClusterID ClusterID
27+
28+
// Upstream is the Cincinnati service URI.
29+
Upstream configv1.URL
30+
31+
// Version is the current release image version.
32+
Version string
33+
34+
// Channel is the subscribed release channel.
35+
Channel string
36+
37+
// Architecture is the cluster's current architecture.
38+
Architecture string
39+
}
40+
41+
// AvailableUpdatesResponse is a response listing available updates.
42+
type AvailableUpdatesResponse struct {
43+
// Request is the request ...
44+
Request AvailableUpdatesRequest
45+
46+
}
47+
2348
// availableUpdatesSync is triggered on cluster version change (and periodic requeues) to
2449
// sync available updates. It only modifies cluster version.
2550
func (optr *Operator) availableUpdatesSync(key string) error {

pkg/cvo/cvo.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,13 @@ type Operator struct {
120120

121121
// queue tracks applying updates to a cluster.
122122
queue workqueue.RateLimitingInterface
123-
// availableUpdatesQueue tracks checking for updates from the update server.
124-
availableUpdatesQueue workqueue.RateLimitingInterface
125123
// upgradeableQueue tracks checking for upgradeable.
126124
upgradeableQueue workqueue.RateLimitingInterface
127125

126+
// availableUpdatesTrigger allows the...Queue tracks checking for updates from the update server.
127+
availableUpdatesTrigger <-chan string
128+
129+
128130
// statusLock guards access to modifying available updates
129131
statusLock sync.Mutex
130132
availableUpdates *availableUpdates
@@ -314,8 +316,8 @@ func loadConfigMapVerifierDataFromUpdate(update *payload.Update, clientBuilder v
314316
return nil, nil, nil
315317
}
316318

317-
// Run runs the cluster version operator until stopCh is completed. Workers is ignored for now.
318-
func (optr *Operator) Run(ctx context.Context, workers int) {
319+
// Run runs the cluster version operator until the context completes.
320+
func (optr *Operator) Run(ctx context.Context, availableUpdatesTrigger <-chan struct{}, availableUpdatesStatus chan-> configv1.ClusterVersionStatus) {
319321
defer utilruntime.HandleCrash()
320322
defer optr.queue.ShutDown()
321323
stopCh := ctx.Done()

pkg/start/start.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"k8s.io/client-go/util/flowcontrol"
2828
"k8s.io/klog"
2929

30+
configv1 "github.com/openshift/api/config/v1"
3031
clientset "github.com/openshift/client-go/config/clientset/versioned"
3132
externalversions "github.com/openshift/client-go/config/informers/externalversions"
3233
"github.com/openshift/cluster-version-operator/pkg/autoupdate"
@@ -178,12 +179,13 @@ func (o *Options) run(ctx context.Context, controllerCtx *Context, lock *resourc
178179
OnStartedLeading: func(localCtx context.Context) {
179180

180181
availableUpdatesTrigger := make(chan struct{}, 1)
182+
availableUpdatesStatus := make(chan configv1.ClusterVersionStatus, 1)
181183
errorChannelCount++
182184
go func() {
183-
errorChannel <- cvo.RunAvailableUpdates(runContext, shutdownContext, availableUpdatesTrigger)
185+
errorChannel <- cvo.RunAvailableUpdates(runContext, shutdownContext, availableUpdatesTrigger, availableUpdatesStatus)
184186
}()
185187

186-
controllerCtx.Start(runContext, availableUpdatesTrigger)
188+
controllerCtx.Start(runContext, availableUpdatesTrigger, availableUpdatesStatus)
187189
select {
188190
case <-runContext.Done():
189191
// WARNING: this is not completely safe until we have Kube 1.14 and ReleaseOnCancel
@@ -401,10 +403,10 @@ func (o *Options) NewControllerContext(cb *ClientBuilder) *Context {
401403

402404
// Start launches the controllers in the provided context and any supporting
403405
// infrastructure. When ch is closed the controllers will be shut down.
404-
func (c *Context) Start(ctx context.Context, availableUpdatesTrigger <-chan struct{}, availableUpdatesStatus ->..) {
406+
func (c *Context) Start(ctx context.Context, availableUpdatesTrigger <-chan struct{}, availableUpdatesStatus chan-> configv1.ClusterVersionStatus) {
405407
ch := ctx.Done()
406408

407-
go c.CVO.Run(ctx, 2)
409+
go c.CVO.Run(ctx, availableUpdatesTrigger, availableUpdatesStatus)
408410
if c.AutoUpdate != nil {
409411
go c.AutoUpdate.Run(2, ch)
410412
}

0 commit comments

Comments
 (0)