You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "ranxuxin001 (via GitHub)" <gi...@apache.org> on 2026/04/15 07:46:54 UTC

[I] [Bug] how to define response of Dynamic configuration DCS grpc server [skywalking]

ranxuxin001 opened a new issue, #13823:
URL: https://github.com/apache/skywalking/issues/13823

   ### Search before asking
   
   - [x] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Apache SkyWalking Component
   
   OAP server (apache/skywalking)
   
   ### What happened
   
   Hello,
   
   I also implemented my grpc server which responses the dynamic configuration to skywalking oap. But oap log shows it calls callgroup function successfully. But my agent plugin configuration didn't change. Is my response data structure wrong?
   
   my server responses data structure:
   
   pb.GroupConfigurationResponse{
   GroupConfigTable: []*pb.GroupConfigItems{groupItems},
   Uuid: s.currentGroupUUID,
   }
   
   groupItems := &pb.GroupConfigItems{
   GroupName: "configuration-discovery.default.agentConfigurations",
   }
   
   groupItems.Items = append(groupItems.Items, &pb.Config{
   Name: "customerAPI-v1",
   Value: s.groupConfig,
   })
   
   s.groupConfig := configurations: qewqw-test::myapmmysqlservice: agent.sample_n_per_3_secs: 1
   
   data structure of official web:
   groupConfigTable {
   groupName: "core.default.endpoint-name-grouping-openapi"
   items {
   name: "customerAPI-v1"
   value: "value of customerAPI-v1"
   }
   items {
   name: "productAPI-v1"
   value: "value of productAPI-v1"
   }
   items {
   name: "productAPI-v2"
   value: "value of productAPI-v2"
   }
   }
   
   ### What you expected to happen
   
   oap should parse my dynamic configuration responsed from my grpc server. And acknowledge to agent server. 
   
   ### How to reproduce
   
   my grpc server codes:
   
   
   
   package main
   
   import (
   	"context"
   	"crypto/sha512"
   	"encoding/hex"
   	"flag"
   	"fmt"
   	"log"
   	"net"
   	"sync"
   
   	"google.golang.org/grpc"
   
   	pb "skywalking-grpc-config-server/proto"
   )
   
   const agentConfigurationYAML = `
   configurations:
     qewqw-test::myapmmysqlservice:
       agent.sample_n_per_3_secs: 1
   `
   
   func generateUUID(content string) string {
   	if content == "" {
   		content = "EMPTY"
   	}
   	hash := sha512.Sum512([]byte(content))
   	return hex.EncodeToString(hash[:])
   }
   
   type configServer struct {
   	pb.UnimplementedConfigurationServiceServer
   	mu               sync.RWMutex
   	groupConfig      string // 存储完整 YAML
   	currentGroupUUID string // 配置UUID(内容哈希)
   }
   
   func newConfigServer() *configServer {
   	s := &configServer{}
   	// 直接使用标准格式的 YAML
   	s.groupConfig = agentConfigurationYAML
   	// 根据 YAML 内容生成 UUID
   	//s.currentGroupUUID = generateUUID(s.groupConfig)
   	s.currentGroupUUID = "e27dc5ec4a198d80c101b634149023c92d071c7fc5262e92e923d42bf9bf0acb068fcfcf5be7a7375be9126916cb116bd4328fb152dd87c4390a2d9529f2d696"
   	return s
   }
   
   func (s *configServer) Call(ctx context.Context, req *pb.ConfigurationRequest) (*pb.ConfigurationResponse, error) {
   	// 直接返回一个有 Uuid 的合法响应
   	return &pb.ConfigurationResponse{Uuid: ""}, nil
   }
   
   func (s *configServer) CallGroup(
   	ctx context.Context,
   	req *pb.ConfigurationRequest,
   ) (*pb.GroupConfigurationResponse, error) {
   	log.Printf("OAP 拉取分组配置 | cluster=%s | clientUUID=%s | serverUUID=%s",
   		req.ClusterName, req.Uuid, s.currentGroupUUID)
   
   	// UUID 一致 → 告诉 OAP 配置无变化
   	if req.Uuid != "" && req.Uuid == s.currentGroupUUID {
   		return &pb.GroupConfigurationResponse{
   			Uuid: s.currentGroupUUID,
   		}, nil
   	}
   
   	log.Printf("request uuid is not equal to current uuid. %s    %s", req.Uuid, s.currentGroupUUID)
   	// 构造协议要求的 Group 配置结构
   	groupItems := &pb.GroupConfigItems{
   		GroupName: "configuration-discovery.default.agentConfigurations",
   	}
   
   	// 关键:把完整 YAML 塞进 key = configurations
   	groupItems.Items = append(groupItems.Items, &pb.Config{
   		Name:  "customerAPI-v1",
   		Value: s.groupConfig,
   	})
   
   	out := &pb.GroupConfigurationResponse{
   		GroupConfigTable: []*pb.GroupConfigItems{groupItems},
   		Uuid:             s.currentGroupUUID,
   	}
   
   	log.Printf("will send group configuration to oap: %v %s", out.GroupConfigTable, out.Uuid)
   	return out, nil
   }
   
   func main() {
   	port := flag.Int("port", 18080, "gRPC 端口")
   	flag.Parse()
   
   	lis, err := net.Listen("tcp", "0.0.0.0:"+fmt.Sprint(*port))
   	if err != nil {
   		log.Fatal(err)
   	}
   
   	grpcServer := grpc.NewServer()
   	pb.RegisterConfigurationServiceServer(grpcServer, newConfigServer())
   
   	log.Printf("✅ SkyWalking Go gRPC 配置服务启动,端口:%d", *port)
   	log.Fatal(grpcServer.Serve(lis))
   }
   
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [x] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] how to define response of Dynamic configuration DCS grpc server [skywalking]

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng closed issue #13823: [Bug] how to define response of Dynamic configuration DCS grpc server
URL: https://github.com/apache/skywalking/issues/13823


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] how to define response of Dynamic configuration DCS grpc server [skywalking]

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on issue #13823:
URL: https://github.com/apache/skywalking/issues/13823#issuecomment-4251776941

   https://github.com/apache/skywalking/discussions/12577#discussioncomment-16568783 replied. And we require EN on Github. Chinese discussion should go to slack channels.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org