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

Upgrade Rancher #19

Merged
merged 1 commit into from
Jul 26, 2024
Merged

Upgrade Rancher #19

merged 1 commit into from
Jul 26, 2024

Conversation

atanasdinov
Copy link
Contributor

@atanasdinov atanasdinov commented Jul 25, 2024

  • Introduces the necessary functionality to upgrade Rancher
  • Upgrade is skipped if the respective HelmChart resource is missing
    • This is what we end up with after installing Rancher (and other Helm charts) via EIB
    • We should further investigate if we support alternative installation methods; not part of this PR
  • Upgrade is performed by modifying the respective HelmChart resource
  • Upgrade is considered successful or failed based on the status of the Job spawned by the Helm controller
    • This is likely not enough since the Job performing helm upgrade exits very fast but it takes time for the actual deployment (and in turn Rancher instance) to report it is ready
    • Due to the above, the done criteria might change in the future but I'd like to use this initial flow and add all other components before diving into the specifics of each one

@atanasdinov atanasdinov force-pushed the rancher-upgrade branch 2 times, most recently from 647841e to 1d8b9a6 Compare July 25, 2024 08:20
Signed-off-by: Atanas Dinov <[email protected]>
@@ -9,6 +9,7 @@ type Release struct {
type Components struct {
Kubernetes Kubernetes `yaml:"kubernetes"`
OperatingSystem OperatingSystem `yaml:"operatingSystem"`
Rancher HelmChart `yaml:"rancher"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still fuzzy on how this will look like, but we can revisit it for the next chart.

@@ -172,5 +209,28 @@ func (r *UpgradePlanReconciler) SetupWithManager(mgr ctrl.Manager) error {
len(e.ObjectOld.(*upgradecattlev1.Plan).Status.Applying) != 0
},
})).
Watches(&batchv1.Job{}, handler.EnqueueRequestsFromMapFunc(r.findUpgradePlanFromJob), builder.WithPredicates(predicate.Funcs{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, the Helm controller doesn't really offer us anything to work on for the HelmChart resource so we must watch the Jobs that are spawned from it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sanity check me on the process:

  1. We locate Jobs that have been created by the helm controller (e.g. have the controller label)
  2. From the label we locate the HelmChart resource
  3. From the HelmChart resources we check whether it has the upgrade plan annotation
  4. If it does, we return the plan location
  5. From there reconciliation is triggered on when the Job reaches a finished status (e.g. Completed or Failed)

@atanasdinov atanasdinov marked this pull request as ready for review July 25, 2024 08:50
Copy link
Contributor

@ipetrov117 ipetrov117 left a comment

Choose a reason for hiding this comment

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

LGTM! I left out some comments and will be happy to approve once we discuss them.

Apart from the comments below, I think it is fair to say that assuming that the upgrade has finished successfully by looking only at the helm controller Job would not be enough in the long term.

Probably every chart component would have to have its separate logic validating whether its resources are running on the desired upgrade version. For example, for Rancher we might have to look at the server-version property that can be displayed using this command: kubectl get settings.management.cattle.io server-version.

Nevertheless, the above statements would need to be handled in a different PR later down the line once we have something relatively stable.. Great job on this!

manifests/release-3.0.1.yaml Show resolved Hide resolved
internal/upgrade/helm.go Show resolved Hide resolved
@@ -172,5 +209,28 @@ func (r *UpgradePlanReconciler) SetupWithManager(mgr ctrl.Manager) error {
len(e.ObjectOld.(*upgradecattlev1.Plan).Status.Applying) != 0
},
})).
Watches(&batchv1.Job{}, handler.EnqueueRequestsFromMapFunc(r.findUpgradePlanFromJob), builder.WithPredicates(predicate.Funcs{
Copy link
Contributor

Choose a reason for hiding this comment

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

Sanity check me on the process:

  1. We locate Jobs that have been created by the helm controller (e.g. have the controller label)
  2. From the label we locate the HelmChart resource
  3. From the HelmChart resources we check whether it has the upgrade plan annotation
  4. If it does, we return the plan location
  5. From there reconciliation is triggered on when the Job reaches a finished status (e.g. Completed or Failed)

internal/controller/reconcile_rancher.go Show resolved Hide resolved
@atanasdinov atanasdinov merged commit 406fc86 into suse-edge:main Jul 26, 2024
2 checks passed
@atanasdinov atanasdinov deleted the rancher-upgrade branch July 26, 2024 07:47
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.

2 participants