-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create and add deployment trace obj to datastore on event registering flow #5622
base: master
Are you sure you want to change the base?
Conversation
… flow Signed-off-by: khanhtc1202 <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5622 +/- ##
==========================================
- Coverage 26.56% 26.54% -0.02%
==========================================
Files 475 477 +2
Lines 50582 50658 +76
==========================================
+ Hits 13438 13449 +11
- Misses 36081 36146 +65
Partials 1063 1063 ☔ View full report in Codecov by Sentry. |
@@ -103,3 +103,16 @@ CREATE TABLE IF NOT EXISTS DeploymentChain ( | |||
CreatedAt INT(11) GENERATED ALWAYS AS (data->>"$.created_at") STORED NOT NULL, | |||
UpdatedAt INT(11) GENERATED ALWAYS AS (data->>"$.updated_at") STORED NOT NULL | |||
) ENGINE=InnoDB; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is enable using MySQL as the datastore of ControlPlane; each time we have a new objStore (DeploymentTraceStore at this time), we need to create a new table in MySQL schema.
type deploymentTraceCollection struct { | ||
requestedBy Commander | ||
} | ||
|
||
func (d *deploymentTraceCollection) Kind() string { | ||
return "DeploymentTrace" | ||
} | ||
|
||
func (d *deploymentTraceCollection) Factory() Factory { | ||
return func() interface{} { | ||
return &model.DeploymentTrace{} | ||
} | ||
} | ||
|
||
func (d *deploymentTraceCollection) ListInUsedShards() []Shard { | ||
return []Shard{ | ||
AgentShard, | ||
} | ||
} | ||
|
||
func (d *deploymentTraceCollection) GetUpdatableShard() (Shard, error) { | ||
switch d.requestedBy { | ||
case PipedCommander: | ||
return AgentShard, nil | ||
default: | ||
return "", ErrUnsupported | ||
} | ||
} | ||
|
||
func (d *deploymentTraceCollection) Encode(entity interface{}) (map[Shard][]byte, error) { | ||
const errFmt = "failed while encode Deployment Trace object: %s" | ||
|
||
me, ok := entity.(*model.DeploymentTrace) | ||
if !ok { | ||
return nil, fmt.Errorf(errFmt, "type not matched") | ||
} | ||
|
||
data, err := json.Marshal(me) | ||
if err != nil { | ||
return nil, fmt.Errorf(errFmt, "unable to marshal entity data") | ||
} | ||
return map[Shard][]byte{ | ||
AgentShard: data, | ||
}, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is to enable support filedb as db of the pipecd. I'm thinking about deprecated this filedb feature since we're not actively maintaining these parts. Let's ignore this while reviewing this PR 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I wanna ask you two small points
string commit_message = 3; | ||
string commit_hash = 4 [(validate.rules).string.min_len = 1]; | ||
string commit_url = 5 [(validate.rules).string.min_len = 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ASK] What does this change for? It seems all the fields have not changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just rearrangement 👀
pkg/app/server/grpcapi/api.go
Outdated
if req.CommitTitle != "" { | ||
trace.Title = req.CommitTitle | ||
} | ||
if req.CommitMessage != "" { | ||
trace.CommitMessage = req.CommitMessage | ||
} | ||
if req.CommitAuthor != "" { | ||
trace.Author = req.CommitAuthor | ||
} | ||
if req.CommitTimestamp != 0 { | ||
trace.CommitTimestamp = req.CommitTimestamp | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ask] Are these empty checks required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, we don't need that. Let's me update 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated by 884e1e6 👍
Signed-off-by: khanhtc1202 <[email protected]>
What this PR does:
as title
Why we need it:
While registering an event by pipette, we will create a DeploymentTrace object and store it in the datastore. The stored DeploymentTrace object contains information about the commit that triggered the event, which will be used in the DeploymentTrace feature UI.
Also, I updated the Event model to store trigger_commit_hash, which is the commit hash of the commit that triggers this event. This information will be used while handling the event (EventWatcher handling flow)
Which issue(s) this PR fixes:
Part of #5444
Does this PR introduce a user-facing change?: