Skip to content

Commit

Permalink
feat: delete invalid code for promethus target
Browse files Browse the repository at this point in the history
  • Loading branch information
askyrie committed Jul 26, 2024
1 parent 82f9196 commit 36ed4fb
Show file tree
Hide file tree
Showing 45 changed files with 33 additions and 1,381 deletions.
12 changes: 1 addition & 11 deletions cli/ctl/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,10 @@ func RegisterGenesisCommand() *cobra.Command {
}
k8sInfo.Flags().StringVarP(&k8sType, "type", "t", "", "k8s info resource type: '*version.Info | *v1.Pod | *v1.ConfigMap | *v1.Namespace | \n*v1.Service | *v1.Deployment | *v1.DaemonSet | *v1.ReplicaSet | *v1beta1.Ingress | \n*v1.CloneSet | *v1.StatefulSet'")

prometheusInfo := &cobra.Command{
Use: "prometheus",
Short: "genesis prometheus info",
Example: "deepflow-ctl genesis prometheus cluster_id",
Run: func(cmd *cobra.Command, args []string) {
prometheusInfo(cmd, args)
},
}

agentInfo := &cobra.Command{
Use: "agent",
Short: "genesis agent info",
Example: "deepflow-ctl genesis agent -i node_ip [host_ip or agent_id]",
Example: "deepflow-ctl genesis agent -i node_ip [agent_id]",
Run: func(cmd *cobra.Command, args []string) {
agentInfo(cmd, args)
},
Expand All @@ -92,7 +83,6 @@ func RegisterGenesisCommand() *cobra.Command {
genesis.AddCommand(syncInfo)
genesis.AddCommand(k8sInfo)
genesis.AddCommand(agentInfo)
genesis.AddCommand(prometheusInfo)
genesis.AddCommand(storageInfo)
return genesis
}
Expand Down
5 changes: 0 additions & 5 deletions message/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,3 @@ message KubernetesAPIInfo {
optional string info = 2;
optional bytes compressed_info = 3;
}

message PrometheusAPIInfo {
optional bytes target_compressed_info = 1;
optional bytes config_compressed_info = 2;
}
12 changes: 0 additions & 12 deletions message/controller.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "common.proto";
service Controller {
rpc GenesisSharingK8S (GenesisSharingK8SRequest) returns (GenesisSharingK8SResponse) {}
rpc GenesisSharingSync (GenesisSharingSyncRequest) returns (GenesisSharingSyncResponse) {}
rpc GenesisSharingPrometheus (GenesisSharingPrometheusRequest) returns (GenesisSharingPrometheusResponse) {}
rpc GetEncryptKey (EncryptKeyRequest) returns (EncryptKeyResponse) {}
rpc GetResourceID (GetResourceIDRequest) returns (GetResourceIDResponse) {}
rpc ReleaseResourceID (ReleaseResourceIDRequest) returns (ReleaseResourceIDResponse) {}
Expand All @@ -26,17 +25,6 @@ message GenesisSharingK8SResponse {
repeated common.KubernetesAPIInfo entries = 3;
}

message GenesisSharingPrometheusRequest {
optional uint32 org_id = 1;
optional string cluster_id = 2;
}

message GenesisSharingPrometheusResponse {
optional string epoch = 1;
optional string error_msg = 2;
optional bytes entries = 3;
}

message GenesisSyncIP {
optional uint32 masklen = 1;
optional string ip = 2;
Expand Down
15 changes: 0 additions & 15 deletions message/trident.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ service Synchronizer {
rpc Query(NtpRequest) returns (NtpResponse) {}
rpc GenesisSync(GenesisSyncRequest) returns (GenesisSyncResponse) {}
rpc KubernetesAPISync(KubernetesAPISyncRequest) returns (KubernetesAPISyncResponse) {}
rpc PrometheusAPISync(PrometheusAPISyncRequest) returns (PrometheusAPISyncResponse) {}
rpc GetKubernetesClusterID(KubernetesClusterIDRequest) returns (KubernetesClusterIDResponse) {}
rpc GPIDSync(GPIDSyncRequest) returns (GPIDSyncResponse) {}
rpc ShareGPIDLocalData(ShareGPIDSyncRequests) returns (ShareGPIDSyncRequests) {}
Expand Down Expand Up @@ -758,20 +757,6 @@ message KubernetesAPISyncResponse {
optional uint64 version = 1;
}

message PrometheusAPISyncRequest {
optional string cluster_id = 1;
optional uint64 version = 2;
optional string error_msg = 3;
optional uint32 vtap_id = 4;
optional string source_ip = 5;
optional string team_id = 6; // agent team identity
repeated common.PrometheusAPIInfo entries = 10;
}

message PrometheusAPISyncResponse {
optional uint64 version = 1;
}

message KubernetesClusterIDRequest {
optional string ca_md5 = 1; // md5 of /run/secrets/[kubernetes.io/serviceaccount/ca.crt
optional string team_id = 2; // agent team identity
Expand Down
1 change: 0 additions & 1 deletion server/controller/cloud/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func (c *Cloud) getKubernetesData() model.Resource {
PodServicePorts: kubernetesGatherResource.PodServicePorts,
PodIngressRules: kubernetesGatherResource.PodIngressRules,
PodIngressRuleBackends: kubernetesGatherResource.PodIngressRuleBackends,
PrometheusTargets: kubernetesGatherResource.PrometheusTargets,
IPs: ips,
VMs: vms,
Regions: regions,
Expand Down
10 changes: 0 additions & 10 deletions server/controller/cloud/kubernetes_gather/kubernetes_gather.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,6 @@ func (k *KubernetesGather) GetKubernetesGatherData() (model.KubernetesGatherReso
}
k.k8sInfo = k8sInfo

prometheusTargets, err := k.getPrometheusTargets()
if err != nil {
return model.KubernetesGatherResource{
ErrorState: common.RESOURCE_STATE_CODE_WARNING,
ErrorMessage: err.Error(),
}, err
}

podCluster, err := k.getPodCluster()
if err != nil {
return model.KubernetesGatherResource{}, err
Expand Down Expand Up @@ -385,10 +377,8 @@ func (k *KubernetesGather) GetKubernetesGatherData() (model.KubernetesGatherReso
PodReplicaSets: replicaSets,
PodGroups: podGroups,
Pods: pods,
PrometheusTargets: prometheusTargets,
}

k.cloudStatsd.RefreshAPIMoniter("PrometheusTarget", len(prometheusTargets), time.Time{})
k.cloudStatsd.ResCount = statsd.GetResCount(resource)
statsd.MetaStatsd.RegisterStatsdTable(k)
return resource, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
. "github.com/smartystreets/goconvey/convey"

cloudconfig "github.com/deepflowio/deepflow/server/controller/cloud/config"
"github.com/deepflowio/deepflow/server/controller/cloud/model"
"github.com/deepflowio/deepflow/server/controller/common"
"github.com/deepflowio/deepflow/server/controller/config"
"github.com/deepflowio/deepflow/server/controller/db/mysql"
Expand Down Expand Up @@ -92,12 +91,6 @@ func TestKubernetes(t *testing.T) {
})
defer vinterfacesInfoPatch.Reset()

pData := []model.PrometheusTarget{}
prometheusTargetInfoPatch := gomonkey.ApplyMethod(reflect.TypeOf(g), "GetPrometheusResponse", func(_ *genesis.Genesis) ([]model.PrometheusTarget, error) {
return pData, nil
})
defer prometheusTargetInfoPatch.Reset()

k8sGatherData, _ := k8s.GetKubernetesGatherData()
Convey("k8sGatherResource number should be equal", func() {
So(len(k8sGatherData.PodNodes), ShouldEqual, 2)
Expand Down
1 change: 0 additions & 1 deletion server/controller/cloud/kubernetes_gather/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ type KubernetesGatherResource struct {
PodSubnets []model.Subnet
PodVInterfaces []model.VInterface
PodIPs []model.IP
PrometheusTargets []model.PrometheusTarget
}

type KubernetesGatherBasicInfo struct {
Expand Down
53 changes: 0 additions & 53 deletions server/controller/cloud/kubernetes_gather/prometheus.go

This file was deleted.

14 changes: 0 additions & 14 deletions server/controller/cloud/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,18 +467,6 @@ type Process struct {
SubDomainLcuuid string `json:"sub_domain_lcuuid"`
}

type PrometheusTarget struct {
Lcuuid string `json:"lcuuid,omitempty" binding:"required"`
ScrapeURL string `json:"scrape_url" binding:"required"`
Instance string `json:"instance" binding:"required"`
Job string `json:"job" binding:"required"`
OtherLabels string `json:"other_labels" binding:"required"`
SubDomainLcuuid string `json:"sub_domain_lcuuid,omitempty"`
PodClusterLcuuid string `json:"pod_cluster_lcuuid" binding:"required"`
VPCLcuuid string `json:"vpc_lcuuid,omitempty"`
HonorLabelsConfig bool `json:"honor_labels_config" binding:"required"`
}

type SubDomainResource struct {
Verified bool `json:"verified"`
ErrorState int
Expand All @@ -502,7 +490,6 @@ type SubDomainResource struct {
PodReplicaSets []PodReplicaSet
Pods []Pod
Processes []Process
PrometheusTargets []PrometheusTarget
}

type Resource struct {
Expand Down Expand Up @@ -551,7 +538,6 @@ type Resource struct {
PodIngressRules []PodIngressRule
PodIngressRuleBackends []PodIngressRuleBackend
Processes []Process
PrometheusTargets []PrometheusTarget
SubDomainResources map[string]SubDomainResource
}

Expand Down
24 changes: 0 additions & 24 deletions server/controller/cloud/sub_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ func (c *Cloud) generateSubDomainResource(lcuuid string, kubernetesGatherResourc
// networks
networks := c.getSubDomainNetworks(lcuuid, &kubernetesGatherResource, azLcuuid)

// prometheusTargets
prometheusTargets := c.getSubDomainPrometheusTargets(lcuuid, &kubernetesGatherResource)

// 生成SubDomainResource
return model.SubDomainResource{
Verified: true,
Expand All @@ -170,7 +167,6 @@ func (c *Cloud) generateSubDomainResource(lcuuid string, kubernetesGatherResourc
Subnets: subnets,
VInterfaces: vinterfaces,
IPs: ips,
PrometheusTargets: prometheusTargets,
}
}

Expand Down Expand Up @@ -878,23 +874,3 @@ func (c *Cloud) getSubDomainNetworks(

return retNetworks
}

func (c *Cloud) getSubDomainPrometheusTargets(
subDomainLcuuid string, resource *kubernetes_model.KubernetesGatherResource) []model.PrometheusTarget {
var retPrometheusTargets []model.PrometheusTarget

// 遍历PrometheusTargets,更新subDomain信息
for _, p := range resource.PrometheusTargets {
retPrometheusTargets = append(retPrometheusTargets, model.PrometheusTarget{
Lcuuid: p.Lcuuid,
ScrapeURL: p.ScrapeURL,
Instance: p.Instance,
Job: p.Job,
OtherLabels: p.OtherLabels,
VPCLcuuid: p.VPCLcuuid,
SubDomainLcuuid: subDomainLcuuid,
})
}

return retPrometheusTargets
}
19 changes: 0 additions & 19 deletions server/controller/genesis/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (

simplejson "github.com/bitly/go-simplejson"
"github.com/op/go-logging"
"gopkg.in/yaml.v3"
"inet.af/netaddr"

"github.com/deepflowio/deepflow/server/controller/common"
Expand Down Expand Up @@ -162,15 +161,6 @@ type XMLVM struct {
Interfaces []XMLInterface
}

type scrapeConfig struct {
JobName string `yaml:"job_name"`
HonorLabels bool `yaml:"honor_labels"`
}

type prometheusConfig struct {
ScrapeConfigs []scrapeConfig `yaml:"scrape_configs"`
}

var IfaceRegex = regexp.MustCompile("^(\\d+):\\s+([^@:]+)(@.*)?\\:")
var MACRegex = regexp.MustCompile("^\\s+link/\\S+\\s+(([\\dA-Za-z]{2}:){5}[\\dA-Za-z]{2}) brd.*$")
var IPRegex = regexp.MustCompile("^\\s+inet6?\\s+([\\d\\.A-Za-z:]+)/(\\d+)\\s+.*scope\\s+(global|link|host)")
Expand Down Expand Up @@ -451,15 +441,6 @@ func ParseVMXml(s, nameField string) ([]XMLVM, error) {
return vms, nil
}

func ParseYMAL(y string) (prometheusConfig, error) {
pConfig := prometheusConfig{}
err := yaml.Unmarshal([]byte(y), &pConfig)
if err != nil {
return prometheusConfig{}, err
}
return pConfig, nil
}

func ParseCompressedInfo(cInfo []byte) (bytes.Buffer, error) {
reader := bytes.NewReader(cInfo)
var out bytes.Buffer
Expand Down
17 changes: 0 additions & 17 deletions server/controller/genesis/datatypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

messagecommon "github.com/deepflowio/deepflow/message/common"
"github.com/deepflowio/deepflow/message/trident"
cloudmodel "github.com/deepflowio/deepflow/server/controller/cloud/model"
"github.com/deepflowio/deepflow/server/controller/common"
"github.com/deepflowio/deepflow/server/controller/db/mysql"
"github.com/deepflowio/deepflow/server/controller/model"
Expand All @@ -48,14 +47,6 @@ type K8SRPCMessage struct {
message *trident.KubernetesAPISyncRequest
}

type PrometheusMessage struct {
orgID int
msgType int
vtapID uint32
peer string
message *trident.PrometheusAPISyncRequest
}

type KubernetesInfo struct {
ORGID int
ClusterID string
Expand All @@ -65,14 +56,6 @@ type KubernetesInfo struct {
Entries []*messagecommon.KubernetesAPIInfo
}

type PrometheusInfo struct {
ORGID int
ClusterID string
ErrorMSG string
Epoch time.Time
Entries []cloudmodel.PrometheusTarget
}

type GenesisSyncData struct {
IPLastSeens map[int][]model.GenesisIP
VIPs map[int][]model.GenesisVIP
Expand Down
Loading

0 comments on commit 36ed4fb

Please sign in to comment.