Skip to content

Commit

Permalink
feat: add events and status for ApisixClusterConfig resource (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
gxthrj authored May 31, 2021
1 parent a89be23 commit 029c0d7
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pkg/ingress/apisix_cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import (
"time"

"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"

Expand Down Expand Up @@ -140,6 +142,8 @@ func (c *apisixClusterConfigController) sync(ctx context.Context, ev *types.Even
zap.Error(err),
zap.Any("opts", clusterOpts),
)
c.controller.recorderEvent(acc, corev1.EventTypeWarning, _resourceSyncAborted, err)
c.controller.recordStatus(acc, _resourceSyncAborted, err, metav1.ConditionFalse)
return err
}
}
Expand All @@ -152,6 +156,8 @@ func (c *apisixClusterConfigController) sync(ctx context.Context, ev *types.Even
zap.String("key", key),
zap.Any("object", acc),
)
c.controller.recorderEvent(acc, corev1.EventTypeWarning, _resourceSyncAborted, err)
c.controller.recordStatus(acc, _resourceSyncAborted, err, metav1.ConditionFalse)
return err
}
log.Debugw("translated global_rule",
Expand All @@ -169,8 +175,12 @@ func (c *apisixClusterConfigController) sync(ctx context.Context, ev *types.Even
zap.Any("global_rule", globalRule),
zap.Any("cluster", acc.Name),
)
c.controller.recorderEvent(acc, corev1.EventTypeWarning, _resourceSyncAborted, err)
c.controller.recordStatus(acc, _resourceSyncAborted, err, metav1.ConditionFalse)
return err
}
c.controller.recorderEvent(acc, corev1.EventTypeNormal, _resourceSynced, nil)
c.controller.recordStatus(acc, _resourceSynced, nil, metav1.ConditionTrue)
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/kube/apisix/apis/config/v2alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ type ApisixClusterConfig struct {
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`

// Spec defines the desired state of ApisixClusterConfigSpec.
Spec ApisixClusterConfigSpec `json:"spec" yaml:"spec"`
Spec ApisixClusterConfigSpec `json:"spec" yaml:"spec"`
Status ApisixStatus `json:"status,omitempty" yaml:"status,omitempty"`
}

// ApisixClusterConfigSpec defines the desired state of ApisixClusterConfigSpec.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions samples/deploy/rbac/apisix_view_clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ rules:
- apisixtlses
- apisixtlses/status
- apisixclusterconfigs
- apisixclusterconfigs/status
- apisixconsumers
- apisixconsumers/status
verbs:
- '*'
- apiGroups:
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/scaffold/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ rules:
- apisixtlses
- apisixtlses/status
- apisixclusterconfigs
- apisixclusterconfigs/status
- apisixconsumers
- apisixconsumers/status
verbs:
- '*'
- apiGroups:
Expand Down

0 comments on commit 029c0d7

Please sign in to comment.