Skip to content

Commit

Permalink
self review PR
Browse files Browse the repository at this point in the history
  • Loading branch information
miguel-crespo-fdc committed Oct 14, 2024
1 parent a42bc74 commit 5f2773e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
3 changes: 1 addition & 2 deletions pkg/api/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,7 @@ service EnvironmentService {
message GetChangedAppsRequest {}

message GetChangedAppsResponse {
repeated string full_list_apps = 1;
repeated string changed_apps = 2;
repeated string changed_apps = 1;
}

message GetAppDetailsRequest {
Expand Down
10 changes: 2 additions & 8 deletions services/cd-service/pkg/service/overview.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ func (o *OverviewServiceServer) StreamOverview(in *api.GetOverviewRequest,
return nil
case <-ch:
ov := o.response.Load().(*api.GetOverviewResponse)
//o.changedApps.Load()
if err := stream.Send(ov); err != nil {
// if we don't log this here, the details will be lost - so this is an exception to the rule "either return an error or log it".
// for example if there's an invalid encoding, grpc will just give a generic error like
Expand All @@ -364,16 +363,11 @@ func (o *OverviewServiceServer) StreamChangedApps(in *api.GetChangedAppsRequest,
return nil
case changedApps := <-ch:
ov := &api.GetChangedAppsResponse{
ChangedApps: changedApps,
FullListApps: []string{},
ChangedApps: changedApps,
}
logger.FromContext(stream.Context()).Sugar().Infof("Got changes apps: '%v'\n", changedApps)
if err := stream.Send(ov); err != nil {
// if we don't log this here, the details will be lost - so this is an exception to the rule "either return an error or log it".
// for example if there's an invalid encoding, grpc will just give a generic error like
// "error while marshaling: string field contains invalid UTF-8"
// but it won't tell us which field has the issue. This is then very hard to debug further.
logger.FromContext(stream.Context()).Error("error sending overview response:", zap.Error(err), zap.String("overview", fmt.Sprintf("%+v", ov)))
logger.FromContext(stream.Context()).Error("error sending changed apps response:", zap.Error(err), zap.String("changedApps", fmt.Sprintf("%+v", ov)))
return err
}

Expand Down
4 changes: 2 additions & 2 deletions services/rollout-service/pkg/argo/argo.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func (a *ArgoAppProcessor) Consume(ctx context.Context, hlth *setup.HealthReport
}

type ArgoOverview struct {
AppDetails map[string]*api.GetAppDetailsResponse
Overview *api.GetOverviewResponse
AppDetails map[string]*api.GetAppDetailsResponse //Map from appName to app Details. Gets filled with information based on what apps have changed.
Overview *api.GetOverviewResponse //Standard overview. Only information regarding environments should be retrieved from this overview.
}

func (a *ArgoAppProcessor) CreateOrUpdateApp(ctx context.Context, overview *api.GetOverviewResponse, appName, team string, env *api.Environment, appsKnownToArgo map[string]*v1alpha1.Application) {
Expand Down
2 changes: 2 additions & 0 deletions services/rollout-service/pkg/versions/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,8 @@ func assertStep(t *testing.T, i int, s step, vp *mockVersionEventProcessor, hs *
if hs.IsReady("versions") != s.ExpectReady {
t.Errorf("wrong readyness in step %d, expected %t but got %t", i, s.ExpectReady, hs.IsReady("versions"))
}

//Sort this to avoid flakeyness based on order
sort.Slice(vp.events, func(i, j int) bool {
return vp.events[i].Environment < vp.events[j].Environment
})
Expand Down

0 comments on commit 5f2773e

Please sign in to comment.