Skip to content

Commit 7e29c14

Browse files
committed
Add comments with context to apply and agent code
A couple of new comments should help our future selves, or our successors, understand why this new logic has been added.
1 parent e02ac76 commit 7e29c14

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

internal/cmd/agent/controller/bundledeployment_controller.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,14 @@ func (r *BundleDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req
218218
merr = append(merr, fmt.Errorf("failed refreshing drift detection: %w", err))
219219
}
220220

221-
logger.V(1).Info("### ModifiedStatus", "orig", orig.Status.ModifiedStatus, "bd", bd.Status.ModifiedStatus)
222-
// FIXME why would this run multiple times, e.g. every 5s?
221+
// Check if this bundle deployment has overlapping resources with a previously deleted bundle (Overwrites
222+
// field): if so, requeue to ensure the corresponding Helm release, and therefore its resources, are
223+
// reinstalled.
224+
// Overlaps are checked by namespace, kind and name. Resource contents do not matter in this context, as a
225+
// resource would be deleted by Helm deleting its parent release based on its kind, name and namespace.
226+
// This requires deleting the release beforehand, to force a new installation as the deployer would otherwise
227+
// skip re-installing an existing release with no version change.
228+
// See fleet#3770 for more context.
223229
if len(orig.Status.ModifiedStatus) > 0 && len(orig.Spec.Options.Overwrites) > 0 {
224230
for _, ms := range orig.Status.ModifiedStatus {
225231
if !ms.Create { // missing

internal/cmd/cli/apply/apply.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,13 @@ func pruneBundlesNotFoundInRepo(
348348
if _, ok := gitRepoBundlesMap[bundle.Name]; !ok {
349349
logrus.Debugf("Bundle to be deleted since it is not found in gitrepo %v anymore %v %v", repoName, bundle.Namespace, bundle.Name)
350350

351+
// Populate new bundles' `Overwrites` field with possible overlaps between the in-cluster bundle, to be deleted,
352+
// and bundles which will be created in the cluster.
353+
// Knowing about these overlaps, if any, the Fleet agent will then be able to:
354+
// 1. match them against possible missing resources in a bundle deployment's status
355+
// 2. trigger a new deployment, re-creating missing resources if those are overwritten by the
356+
// bundle deployment
357+
// See fleet#3770 for more context.
351358
for _, inClusterRsc := range bundle.Spec.Resources {
352359
for _, grb := range gitRepoBundlesMap {
353360
logrus.Debugf("gitRepo bundle: %v", grb)

0 commit comments

Comments
 (0)