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

feat: add bundle metadata and fix secret #9

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v5.1.1
KUSTOMIZE_VERSION ?= v5.2.1
CONTROLLER_TOOLS_VERSION ?= v0.13.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
annotations:
alm-examples: '[]'
capabilities: Basic Install
categories: 'Storage, Compute'
datasuit: 'Develop, Analysis, Governance'
name: hive-metastore-operator.v0.0.0
namespace: placeholder
spec:
Expand Down
4 changes: 1 addition & 3 deletions internal/controller/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func makeSecret(ctx context.Context, instance *stackv1alpha1.HiveMetastore, sche
data["POSTGRES_DB"] = []byte(instance.Spec.PostgresSecret.DataBase)
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: instance.GetNameWithSuffix("-secret"),
Name: instance.GetNameWithSuffix("secret"),
Namespace: instance.Namespace,
Labels: labels,
},
Expand All @@ -198,7 +198,5 @@ func (r *HiveMetastoreReconciler) reconcileSecret(ctx context.Context, instance
return err
}
}
// Create or update the secret

return nil
}
63 changes: 28 additions & 35 deletions internal/controller/hivemetastore_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"context"
"github.com/go-logr/logr"
stackv1alpha1 "github.com/zncdata-labs/hive-metastore-operator/api/v1alpha1"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/util/retry"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -67,18 +69,23 @@ func (r *HiveMetastoreReconciler) Reconcile(ctx context.Context, req ctrl.Reques
return ctrl.Result{}, nil
}

//// Get the status condition, if it exists and its generation is not the
////same as the HiveMetastore's generation, reset the status conditions
//readCondition := apimeta.FindStatusCondition(hiveMetastore.Status.Conditions, stackv1alpha1.ConditionTypeProgressing)
//if readCondition == nil || readCondition.ObservedGeneration != hiveMetastore.GetGeneration() {
// hiveMetastore.InitStatusConditions()
//
// if err := r.UpdateStatus(ctx, hiveMetastore); err != nil {
// return ctrl.Result{}, err
// }
//}
//
//r.Log.Info("HiveMetastore found", "Name", hiveMetastore.Name)
// Get the status condition, if it exists and its generation is not the
//same as the HiveMetastore's generation, reset the status conditions
readCondition := apimeta.FindStatusCondition(hiveMetastore.Status.Conditions, stackv1alpha1.ConditionTypeProgressing)
if readCondition == nil || readCondition.ObservedGeneration != hiveMetastore.GetGeneration() {
hiveMetastore.InitStatusConditions()

if err := r.UpdateStatus(ctx, hiveMetastore); err != nil {
return ctrl.Result{}, err
}
}

r.Log.Info("HiveMetastore found", "Name", hiveMetastore.Name)

if err := r.reconcileSecret(ctx, hiveMetastore); err != nil {
r.Log.Error(err, "unable to reconcile Secret")
return ctrl.Result{}, err
}

if err := r.reconcileDeployment(ctx, hiveMetastore); err != nil {
r.Log.Error(err, "unable to reconcile Deployment")
Expand All @@ -90,23 +97,18 @@ func (r *HiveMetastoreReconciler) Reconcile(ctx context.Context, req ctrl.Reques
return ctrl.Result{}, err
}

if err := r.reconcileSecret(ctx, hiveMetastore); err != nil {
r.Log.Error(err, "unable to reconcile Secret")
hiveMetastore.SetStatusCondition(metav1.Condition{
Type: stackv1alpha1.ConditionTypeAvailable,
Status: metav1.ConditionTrue,
Reason: stackv1alpha1.ConditionReasonRunning,
Message: "HiveMetastore is running",
ObservedGeneration: hiveMetastore.GetGeneration(),
})

if err := r.UpdateStatus(ctx, hiveMetastore); err != nil {
return ctrl.Result{}, err
}

//hiveMetastore.SetStatusCondition(metav1.Condition{
// Type: stackv1alpha1.ConditionTypeAvailable,
// Status: metav1.ConditionTrue,
// Reason: stackv1alpha1.ConditionReasonRunning,
// Message: "HiveMetastore is running",
// ObservedGeneration: hiveMetastore.GetGeneration(),
//})

//if err := r.UpdateStatus(ctx, hiveMetastore); err != nil {
// return ctrl.Result{}, err
//}

r.Log.Info("Successfully reconciled hiveMetastore")
return ctrl.Result{}, nil
}
Expand All @@ -122,15 +124,6 @@ func (r *HiveMetastoreReconciler) UpdateStatus(ctx context.Context, instance *st
return retryErr
}

//if err := r.Get(ctx, key, latest); err != nil {
// r.Log.Error(err, "Failed to get latest object")
// return err
//}

//if err := r.Status().Patch(ctx, instance, client.MergeFrom(instance)); err != nil {
// r.Log.Error(err, "Failed to patch object status")
// return err
//}
r.Log.V(1).Info("Successfully patched object status")
return nil
}
Expand Down