Skip to content

Commit

Permalink
chore(tibuild): add debug log (#224)
Browse files Browse the repository at this point in the history
Signed-off-by: wuhuizuo <[email protected]>
  • Loading branch information
wuhuizuo committed Jan 29, 2025
1 parent 8a17a7b commit 54be63d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tibuild/pkg/rest/service/cloud_event_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package service

import (
"context"
"encoding/json"
"fmt"
"log/slog"
"strings"
Expand Down Expand Up @@ -38,10 +39,14 @@ type CloudEventClient struct {
}

func (s CloudEventClient) TriggerDevBuild(ctx context.Context, dev DevBuild) error {
bs, _ := json.Marshal(dev)
slog.InfoContext(ctx, "trigger dev build", "dev", string(bs))
event, err := newDevBuildCloudEvent(dev)
if err != nil {
return err
}
eventBytes, _ := event.MarshalJSON()
slog.InfoContext(ctx, "trigger dev build event", "event", string(eventBytes))
c := cloudevents.ContextWithTarget(ctx, s.endpoint)
if result := s.client.Send(c, *event); !protocol.IsACK(result) {
slog.ErrorContext(ctx, "failed to send", "reason", result)
Expand Down Expand Up @@ -78,7 +83,7 @@ func newDevBuildCloudEvent(dev DevBuild) (*cloudevents.Event, error) {
event.SetSubject(fmt.Sprint(dev.ID))
event.SetSource("tibuild.pingcap.net/api/devbuilds/" + fmt.Sprint(dev.ID))
event.SetExtension("user", dev.Meta.CreatedBy)
event.SetExtension("paramProfile", dev.Spec.Edition)
event.SetExtension("paramProfile", string(dev.Spec.Edition))
if dev.Spec.BuilderImg != "" {
event.SetExtension("paramBuilderImage", dev.Spec.BuilderImg)
}
Expand Down

0 comments on commit 54be63d

Please sign in to comment.