Skip to content

Commit

Permalink
[#1084] Retry transient artemis status errors
Browse files Browse the repository at this point in the history
  • Loading branch information
brusdev committed Jan 22, 2025
1 parent 1184e8e commit ebf8ae2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
17 changes: 10 additions & 7 deletions controllers/activemqartemis_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,11 @@ type ArtemisError interface {
Requeue() bool
}

type unknownJolokiaError struct {
cause error
type artemisStatusError struct {
cause error
transient bool
}

type jolokiaClientNotFoundError struct {
cause error
}
Expand All @@ -881,18 +883,19 @@ type versionMismatchError struct {
cause string
}

func NewUnknownJolokiaError(err error) unknownJolokiaError {
return unknownJolokiaError{
func NewArtemisStatusError(err error, transient bool) artemisStatusError {
return artemisStatusError{
err,
transient,
}
}

func (e unknownJolokiaError) Error() string {
func (e artemisStatusError) Error() string {
return e.cause.Error()
}

func (e unknownJolokiaError) Requeue() bool {
return false
func (e artemisStatusError) Requeue() bool {
return e.transient
}

func NewJolokiaClientsNotFoundError(err error) jolokiaClientNotFoundError {
Expand Down
22 changes: 11 additions & 11 deletions controllers/activemqartemis_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3261,7 +3261,7 @@ func AssertBrokersAvailable(cr *brokerv1beta1.ActiveMQArtemis, client rtclient.C
DeployedCondition := meta.FindStatusCondition(cr.Status.Conditions, brokerv1beta1.DeployedConditionType)
if DeployedCondition == nil || DeployedCondition.Status == metav1.ConditionFalse {
reqLogger.V(2).Info("There are no available brokers from DeployedCondition", "condition", DeployedCondition)
return NewUnknownJolokiaError(errors.New("no available brokers from deployed condition"))
return NewArtemisStatusError(errors.New("no available brokers from deployed condition"), false)
}
return nil
}
Expand All @@ -3271,8 +3271,8 @@ func (reconciler *ActiveMQArtemisReconcilerImpl) AssertBrokerPropertiesStatus(cr

secretProjection, err := getSecretProjection(getPropertiesResourceNsName(cr), client)
if err != nil {
reqLogger.V(2).Info("error retrieving config resources. requeing")
return NewUnknownJolokiaError(err)
reqLogger.V(2).Info("error retrieving config resources.")
return NewArtemisStatusError(err, false)
}

errorStatus := reconciler.checkProjectionStatus(cr, client, secretProjection, func(BrokerStatus *brokerStatus, FileName string) (propertiesStatus, bool) {
Expand All @@ -3285,8 +3285,8 @@ func (reconciler *ActiveMQArtemisReconcilerImpl) AssertBrokerPropertiesStatus(cr
if strings.HasSuffix(extraSecretName, brokerPropsSuffix) {
secretProjection, err = getSecretProjection(types.NamespacedName{Name: extraSecretName, Namespace: cr.Namespace}, client)
if err != nil {
reqLogger.V(2).Info("error retrieving -bp extra mount resource. requeing")
return NewUnknownJolokiaError(err)
reqLogger.V(2).Info("error retrieving -bp extra mount resource.")
return NewArtemisStatusError(err, false)
}
errorStatus = reconciler.checkProjectionStatus(cr, client, secretProjection, func(BrokerStatus *brokerStatus, FileName string) (propertiesStatus, bool) {
current, present := BrokerStatus.BrokerConfigStatus.PropertiesStatus[FileName]
Expand All @@ -3310,8 +3310,8 @@ func (reconciler *ActiveMQArtemisReconcilerImpl) AssertJaasPropertiesStatus(cr *

Projection, err := getConfigMappedJaasProperties(cr, client)
if err != nil {
reqLogger.V(2).Info("error retrieving config resources. requeing")
return NewUnknownJolokiaError(err)
reqLogger.V(2).Info("error retrieving config resources.")
return NewArtemisStatusError(err, false)
}

statusError := reconciler.checkProjectionStatus(cr, client, Projection, func(BrokerStatus *brokerStatus, FileName string) (propertiesStatus, bool) {
Expand Down Expand Up @@ -3375,16 +3375,16 @@ func (reconciler *ActiveMQArtemisReconcilerImpl) checkStatus(cr *brokerv1beta1.A
currentJson, err := jk.Artemis.GetStatus()

if err != nil {
reqLogger.V(1).Info("unknown status reported from Jolokia.", "IP", jk.IP, "Ordinal", jk.Ordinal, "error", err)
return NewUnknownJolokiaError(err)
reqLogger.V(1).Info("error getting broker status with Jolokia", "IP", jk.IP, "Ordinal", jk.Ordinal, "error", err)
return NewArtemisStatusError(err, false)
}

reqLogger.V(2).Info("raw json status", "IP", jk.IP, "ordinal", jk.Ordinal, "status json", currentJson)

brokerStatus, err := unmarshallStatus(currentJson)
if err != nil {
reqLogger.Error(err, "unable to unmarshall broker status", "json", currentJson)
return NewUnknownJolokiaError(err)
return NewArtemisStatusError(err, false)
}

reqLogger.V(2).Info("broker status", "ordinal", jk.Ordinal, "status", brokerStatus)
Expand Down Expand Up @@ -3510,7 +3510,7 @@ func getSecretProjection(secretName types.NamespacedName, client rtclient.Client
resource := corev1.Secret{}
err := client.Get(context.TODO(), secretName, &resource)
if err != nil {
return nil, NewUnknownJolokiaError(errors.Wrap(err, "unable to retrieve mutable properties secret"))
return nil, errors.Wrap(err, "unable to retrieve secret projection")
}
return newProjectionFromByteValues(resource.ObjectMeta, resource.Data), nil
}
Expand Down

0 comments on commit ebf8ae2

Please sign in to comment.