-
Notifications
You must be signed in to change notification settings - Fork 81
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
Operator Enhancement #560
Operator Enhancement #560
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import ( | |
|
||
"github.com/go-logr/logr" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
appsv1 "k8s.io/api/apps/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/rest" | ||
|
@@ -67,7 +68,9 @@ func (r *BrokerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr | |
// Check if Broker controller deployed | ||
result, err := r.reconcileBroker(ctx, true, baseResource, req) | ||
if err != nil { | ||
return ctrl.Result{}, ErrReconcileBroker(err) | ||
err = ErrReconcileBroker(err) | ||
r.Log.Error(err, "broker reconcilation failed") | ||
return ctrl.Result{}, err | ||
} | ||
|
||
// Check if Broker controller started | ||
|
@@ -79,18 +82,24 @@ func (r *BrokerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr | |
// Get broker endpoint | ||
err = brokerpackage.GetEndpoint(ctx, baseResource, r.Clientset, r.KubeConfig.Host) | ||
if err != nil { | ||
return ctrl.Result{}, ErrGetEndpoint(err) | ||
err = ErrGetEndpoint(err) | ||
r.Log.Error(err, "unable to get the broker endpoint") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. meaning that the endpoint is undefined or that a network-based attempt failed? |
||
return ctrl.Result{}, err | ||
} | ||
|
||
// Patch the broker resource | ||
patch, err := utils.Marshal(baseResource) | ||
if err != nil { | ||
return ctrl.Result{}, ErrUpdateResource(err) | ||
err = ErrUpdateResource(err) | ||
r.Log.Error(err, "unable to update broker resource") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meaning that the resource couldn't be found or that it is present but the operator doesn't have permission or something else? |
||
return ctrl.Result{}, err | ||
} | ||
|
||
err = r.Status().Patch(ctx, baseResource, client.RawPatch(types.MergePatchType, []byte(patch))) | ||
if err != nil { | ||
return ctrl.Result{}, ErrUpdateResource(err) | ||
err = ErrUpdateResource(err) | ||
r.Log.Error(err, "unable to update broker resource") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meaning that the configuration was rejected from Kube API or that the resource isn't present or that the requested configuration was missing or invalid or what? |
||
return ctrl.Result{}, err | ||
} | ||
|
||
return result, nil | ||
|
@@ -99,6 +108,7 @@ func (r *BrokerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr | |
func (r *BrokerReconciler) SetupWithManager(mgr ctrl.Manager) error { | ||
return ctrl.NewControllerManagedBy(mgr). | ||
For(&mesheryv1alpha1.Broker{}). | ||
Owns(&appsv1.StatefulSet{}). | ||
Complete(r) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,53 +39,53 @@ const ( | |
|
||
// Error definitions | ||
func ErrGetMeshsync(err error) error { | ||
return errors.New(ErrGetMeshsyncCode + ":" + "Unable to get meshsync resource") | ||
return errors.New(ErrGetMeshsyncCode + ":" + "Unable to get meshsync resource" + err.Error()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meaning that the custom resource was never created? |
||
} | ||
|
||
func ErrCreateMeshsync(err error) error { | ||
return errors.New(ErrCreateMeshsyncCode + ":" + "Unable to create meshsync controller") | ||
return errors.New(ErrCreateMeshsyncCode + ":" + "Unable to create meshsync controller" + err.Error()) | ||
} | ||
|
||
func ErrDeleteMeshsync(err error) error { | ||
return errors.New(ErrDeleteMeshsyncCode + ":" + "Unable to delete meshsync controller") | ||
return errors.New(ErrDeleteMeshsyncCode + ":" + "Unable to delete meshsync controller" + err.Error()) | ||
} | ||
|
||
func ErrReconcileMeshsync(err error) error { | ||
return errors.New(ErrReconcileMeshsyncCode + ":" + "Error during meshsync resource reconciliation") | ||
return errors.New(ErrReconcileMeshsyncCode + ":" + "Error during meshsync resource reconciliation" + err.Error()) | ||
} | ||
|
||
func ErrGetBroker(err error) error { | ||
return errors.New(ErrGetBrokerCode + ":" + "Broker resource not found") | ||
return errors.New(ErrGetBrokerCode + ":" + "Broker resource not found" + err.Error()) | ||
} | ||
|
||
func ErrCreateBroker(err error) error { | ||
return errors.New(ErrCreateBrokerCode + ":" + "Unable to create broker controller") | ||
return errors.New(ErrCreateBrokerCode + ":" + "Unable to create broker controller" + err.Error()) | ||
} | ||
|
||
func ErrDeleteBroker(err error) error { | ||
return errors.New(ErrDeleteBrokerCode + ":" + "Unable to delete broker controller") | ||
return errors.New(ErrDeleteBrokerCode + ":" + "Unable to delete broker controller" + err.Error()) | ||
} | ||
|
||
func ErrReconcileBroker(err error) error { | ||
return errors.New(ErrReconcileBrokerCode + ":" + "Error during broker resource reconciliation") | ||
return errors.New(ErrReconcileBrokerCode + ":" + "Error during broker resource reconciliation" + err.Error()) | ||
} | ||
|
||
func ErrReconcileCR(err error) error { | ||
return errors.New(ErrReconcileCRCode + ":" + "Error during custom resource reconciliation") | ||
return errors.New(ErrReconcileCRCode + ":" + "Error during custom resource reconciliation" + err.Error()) | ||
} | ||
|
||
func ErrCheckHealth(err error) error { | ||
return errors.New(ErrCheckHealthCode + ":" + "Error during health check") | ||
return errors.New(ErrCheckHealthCode + ":" + "Error during health check" + err.Error()) | ||
} | ||
|
||
func ErrGetEndpoint(err error) error { | ||
return errors.New(ErrGetEndpointCode + ":" + "Unable to get endpoint") | ||
return errors.New(ErrGetEndpointCode + ":" + "Unable to get endpoint" + err.Error()) | ||
} | ||
|
||
func ErrUpdateResource(err error) error { | ||
return errors.New(ErrUpdateResourceCode + ":" + "Unable to update resource") | ||
return errors.New(ErrUpdateResourceCode + ":" + "Unable to update resource" + err.Error()) | ||
} | ||
|
||
func ErrMarshal(err error) error { | ||
return errors.New(ErrMarshalCode + ":" + "Error during marshaling") | ||
return errors.New(ErrMarshalCode + ":" + "Error during marshaling" + err.Error()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reconciliation failures means what?