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

remove duplicate workflow installation and deletion #99

Closed
wants to merge 34 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
61c1bea
refactor load-test
Feb 12, 2022
07a82b0
refactor load-tests
Feb 12, 2022
b2e6286
Update go modules also
Feb 12, 2022
e259f63
replace using script template workflow
Feb 15, 2022
a2c927f
fix: controller performance optimization
Feb 15, 2022
853d8ae
fix: cleanup
Feb 15, 2022
112a508
fix: cleanup
Feb 15, 2022
b9ec0cc
fix: remove waitgroup what wait for itself
Feb 15, 2022
899c8bc
fix: remove duplicate runWorkflow call even after workflow has been c…
Feb 15, 2022
cea2530
Improve: decouple addon prereq and install installation
Feb 16, 2022
e695cdf
Fix: remove duplicate addon exec and install
Feb 16, 2022
490f2e4
Fix: remove duplicate deletion call
Feb 16, 2022
92e9356
remove load-test code from the PR
Feb 16, 2022
786b2e3
remove test-load code
Feb 16, 2022
6941ad8
Add clientset comment marker generating clientset code
Feb 16, 2022
4d1f5d3
Update Makefile with code-generator
Feb 16, 2022
68f2cd2
fix: generate clientset for addon APIGroups
Feb 16, 2022
6f1150a
fix: update api
Feb 16, 2022
24fdfbc
fix: refer to API new location
Feb 16, 2022
52b3401
Fix: use addon api clientset update addon cr status
Feb 17, 2022
ec84cb4
Fix: remove memory cache
Feb 17, 2022
5a400a8
Fix: list addons from cluster
Feb 17, 2022
523521e
revert wrong commands
Feb 17, 2022
9d87f7f
Fix: workflow installation only once
Feb 18, 2022
729b1ab
Fix controller test setup
Feb 28, 2022
d753ce3
Revert "Fix controller test setup"
Feb 28, 2022
0e56d06
Revert "Revert "Fix controller test setup""
Feb 28, 2022
a5f2ba7
Revert merge errors
Feb 28, 2022
f32f5fe
revert merge mistakes
Feb 28, 2022
84e39b2
Revert merge errors
Feb 28, 2022
f878267
Fix controller tests
Feb 28, 2022
36160c3
Fix controller checksum bug based on unit tests
Feb 28, 2022
ff1b032
Merge branch 'master' into tests-and-perf
Feb 28, 2022
2355b35
Fix: controller unit test cases
Feb 28, 2022
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
Prev Previous commit
Next Next commit
Improve: decouple addon prereq and install installation
Signed-off-by: jhu02 <jiminh@jiminhs-MacBook-Pro.local>
jhu02 authored and jhu02 committed Feb 16, 2022
commit cea2530e959beae51f9b04a2bfeb6e8ae98d1644
21 changes: 18 additions & 3 deletions controllers/addon_controller.go
Original file line number Diff line number Diff line change
@@ -368,12 +368,23 @@ func (r *AddonReconciler) processAddon(ctx context.Context, log logr.Logger, ins
// Also if workflow is in Pending state, execute it to update status to terminal state.
if changedStatus || instance.Status.Lifecycle.Installed == addonmgrv1alpha1.ValidationFailed ||
instance.Status.Lifecycle.Prereqs == addonmgrv1alpha1.Pending || instance.Status.Lifecycle.Installed == addonmgrv1alpha1.Pending {
log.Info("Addon spec is updated, workflows will be generated")
log.Info("Addon spec is updated, workflows will be updated.")
if prereqwfstatus := r.config.statusCache.Read(instance.GetNamespace(), instance.Name, string(addonmgrv1alpha1.Prereqs)); prereqwfstatus != "" {
instance.Status.Lifecycle.Prereqs = addonmgrv1alpha1.ApplicationAssemblyPhase(prereqwfstatus)
} else {
err := r.executePrereq(ctx, log, instance, wfl)
if err != nil {
return reconcile.Result{}, err
}
}

if wfinstallstatus := r.config.statusCache.Read(instance.GetNamespace(), instance.Name, string(addonmgrv1alpha1.Install)); wfinstallstatus != "" {
instance.Status.Lifecycle.Installed = addonmgrv1alpha1.ApplicationAssemblyPhase(wfinstallstatus)
} else {
err := r.executeInstall(ctx, log, instance, wfl)
if err != nil {
return reconcile.Result{}, err
}
}
}

@@ -473,9 +484,8 @@ func (r *AddonReconciler) addAddonToCache(log logr.Logger, instance *addonmgrv1a
log.Info("Adding version cache", "phase", version.PkgPhase)
}

func (r *AddonReconciler) executePrereqAndInstall(ctx context.Context, log logr.Logger, instance *addonmgrv1alpha1.Addon, wfl workflows.AddonLifecycle) error {
func (r *AddonReconciler) executePrereq(ctx context.Context, log logr.Logger, instance *addonmgrv1alpha1.Addon, wfl workflows.AddonLifecycle) error {
// Always reset reason when executing
fmt.Printf("\n why execute repeat PrereqAndInstall. instead we should check wf status directly.\n")
instance.Status.Reason = ""
prereqsPhase, err := r.runWorkflow(addonmgrv1alpha1.Prereqs, instance, wfl)
if err != nil {
@@ -502,6 +512,11 @@ func (r *AddonReconciler) executePrereqAndInstall(ctx context.Context, log logr.
return fmt.Errorf(reason)
}

return nil
}

func (r *AddonReconciler) executeInstall(ctx context.Context, log logr.Logger, instance *addonmgrv1alpha1.Addon, wfl workflows.AddonLifecycle) error {

if instance.Status.Lifecycle.Prereqs == addonmgrv1alpha1.Succeeded {
if err := r.validateSecrets(ctx, instance); err != nil {
reason := fmt.Sprintf("Addon %s/%s could not validate secrets. %v", instance.Namespace, instance.Name, err)