diff --git a/cmd/render.go b/cmd/render.go index aedb83f79..d81aeb996 100644 --- a/cmd/render.go +++ b/cmd/render.go @@ -20,6 +20,7 @@ var ( renderOpts struct { releaseImage string outputDir string + telemetryID string } ) @@ -27,6 +28,7 @@ func init() { rootCmd.AddCommand(renderCmd) renderCmd.PersistentFlags().StringVar(&renderOpts.outputDir, "output-dir", "", "The output directory where the manifests will be rendered.") renderCmd.PersistentFlags().StringVar(&renderOpts.releaseImage, "release-image", "", "The Openshift release image url.") + renderCmd.PersistentFlags().StringVar(&renderOpts.telemetryID, "telemetry-id", "", "A telemetry ID which should be used for the default ClusterVersion spec.clusterID.") } func runRenderCmd(cmd *cobra.Command, args []string) { @@ -39,7 +41,7 @@ func runRenderCmd(cmd *cobra.Command, args []string) { if renderOpts.releaseImage == "" { klog.Fatalf("missing --release-image flag, it is required") } - if err := payload.Render(renderOpts.outputDir, renderOpts.releaseImage); err != nil { + if err := payload.Render(renderOpts.outputDir, renderOpts.releaseImage, renderOpts.telemetryID); err != nil { klog.Fatalf("Render command failed: %v", err) } } diff --git a/cmd/start.go b/cmd/start.go index 0227baa89..fd6dfe5b5 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -29,5 +29,6 @@ func init() { cmd.PersistentFlags().StringVar(&opts.NodeName, "node-name", opts.NodeName, "kubernetes node name CVO is scheduled on.") cmd.PersistentFlags().BoolVar(&opts.EnableAutoUpdate, "enable-auto-update", opts.EnableAutoUpdate, "Enables the autoupdate controller.") cmd.PersistentFlags().StringVar(&opts.ReleaseImage, "release-image", opts.ReleaseImage, "The Openshift release image url.") + cmd.PersistentFlags().StringVar(&opts.telemetryID, "telemetry-id", "", "A telemetry ID which should be used for the default ClusterVersion spec.clusterID.") rootCmd.AddCommand(cmd) } diff --git a/docs/dev/metrics.md b/docs/dev/metrics.md index 55931cedf..cd401e958 100644 --- a/docs/dev/metrics.md +++ b/docs/dev/metrics.md @@ -28,7 +28,7 @@ cluster_version{image="test/image:2",type="cluster",version="4.0.3",from_version cluster_version{image="test/image:3",type="updating",version="4.0.4",from_version="4.0.3"} 132000400 # HELP cluster_version_available_updates Report the count of available versions for an upstream and channel. # TYPE cluster_version_available_updates gauge -cluster_version_available_updates{channel="fast",upstream="https://api.openshift.com/api/upgrades_info/v1/graph"} 0 +cluster_version_available_updates{channel="stable-4.2",upstream="https://api.openshift.com/api/upgrades_info/v1/graph"} 0 ``` Metrics about cluster operators: diff --git a/install/0000_00_cluster-version-operator_03_deployment.yaml b/install/0000_00_cluster-version-operator_03_deployment.yaml index c286dadc8..88a041420 100644 --- a/install/0000_00_cluster-version-operator_03_deployment.yaml +++ b/install/0000_00_cluster-version-operator_03_deployment.yaml @@ -22,6 +22,7 @@ spec: args: - "start" - "--release-image={{.ReleaseImage}}" + - "--telemetry-id={{.TelemetryID}}" - "--enable-auto-update=false" - "--v=4" resources: diff --git a/pkg/cvo/cvo.go b/pkg/cvo/cvo.go index 9c2c20dc6..7f0591a47 100644 --- a/pkg/cvo/cvo.go +++ b/pkg/cvo/cvo.go @@ -85,6 +85,9 @@ type Operator struct { // releaseCreated, if set, is the timestamp of the current update. releaseCreated time.Time + // telemetryID is the default Telemetry ID. + telemetryID string + client clientset.Interface kubeClient kubernetes.Interface eventRecorder record.EventRecorder @@ -133,6 +136,7 @@ func New( nodename string, namespace, name string, releaseImage string, + telemetryID string, overridePayloadDir string, minimumInterval time.Duration, cvInformer configinformersv1.ClusterVersionInformer, @@ -152,6 +156,7 @@ func New( namespace: namespace, name: name, releaseImage: releaseImage, + telemetryID: telemetryID, statusInterval: 15 * time.Second, minimumUpdateCheckInterval: minimumInterval, @@ -191,7 +196,7 @@ func New( // controller that loads and applies content to the cluster. It returns an error if the payload appears to // be in error rather than continuing. func (optr *Operator) InitializeFromPayload(restConfig *rest.Config, burstRestConfig *rest.Config) error { - update, err := payload.LoadUpdate(optr.defaultPayloadDir(), optr.releaseImage) + update, err := payload.LoadUpdate(optr.defaultPayloadDir(), optr.releaseImage, optr.telemetryID) if err != nil { return fmt.Errorf("the local release contents are invalid - no current version can be determined from disk: %v", err) } @@ -287,6 +292,7 @@ func (optr *Operator) eventHandler() cache.ResourceEventHandler { optr.availableUpdatesQueue.Add(workQueueKey) }, UpdateFunc: func(old, new interface{}) { + // FIXME: check for Telemetry ID changes somewhere under this pathway, which I don't understand optr.queue.Add(workQueueKey) optr.availableUpdatesQueue.Add(workQueueKey) }, @@ -455,6 +461,9 @@ func (optr *Operator) getOrCreateClusterVersion() (*configv1.ClusterVersion, boo if optr.isOlderThanLastUpdate(obj) { return nil, true, nil } + if obj.Spec.ClusterID != nil { + optr.telemetryID = obj.Spec.ClusterID + } return obj, false, nil } @@ -467,7 +476,12 @@ func (optr *Operator) getOrCreateClusterVersion() (*configv1.ClusterVersion, boo u := configv1.URL(optr.defaultUpstreamServer) upstream = u } - id, _ := uuid.NewRandom() + if optr.telemetryID == "" { + optr.telemetryID, err = uuid.NewRandom() + if err != nil { + return nil, false, err + } + } // XXX: generate ClusterVersion from options calculated above. config := &configv1.ClusterVersion{ @@ -476,8 +490,8 @@ func (optr *Operator) getOrCreateClusterVersion() (*configv1.ClusterVersion, boo }, Spec: configv1.ClusterVersionSpec{ Upstream: upstream, - Channel: "fast", - ClusterID: configv1.ClusterID(id.String()), + Channel: "stable-4.2", + ClusterID: configv1.ClusterID(optr.telemetryID), }, } diff --git a/pkg/cvo/cvo_scenarios_test.go b/pkg/cvo/cvo_scenarios_test.go index 3cc8d3c4e..541e0c1f3 100644 --- a/pkg/cvo/cvo_scenarios_test.go +++ b/pkg/cvo/cvo_scenarios_test.go @@ -127,7 +127,7 @@ func TestCVO_StartupAndSync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: actual.Spec.ClusterID, - Channel: "fast", + Channel: "stable-4.2", }, }) verifyAllStatus(t, worker.StatusCh()) @@ -152,7 +152,7 @@ func TestCVO_StartupAndSync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: actual.Spec.ClusterID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -193,7 +193,7 @@ func TestCVO_StartupAndSync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: actual.Spec.ClusterID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ ObservedGeneration: 1, @@ -276,7 +276,7 @@ func TestCVO_StartupAndSync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: actual.Spec.ClusterID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ ObservedGeneration: 1, @@ -398,7 +398,7 @@ func TestCVO_StartupAndSyncUnverifiedPayload(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: actual.Spec.ClusterID, - Channel: "fast", + Channel: "stable-4.2", }, }) verifyAllStatus(t, worker.StatusCh()) @@ -423,7 +423,7 @@ func TestCVO_StartupAndSyncUnverifiedPayload(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: actual.Spec.ClusterID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -464,7 +464,7 @@ func TestCVO_StartupAndSyncUnverifiedPayload(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: actual.Spec.ClusterID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ Desired: desired, @@ -547,7 +547,7 @@ func TestCVO_StartupAndSyncUnverifiedPayload(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: actual.Spec.ClusterID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ ObservedGeneration: 1, @@ -636,7 +636,7 @@ func TestCVO_UpgradeUnverifiedPayload(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: clusterUID, - Channel: "fast", + Channel: "stable-4.2", DesiredUpdate: &desired, }, Status: configv1.ClusterVersionStatus{ @@ -718,7 +718,7 @@ func TestCVO_UpgradeUnverifiedPayload(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: clusterUID, - Channel: "fast", + Channel: "stable-4.2", DesiredUpdate: &desired, }, Status: configv1.ClusterVersionStatus{ @@ -823,7 +823,7 @@ func TestCVO_UpgradeUnverifiedPayload(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: actual.Spec.ClusterID, - Channel: "fast", + Channel: "stable-4.2", DesiredUpdate: &copied, }, Status: configv1.ClusterVersionStatus{ @@ -862,7 +862,7 @@ func TestCVO_UpgradeVerifiedPayload(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: clusterUID, - Channel: "fast", + Channel: "stable-4.2", DesiredUpdate: &desired, }, Status: configv1.ClusterVersionStatus{ @@ -946,7 +946,7 @@ func TestCVO_UpgradeVerifiedPayload(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: clusterUID, - Channel: "fast", + Channel: "stable-4.2", DesiredUpdate: &desired, }, Status: configv1.ClusterVersionStatus{ @@ -1046,7 +1046,7 @@ func TestCVO_UpgradeVerifiedPayload(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: actual.Spec.ClusterID, - Channel: "fast", + Channel: "stable-4.2", DesiredUpdate: &copied, }, Status: configv1.ClusterVersionStatus{ @@ -1089,7 +1089,7 @@ func TestCVO_RestartAndReconcile(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: clusterUID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ // Prefers the image version over the operator's version (although in general they will remain in sync) @@ -1256,7 +1256,7 @@ func TestCVO_ErrorDuringReconcile(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: clusterUID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ // Prefers the image version over the operator's version (although in general they will remain in sync) @@ -1412,7 +1412,7 @@ func TestCVO_ErrorDuringReconcile(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: clusterUID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ // Prefers the image version over the operator's version (although in general they will remain in sync) @@ -1466,7 +1466,7 @@ func TestCVO_ParallelError(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: clusterUID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ // Prefers the image version over the operator's version (although in general they will remain in sync) @@ -1579,7 +1579,7 @@ func TestCVO_ParallelError(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: clusterUID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ // Prefers the image version over the operator's version (although in general they will remain in sync) @@ -1621,7 +1621,7 @@ func TestCVO_VerifyInitializingPayloadState(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: clusterUID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ // Prefers the image version over the operator's version (although in general they will remain in sync) @@ -1679,7 +1679,7 @@ func TestCVO_VerifyUpdatingPayloadState(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: clusterUID, - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ // Prefers the image version over the operator's version (although in general they will remain in sync) diff --git a/pkg/cvo/cvo_test.go b/pkg/cvo/cvo_test.go index 9e422c8b5..16e6661d3 100644 --- a/pkg/cvo/cvo_test.go +++ b/pkg/cvo/cvo_test.go @@ -274,7 +274,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, }) }, @@ -301,7 +301,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -331,7 +331,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -374,7 +374,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -404,7 +404,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -448,7 +448,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -478,7 +478,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -518,7 +518,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -548,7 +548,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ Desired: configv1.Update{Version: "0.0.1-abc", Image: "image/image:v4.0.1"}, @@ -584,7 +584,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, }, ), @@ -601,7 +601,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ Desired: configv1.Update{Image: "image/image:v4.0.1", Version: "4.0.1"}, @@ -638,7 +638,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -665,7 +665,7 @@ func TestOperator_sync(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ Desired: configv1.Update{Image: "image/image:v4.0.1", Version: "4.0.1"}, @@ -702,7 +702,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, }), }, @@ -720,7 +720,7 @@ func TestOperator_sync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -761,7 +761,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -797,7 +797,7 @@ func TestOperator_sync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -851,7 +851,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -894,7 +894,7 @@ func TestOperator_sync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -954,7 +954,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1005,7 +1005,7 @@ func TestOperator_sync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1062,7 +1062,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1101,7 +1101,7 @@ func TestOperator_sync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1157,7 +1157,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1193,7 +1193,7 @@ func TestOperator_sync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1234,7 +1234,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1284,7 +1284,7 @@ func TestOperator_sync(t *testing.T) { name: "default", availableUpdates: &availableUpdates{ Upstream: "http://localhost:8080/graph", - Channel: "fast", + Channel: "stable-4.2", Updates: []configv1.Update{ {Version: "4.0.2", Image: "test/image:1"}, {Version: "4.0.3", Image: "test/image:2"}, @@ -1302,7 +1302,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ ObservedGeneration: 2, @@ -1330,7 +1330,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ AvailableUpdates: []configv1.Update{ @@ -1367,7 +1367,7 @@ func TestOperator_sync(t *testing.T) { defaultUpstreamServer: "http://localhost:8080/graph", availableUpdates: &availableUpdates{ Upstream: "", - Channel: "fast", + Channel: "stable-4.2", Updates: []configv1.Update{ {Version: "4.0.2", Image: "test/image:1"}, {Version: "4.0.3", Image: "test/image:2"}, @@ -1385,7 +1385,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: "", - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ ObservedGeneration: 2, @@ -1413,7 +1413,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: "", - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ AvailableUpdates: []configv1.Update{ @@ -1449,7 +1449,7 @@ func TestOperator_sync(t *testing.T) { name: "default", availableUpdates: &availableUpdates{ Upstream: "http://localhost:8080/graph", - Channel: "fast", + Channel: "stable-4.2", Updates: []configv1.Update{ {Version: "4.0.2", Image: "test/image:1"}, {Version: "4.0.3", Image: "test/image:2"}, @@ -1746,7 +1746,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1806,7 +1806,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1848,7 +1848,7 @@ func TestOperator_sync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ Upstream: configv1.URL("http://localhost:8080/graph"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1893,7 +1893,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: "not-valid-cluster-id", Upstream: configv1.URL("#%GG"), - Channel: "fast", + Channel: "stable-4.2", }, }), }, @@ -1913,7 +1913,7 @@ func TestOperator_sync(t *testing.T) { // The object passed to status has these spec fields cleared // ClusterID: "not-valid-cluster-id", // Upstream: configv1.URL("#%GG"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1952,7 +1952,7 @@ func TestOperator_sync(t *testing.T) { Spec: configv1.ClusterVersionSpec{ ClusterID: "not-valid-cluster-id", Upstream: configv1.URL("#%GG"), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -1991,7 +1991,7 @@ func TestOperator_sync(t *testing.T) { ClusterID: "", Upstream: configv1.URL(""), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -2089,7 +2089,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -2101,7 +2101,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { }, wantUpdates: &availableUpdates{ Upstream: "", - Channel: "fast", + Channel: "stable-4.2", Condition: configv1.ClusterOperatorStatusCondition{ Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse, @@ -2167,7 +2167,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -2179,7 +2179,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { }, wantUpdates: &availableUpdates{ Upstream: "", - Channel: "fast", + Channel: "stable-4.2", Condition: configv1.ClusterOperatorStatusCondition{ Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse, @@ -2206,7 +2206,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -2223,7 +2223,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { }, wantUpdates: &availableUpdates{ Upstream: "", - Channel: "fast", + Channel: "stable-4.2", Condition: configv1.ClusterOperatorStatusCondition{ Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse, @@ -2257,7 +2257,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -2275,7 +2275,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { }, wantUpdates: &availableUpdates{ Upstream: "", - Channel: "fast", + Channel: "stable-4.2", Condition: configv1.ClusterOperatorStatusCondition{ Type: configv1.RetrievedUpdates, Status: configv1.ConditionTrue, @@ -2313,7 +2313,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -2331,7 +2331,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { }, wantUpdates: &availableUpdates{ Upstream: "", - Channel: "fast", + Channel: "stable-4.2", Updates: []configv1.Update{ {Version: "4.0.2-prerelease", Image: "some.other.registry/image/image:v4.0.2"}, {Version: "4.0.2", Image: "image/image:v4.0.2"}, @@ -2352,7 +2352,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { minimumUpdateCheckInterval: 1 * time.Minute, availableUpdates: &availableUpdates{ Upstream: "http://localhost:8080/graph", - Channel: "fast", + Channel: "stable-4.2", At: time.Now(), }, @@ -2368,7 +2368,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) { }, Spec: configv1.ClusterVersionSpec{ ClusterID: configv1.ClusterID(id), - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ diff --git a/pkg/cvo/status_test.go b/pkg/cvo/status_test.go index d8c2e75c2..270b4656e 100644 --- a/pkg/cvo/status_test.go +++ b/pkg/cvo/status_test.go @@ -167,7 +167,7 @@ func TestOperator_syncFailingStatus(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ @@ -202,7 +202,7 @@ func TestOperator_syncFailingStatus(t *testing.T) { Name: "default", }, Spec: configv1.ClusterVersionSpec{ - Channel: "fast", + Channel: "stable-4.2", }, Status: configv1.ClusterVersionStatus{ History: []configv1.UpdateHistory{ diff --git a/pkg/cvo/sync_worker.go b/pkg/cvo/sync_worker.go index b46d7a188..e296a9f28 100644 --- a/pkg/cvo/sync_worker.go +++ b/pkg/cvo/sync_worker.go @@ -477,7 +477,7 @@ func (w *SyncWorker) syncOnce(ctx context.Context, work *SyncWork, maxWorkers in return err } - payloadUpdate, err := payload.LoadUpdate(info.Directory, update.Image) + payloadUpdate, err := payload.LoadUpdate(info.Directory, update.Image, "FIXME: get the Operator.telemetryID somehow?") if err != nil { reporter.Report(SyncWorkerStatus{ Generation: work.Generation, diff --git a/pkg/payload/image.go b/pkg/payload/image.go index f282a9d22..5459f782b 100644 --- a/pkg/payload/image.go +++ b/pkg/payload/image.go @@ -9,7 +9,7 @@ import ( // ImageForShortName returns the image using the updatepayload embedded in // the Operator. func ImageForShortName(name string) (string, error) { - up, err := LoadUpdate(DefaultPayloadDir, "") + up, err := LoadUpdate(DefaultPayloadDir, "", "") if err != nil { return "", errors.Wrapf(err, "error loading release manifests from %q", DefaultPayloadDir) } diff --git a/pkg/payload/payload.go b/pkg/payload/payload.go index 2e978526b..a745b7512 100644 --- a/pkg/payload/payload.go +++ b/pkg/payload/payload.go @@ -90,6 +90,7 @@ const ( type Update struct { ReleaseImage string ReleaseVersion string + TelemetryID string // XXX: cincinatti.json struct VerifiedImage bool @@ -102,8 +103,8 @@ type Update struct { Manifests []lib.Manifest } -func LoadUpdate(dir, releaseImage string) (*Update, error) { - payload, tasks, err := loadUpdatePayloadMetadata(dir, releaseImage) +func LoadUpdate(dir, releaseImage, telemetryID string) (*Update, error) { + payload, tasks, err := loadUpdatePayloadMetadata(dir, releaseImage, telemetryID) if err != nil { return nil, err } @@ -206,7 +207,7 @@ type payloadTasks struct { skipFiles sets.String } -func loadUpdatePayloadMetadata(dir, releaseImage string) (*Update, []payloadTasks, error) { +func loadUpdatePayloadMetadata(dir, releaseImage string, telemetryID string) (*Update, []payloadTasks, error) { klog.V(4).Infof("Loading updatepayload from %q", dir) if err := ValidateDirectory(dir); err != nil { return nil, nil, err @@ -230,7 +231,10 @@ func loadUpdatePayloadMetadata(dir, releaseImage string) (*Update, []payloadTask return nil, nil, errors.Wrapf(err, "invalid image-references data %s", irf) } - mrc := manifestRenderConfig{ReleaseImage: releaseImage} + mrc := manifestRenderConfig{ + ReleaseImage: releaseImage, + TelemetryID: telemetryID, + } tasks := []payloadTasks{{ idir: cvoDir, preprocess: func(ib []byte) ([]byte, error) { return renderManifest(mrc, ib) }, @@ -240,5 +244,10 @@ func loadUpdatePayloadMetadata(dir, releaseImage string) (*Update, []payloadTask preprocess: nil, skipFiles: sets.NewString(cjf, irf), }} - return &Update{ImageRef: imageRef, ReleaseImage: releaseImage, ReleaseVersion: imageRef.Name}, tasks, nil + return &Update{ + ImageRef: imageRef, + ReleaseImage: releaseImage, + ReleaseVersion: imageRef.Name, + TelemetryID: telemetryID, + }, tasks, nil } diff --git a/pkg/payload/payload_test.go b/pkg/payload/payload_test.go index 376d3f158..2307a47be 100644 --- a/pkg/payload/payload_test.go +++ b/pkg/payload/payload_test.go @@ -104,7 +104,7 @@ func Test_loadUpdatePayload(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := LoadUpdate(tt.args.dir, tt.args.releaseImage) + got, err := LoadUpdate(tt.args.dir, tt.args.releaseImage, "") if (err != nil) != tt.wantErr { t.Errorf("loadUpdatePayload() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/pkg/payload/render.go b/pkg/payload/render.go index 54f336264..4a9b9ca53 100644 --- a/pkg/payload/render.go +++ b/pkg/payload/render.go @@ -15,14 +15,17 @@ import ( ) // Render renders all the manifests from /manifests to outputDir. -func Render(outputDir, releaseImage string) error { +func Render(outputDir, releaseImage string, telemetryID string) error { var ( manifestsDir = filepath.Join(DefaultPayloadDir, CVOManifestDir) oManifestsDir = filepath.Join(outputDir, "manifests") bootstrapDir = "/bootstrap" oBootstrapDir = filepath.Join(outputDir, "bootstrap") - renderConfig = manifestRenderConfig{ReleaseImage: releaseImage} + renderConfig = manifestRenderConfig{ + ReleaseImage: releaseImage, + TelemetryID: telemetryID, + } ) tasks := []struct { @@ -103,6 +106,7 @@ func renderDir(renderConfig manifestRenderConfig, idir, odir string, skipFiles s type manifestRenderConfig struct { ReleaseImage string + TelemetryID string } // renderManifest Executes go text template from `manifestBytes` with `config`. diff --git a/pkg/payload/task_graph_test.go b/pkg/payload/task_graph_test.go index f5fc8afba..cd765d9fa 100644 --- a/pkg/payload/task_graph_test.go +++ b/pkg/payload/task_graph_test.go @@ -375,7 +375,7 @@ func Test_TaskGraph_real(t *testing.T) { if len(path) == 0 { t.Skip("TEST_GRAPH_PATH unset") } - p, err := LoadUpdate(path, "arbitrary/image:1") + p, err := LoadUpdate(path, "arbitrary/image:1", "") if err != nil { t.Fatal(err) } diff --git a/pkg/start/start.go b/pkg/start/start.go index 8242ec30c..0ef236ad0 100644 --- a/pkg/start/start.go +++ b/pkg/start/start.go @@ -50,6 +50,7 @@ const ( // Options are the valid inputs to starting the CVO. type Options struct { ReleaseImage string + TelemetryID string Kubeconfig string NodeName string @@ -326,6 +327,7 @@ func (o *Options) NewControllerContext(cb *ClientBuilder) *Context { o.NodeName, o.Namespace, o.Name, o.ReleaseImage, + o.TelemetryID, o.PayloadOverride, resyncPeriod(o.ResyncInterval)(), cvInformer.Config().V1().ClusterVersions(),