pipecd icon indicating copy to clipboard operation
pipecd copied to clipboard

Including more precise deployment timestamps in webhook

Open ren510dev opened this issue 2 years ago • 2 comments

What would you like to be added:

Including in PipeCD webhook the timestamp when an existing resource was changed by piped.

Specifically, PipeCD gets the deployment status by reportDeploymentCompleted. At this time, a timestamp (CompletedAt) of when the status was obtained is included in PipeCD webhook.

We can know precisely the timing of the deployment by obtaining the timestamp when receiving the apply result of the manifests.

Why is this needed:

PipeCD includes the deployment start time in CreatedAt, overwrites the status (triggered:0 -> planned:1 -> success:4 / failed:5), updates UpdatedAt, and includes it in PipeCD webhook. However, the UpdatedAt is not an actual deploy completed timestamp because it includes the time when PipeCD C-Plane updated the database status.

I confirmed a time difference of about 20-40s between the timestamp notified by PipeCD webhook and the timestamp displayed in the WebUI logs.

e.g.

{
  "Type": 4,
  "Metadata": {
    "deployment":
      ...
      ...
      "status_reason": "The deployment has been planned",
      "created_at": 1691115188,// 2023-08-04 11:13:08 // deploy started
      "updated_at": 1691115209 // 2023-08-04 11:13:29 // received a success status
    }
  }
}

webui-log

  • deployment_created_at: 2023-08-04 11:13:08
  • deployment.updated_at: 2023-08-04 11:13:29 <- 20s ~ 40s faster than successfully log

The actual time of successful applied the manifest was 11:13:54. It should be after 11:13:54 that the success status can be included in PipeCD webhook.

ren510dev avatar Sep 01 '23 05:09 ren510dev

@GotoRen I'm Not sure if I missed something, but I think there is a miss here. Across the issue description, the updated_at timestamp is for status reason "status_reason": "The deployment has been planned", while the stage log highlighted in the picture shows a message that it's manifests applied.

I think those timestamps are different because they're totally different events at first, aren't they?

khanhtc1202 avatar Sep 04 '23 04:09 khanhtc1202

@khanhtc1202

Sorry for replying so late.

PipeCD Webhook seems to include the message "The deployment has been planned" in the status_reason, even in the notification of a successful deployment (application of manifest).

I have prepared a webhook receiving server and verified it multiple times!

The data and image shown in the code block are the same event.

Indeed, when Type: 4 (DEPLOYMENT_SUCCEEDED), "The deployment has been planned" is included in the status_reason.

I think the message "The deployment was completed successfully" should be included. [ref]

Is it possible that PipeCD is including the wrong message in the status_reason?

FYI: the messages included in each event.

Type Metadata.deployment.status_reason
0 (triggered) The deployment is waiting to be planned
1 (planned) The deployment is waiting to be planned
4 (succeeded) The deployment has been planned

ren510dev avatar Sep 10 '23 06:09 ren510dev

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Mar 09 '24 00:03 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity. Feel free to reopen if still applicable.

github-actions[bot] avatar Mar 16 '24 00:03 github-actions[bot]