Skip to content

Commit

Permalink
fix: add delete api define and remove watch api.
Browse files Browse the repository at this point in the history
Signed-off-by: Li Jie <cpunion@gmail.com>
  • Loading branch information
cpunion committed Jun 15, 2024
1 parent 541b728 commit bb2924d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 32 deletions.
1 change: 0 additions & 1 deletion pkg/agent/monitortool/latency_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"k8s.io/klog/v2"

statsv1alpha1 "antrea.io/antrea/pkg/apis/stats/v1alpha1"

"antrea.io/antrea/pkg/util/k8s"
)

Expand Down
9 changes: 4 additions & 5 deletions pkg/agent/monitortool/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ import (
"k8s.io/klog/v2"
"k8s.io/utils/clock"

statsv1alpha1 "antrea.io/antrea/pkg/apis/stats/v1alpha1"

"antrea.io/antrea/pkg/agent/client"
"antrea.io/antrea/pkg/agent/config"
"antrea.io/antrea/pkg/apis/crd/v1alpha1"
statsv1alpha1 "antrea.io/antrea/pkg/apis/stats/v1alpha1"
crdinformers "antrea.io/antrea/pkg/client/informers/externalversions/crd/v1alpha1"
)

Expand Down Expand Up @@ -376,8 +375,8 @@ func (m *NodeLatencyMonitor) pingAll(ipv4Socket, ipv6Socket net.PacketConn) {
klog.V(4).InfoS("Done pinging all Nodes")
}

// GetSummary returns the latency summary of the given Node IP.
func (m *NodeLatencyMonitor) GetSummary() *statsv1alpha1.NodeLatencyStats {
// getSummary returns the latency summary of the given Node IP.
func (m *NodeLatencyMonitor) getSummary() *statsv1alpha1.NodeLatencyStats {
return &statsv1alpha1.NodeLatencyStats{
ObjectMeta: metav1.ObjectMeta{
Name: m.nodeName,
Expand All @@ -387,7 +386,7 @@ func (m *NodeLatencyMonitor) GetSummary() *statsv1alpha1.NodeLatencyStats {
}

func (m *NodeLatencyMonitor) report() {
summary := m.GetSummary()
summary := m.getSummary()
antreaClient, err := m.antreaClientProvider.GetAntreaClient()
if err != nil {
klog.ErrorS(err, "Failed to get Antrea client")
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/stats/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ type RuleTrafficStats struct {
// +genclient
// +genclient:nonNamespaced
// +resourceName=nodelatencystats
// +genclient:onlyVerbs=create,delete,get,list,watch
// +genclient:onlyVerbs=create,delete,get,list
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// NodeLatencyStats contains all the latency measurements collected by the Agent from a specific Node.
Expand Down
4 changes: 2 additions & 2 deletions pkg/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import (
"antrea.io/antrea/pkg/apiserver/registry/stats/antreanetworkpolicystats"
"antrea.io/antrea/pkg/apiserver/registry/stats/multicastgroup"
"antrea.io/antrea/pkg/apiserver/registry/stats/networkpolicystats"
nodelatencystat "antrea.io/antrea/pkg/apiserver/registry/stats/nodelatencystats"
"antrea.io/antrea/pkg/apiserver/registry/stats/nodelatencystats"
"antrea.io/antrea/pkg/apiserver/registry/system/controllerinfo"
"antrea.io/antrea/pkg/apiserver/registry/system/supportbundle"
"antrea.io/antrea/pkg/apiserver/storage"
Expand Down Expand Up @@ -241,7 +241,7 @@ func installAPIGroup(s *APIServer, c completedConfig) error {
statsStorage["antreaclusternetworkpolicystats"] = antreaclusternetworkpolicystats.NewREST(c.extraConfig.statsAggregator)
statsStorage["antreanetworkpolicystats"] = antreanetworkpolicystats.NewREST(c.extraConfig.statsAggregator)
statsStorage["multicastgroups"] = multicastgroup.NewREST(c.extraConfig.statsAggregator)
statsStorage["nodelatencystats"] = nodelatencystat.NewREST()
statsStorage["nodelatencystats"] = nodelatencystats.NewREST()
statsGroup.VersionedResourcesStorageMap["v1alpha1"] = statsStorage

groups := []*genericapiserver.APIGroupInfo{&cpGroup, &systemGroup, &statsGroup}
Expand Down
5 changes: 5 additions & 0 deletions pkg/apiserver/registry/stats/nodelatencystats/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
_ rest.Scoper = &REST{}
_ rest.Getter = &REST{}
_ rest.Lister = &REST{}
_ rest.GracefulDeleter = &REST{}
_ rest.SingularNameProvider = &REST{}
)

Expand Down Expand Up @@ -79,6 +80,10 @@ func (r *REST) ConvertToTable(ctx context.Context, obj runtime.Object, tableOpti
return table, nil
}

func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
return &statsv1alpha1.NodeLatencyStats{}, true, nil
}

func (r *REST) NamespaceScoped() bool {
return false
}
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.

0 comments on commit bb2924d

Please sign in to comment.