Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ var (
renderOpts struct {
releaseImage string
outputDir string
telemetryID string
}
)

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) {
Expand All @@ -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)
}
}
1 change: 1 addition & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion docs/dev/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ spec:
args:
- "start"
- "--release-image={{.ReleaseImage}}"
- "--telemetry-id={{.TelemetryID}}"
- "--enable-auto-update=false"
- "--v=4"
resources:
Expand Down
22 changes: 18 additions & 4 deletions pkg/cvo/cvo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -133,6 +136,7 @@ func New(
nodename string,
namespace, name string,
releaseImage string,
telemetryID string,
overridePayloadDir string,
minimumInterval time.Duration,
cvInformer configinformersv1.ClusterVersionInformer,
Expand All @@ -152,6 +156,7 @@ func New(
namespace: namespace,
name: name,
releaseImage: releaseImage,
telemetryID: telemetryID,

statusInterval: 15 * time.Second,
minimumUpdateCheckInterval: minimumInterval,
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
},
Expand Down Expand Up @@ -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
}

Expand All @@ -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{
Expand All @@ -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),
},
}

Expand Down
42 changes: 21 additions & 21 deletions pkg/cvo/cvo_scenarios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand All @@ -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{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading