openshift / oadp-operator

OADP Operator
Apache License 2.0
78 stars 72 forks source link

Create `operator-sdk` update guidelines #1540

Open mateusoliveira43 opened 1 month ago

mateusoliveira43 commented 1 month ago

Problem

Currently, we do not have any strategy to update operator-sdk version used by the project. Last time we updated it, for example, was to fix problem fixed in newer releases. Reference https://github.com/openshift/oadp-operator/pull/1398

But we only updated the executable version, without any updates to project structure, which can cause operator-sdk commands and functionalities not work properly.

Currently, some of operator-sdk functionalities are broken in the project.

Example

These lines are wrong, pointing to an object that does not exist (buckets.oadp.openshift.io) https://github.com/openshift/oadp-operator/blob/5b0b9fcbc0d86c09158f9a6bcf9ec47fd61ae50e/controllers/bucket_controller.go#L44-L47

If we update it and run make bundle, config/rbac/role.yaml is not updated.

https://github.com/openshift/oadp-operator/blob/5b0b9fcbc0d86c09158f9a6bcf9ec47fd61ae50e/config/rbac/role.yaml#L51

operator-sdk uses kubebuilder under the hood

Solution

As proposed previously in https://github.com/openshift/oadp-operator/pull/1250 and already being applied in NAC project (references https://github.com/migtools/oadp-non-admin/blob/master/docs/CONTRIBUTING.md#upgrade-kubebuilder-version https://github.com/migtools/oadp-non-admin/blob/master/docs/architecture.md#kubebuilde), we should update all necessary places when updating operator-sdk version.

To avoid human mistakes of forgetting to apply a change describe in operator-sdk documentation, we should do this update following these instructions:

Download both current and new version of operator-sdk from https://github.com/operator-framework/operator-sdk/releases and run

mkdir current
mkdir new
cd current
# Run operator-sdk commands pointing to operator-sdk executable with the current version
cd ..
cd new
# Run operator-sdk commands pointing to operator-sdk executable with the new version
cd ..
diff -ruN current new > operator-sdk-upgrade.diff
patch -p1 --verbose -d ./ -i operator-sdk-upgrade.diff
# Resolve possible conflicts

Because last step can fail, needing human intervention, do not know if it is necessary to create a script

Pros

Cons

kaovilai commented 1 month ago

diff -ruN current new > operator-sdk-upgrade.diff patch -p1 --verbose -d ./ -i operator-sdk-upgrade.diff

This is a blind patch albeit still better than before.

The full steps for each new operator-sdk upgrade is already outlined in docs at https://sdk.operatorframework.io/docs/upgrading-sdk-version/

The intent by operator-sdk authors per my understanding is for you to follow every step there.

For example, when upgrading to https://sdk.operatorframework.io/docs/upgrading-sdk-version/v1.34.0/ you are expected to make changes to your makefile.