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

KEP-29: Handle changed dependencies when upgrading operators #1558

Merged
merged 8 commits into from Jun 23, 2020

Conversation

nfnt
Copy link
Member

@nfnt nfnt commented Jun 11, 2020

What this PR does / why we need it:
When upgrading operators with dependencies, its dependencies could have changed. In this case the Operator and OperatorVersion resources of the new dependencies are installed. Outdated OperatorVersion resources aren't removed.

The code was refactored to decouple dependency handling from package installation and have separate packages to install and upgrade KUDO resources.
Refactorings:

  • Extract dependency resolver from kudoctl/packages/install to kudoctl/resources/dependencies
  • Extract resource install functions from kudoctl/packages/install to kudoctl/resources/install
  • Extract resource upgrade functions from kudoctl/util/kudo to kudoctl/resources/upgrade

Fixes #1514

@nfnt nfnt marked this pull request as ready for review June 11, 2020 08:46
@nfnt nfnt changed the title KEP-29: Handle changed dependencies when upgrade operators KEP-29: Handle changed dependencies when upgrading operators Jun 11, 2020
// Dependencies are resolved recursively.
// Cyclic dependencies are detected and result in an error.
func gatherDependencies(root packages.Resources, resolver pkgresolver.Resolver) ([]packages.Resources, error) {
func Resolve(root packages.Resources, resolver pkgresolver.Resolver) ([]packages.Resources, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this renaming. So far Resolve methods in KUDOs codebase were implementations of the Resolver interface. But then again the name sort of fits 🤔

@@ -68,25 +70,27 @@ func Package(
dependency.Operator.SetNamespace(namespace)
dependency.OperatorVersion.SetNamespace(namespace)

if err := installOperatorAndOperatorVersion(client, dependency); err != nil {
if err := install.OperatorAndOperatorVersion(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you coding in 80 characters wide terminal? ^.^

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

120 chars. But having long single lines decreases readability, because one may need to scroll and then loses context of the surrounding lines.

pkg/kudoctl/resources/upgrade/operatorversion.go Outdated Show resolved Hide resolved
@nfnt nfnt requested a review from zen-dog June 16, 2020 11:22
@nfnt nfnt changed the base branch from master to main June 22, 2020 10:04
Jan Schlicht added 2 commits June 22, 2020 12:31
When upgrading operators with dependencies, its dependencies could have changed. In this case the Operator and OperatorVersion resources of the new dependencies are installed. Outdated OperatorVersion resources aren't removed.

The code was refactored to decouple dependency handling from package installation and have separate packages to install and upgrade KUDO resources.

Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits and let's clarify the installation of the dependencies with regard to the operator name. Otherwise, this looks solid.

pkg/controller/instance/instance_controller.go Outdated Show resolved Hide resolved
pkg/kudoctl/resources/upgrade/operatorversion.go Outdated Show resolved Hide resolved
pkg/kudoctl/resources/upgrade/operatorversion.go Outdated Show resolved Hide resolved
test/integration/upgrade-with-dependencies/00-install.yaml Outdated Show resolved Hide resolved
Signed-off-by: Jan Schlicht <jan@d2iq.com>
@nfnt nfnt requested a review from zen-dog June 22, 2020 13:38
zen-dog and others added 3 commits June 22, 2020 20:54
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Operator installation has been refactored to include dependency handling. Hence, upgrades are delegating dependency handling to O/OV installation.

Signed-off-by: Jan Schlicht <jan@d2iq.com>
}

if !funk.ContainsString(versionsInstalled, operatorVersion.Spec.Version) {
if err := installDependencies(client, operatorVersion, resolver); err != nil {
Copy link
Member Author

@nfnt nfnt Jun 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependencies are now handled directly in install.OperatorAndOperatorVersion. This function is called when installing packages (install.Package) as well as upgrading OVs (upgrade.OperatorVersion).

Signed-off-by: Jan Schlicht <jan@d2iq.com>
@nfnt nfnt requested a review from zen-dog June 23, 2020 10:23
Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 👏

@nfnt nfnt merged commit 1a707c4 into main Jun 23, 2020
@nfnt nfnt deleted the nfnt/deps-upgrade branch June 23, 2020 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[KEP-29]: kudoctl handling operators with dependencies
2 participants