timflannagan / rukpak

Rukpak runs in a Kubernetes cluster and defines an API for installing cloud native bundle content
Apache License 2.0
0 stars 0 forks source link

play around with pivoting behavior #27

Open github-actions[bot] opened 2 years ago

github-actions[bot] commented 2 years ago

https://github.com/timflannagan/rukpak/blob/98fa7144abc2d937a3ad3a581501df4eb59de396/internal/provisioner/plain/controllers/bundleinstance_controller.go#L108


        }
    }()

    // TODO: we're not properly clearing out Bundle lookup errors despite the installation being successful
    // TODO: need to at least add a simple message for when the InstallationSucceeded reason is present
    // TODO: play around with pivoting behavior
    // TODO: immutable bundles vs. updating bundles directly

    b := &rukpakv1alpha1.Bundle{}
    if err := r.Get(ctx, types.NamespacedName{Name: bi.Spec.Bundle.Name}, b); err != nil {
        // check whether we're handling an embedded Bundle spec
        if bi.Spec.Bundle.Spec == nil {
            bundleStatus := metav1.ConditionUnknown
            if apierrors.IsNotFound(err) {
                bundleStatus = metav1.ConditionFalse
            }
            meta.SetStatusCondition(&bi.Status.Conditions, metav1.Condition{
                Type:    rukpakv1alpha1.TypeHasValidBundle,
                Status:  bundleStatus,
                Reason:  rukpakv1alpha1.ReasonBundleLookupFailed,
                Message: err.Error(),
            })
            return ctrl.Result{}, client.IgnoreNotFound(err)
        }
        if apierrors.IsNotFound(err) {
            bundleSpec := bi.Spec.Bundle.Spec
            b = &rukpakv1alpha1.Bundle{
                ObjectMeta: metav1.ObjectMeta{
                    Name: bi.Spec.Bundle.Name,
                },
                Spec: rukpakv1alpha1.BundleSpec{
                    ProvisionerClassName: bundleSpec.ProvisionerClassName,
                    Source:               bundleSpec.Source,
                },
            }
            if err := controllerutil.SetOwnerReference(bi, b, r.Scheme); err != nil {
                return ctrl.Result{}, fmt.Errorf("failed to establish owner references for embedded bundle: %v", err)
            }
            if err := r.Create(ctx, b); err != nil {
                // TODO: bubble this up somehow
                return ctrl.Result{}, err
            }
        }
    }
    // r.ensureBundle -> bundle; r.ensureBundle calls r.ensureEmbeddedBundle under-the-hood?
    // TODO: create an r.ensureEmbeddedBundle(...) method
    // TODO: check case for missing owner references
    if bi.Spec.Bundle.Spec != nil {
        var needsUpdate bool
        if b.GetName() != bi.Spec.Bundle.Name {
            b.Name = bi.Spec.Bundle.Name
            needsUpdate = true
        }
        if !equality.Semantic.DeepEqual(b.Spec, bi.Spec.Bundle.Spec) {
            b.Spec = *bi.Spec.Bundle.Spec
            needsUpdate = true
        }
        // check whether we need to update the embedded Bundle resource and
        // let r.loadBundle determine whether the Bundle is reporting a non-sucessful
        // bundle unpack status.
        if needsUpdate {
            if err := r.Update(ctx, b); err != nil {
                // TODO: bubble this up to the status
                return ctrl.Result{}, fmt.Errorf("failed to update the embedded bundle: %v", err)
            }
        }
    }
    // TODO: handle the interaction between installed and desired Bundle status field

    desiredObjects, err := r.loadBundle(ctx, bi)
    if err != nil {
github-actions[bot] commented 1 year ago

This issue has become stale because it has been open 60 days with no activity. The maintainers of this repo will remove this label during issue triage or it will be removed automatically after an update. Adding the lifecycle/frozen label will cause this issue to ignore lifecycle events.