Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run the upgrade of a collector instance after the status changes from unmanaged to managed #2086

Merged
merged 18 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
component: operator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Run the upgrade mechanism when there is a change in an instance to ensure it is upgraded. This is useful for cases where the instance uses the unmanaged state, the operator is upgraded and the instance changes to use a managed state."

# One or more tracking issues related to the change
issues: [1890]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
14 changes: 13 additions & 1 deletion pkg/collector/reconcile/opentelemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
"github.com/open-telemetry/opentelemetry-operator/internal/version"
collectorupgrade "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade"
)

// Self updates this instance's self data. This should be the last item in the reconciliation, as it causes changes
Expand All @@ -38,6 +39,17 @@ import (
func Self(ctx context.Context, params manifests.Params) error {
changed := params.Instance

up := &collectorupgrade.VersionUpgrade{
Log: params.Log,
Version: version.Get(),
Client: params.Client,
Recorder: params.Recorder,
}
changed, err := up.ManagedInstance(ctx, changed)
if err != nil {
return fmt.Errorf("failed to upgrade the OpenTelemetry CR: %w", err)
}
iblancasa marked this conversation as resolved.
Show resolved Hide resolved

// this field is only changed for new instances: on existing instances this
// field is reconciled when the operator is first started, i.e. during
// the upgrade mechanism
Expand All @@ -46,7 +58,7 @@ func Self(ctx context.Context, params manifests.Params) error {
changed.Status.Version = version.OpenTelemetryCollector()
}

if err := updateScaleSubResourceStatus(ctx, params.Client, &changed); err != nil {
if err = updateScaleSubResourceStatus(ctx, params.Client, &changed); err != nil {
return fmt.Errorf("failed to update the scale subresource status for the OpenTelemetry CR: %w", err)
}

Expand Down
Loading