Skip to content

Commit

Permalink
keep the spec to the status event when a resource is deleted
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Liu <[email protected]>
  • Loading branch information
skeeey committed Dec 9, 2024
1 parent 3a56948 commit a6a7bab
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/maestro/server/pulse_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,10 @@ func (s *PulseServer) OnStatusUpdate(ctx context.Context, eventID, resourceID st
Meta: api.Meta{
ID: resourceID,
},
Source: statusEvent.ResourceSource,
Type: statusEvent.ResourceType,
Status: statusEvent.Status,
Source: statusEvent.ResourceSource,
Type: statusEvent.ResourceType,
Payload: statusEvent.Payload,
Status: statusEvent.Status,
}
} else {
resource, sErr = s.resourceService.Get(ctx, resourceID)
Expand Down Expand Up @@ -317,6 +318,7 @@ func handleStatusUpdate(ctx context.Context, resource *api.Resource, resourceSer
ResourceID: resource.ID,
ResourceSource: resource.Source,
ResourceType: resource.Type,
Payload: found.Payload,
Status: resource.Status,
StatusEventType: api.StatusDeleteEventType,
})
Expand Down
1 change: 1 addition & 0 deletions pkg/api/status_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type StatusEvent struct {
ResourceID string
ResourceSource string
ResourceType ResourceType
Payload datatypes.JSONMap
Status datatypes.JSONMap
StatusEventType StatusEventType // Update|Delete
ReconciledDate *time.Time `json:"gorm:null"`
Expand Down
1 change: 1 addition & 0 deletions pkg/db/migrations/202406241426_add_status_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func addStatusEvents() *gormigrate.Migration {
ResourceID string `gorm:"index"` // resource id
ResourceSource string
ResourceType string
Payload datatypes.JSON `gorm:"type:json"`
Status datatypes.JSON `gorm:"type:json"`
StatusEventType string // Update|Delete, any string
ReconciledDate *time.Time `gorm:"null;index"`
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/pkg/sourceclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,10 @@ func AssertWatchResult(result *WatchedResult) error {
hasDeletedWork := false

for _, watchedWork := range result.WatchedWorks {
if len(watchedWork.Spec.Workload.Manifests) == 0 {
return fmt.Errorf("expected the watched work has spec, but failed")
}

if strings.HasPrefix(watchedWork.Name, "init-work-a") && !watchedWork.CreationTimestamp.IsZero() {
hasFirstInitWork = true
}
Expand Down

0 comments on commit a6a7bab

Please sign in to comment.