Skip to content

Commit

Permalink
Refresh properties before reconcile and profile init (#4332)
Browse files Browse the repository at this point in the history
Refreshing the repositories ensures that when the requests get to the
executor, the properties will have been fetched.

Related: #4173
  • Loading branch information
jhrozek authored Aug 30, 2024
1 parent d3523eb commit f6e1b9b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions internal/reconcilers/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/stacklok/minder/internal/providers/github"
"github.com/stacklok/minder/internal/reconcilers/messages"
"github.com/stacklok/minder/internal/repositories"
ghreposvc "github.com/stacklok/minder/internal/repositories/github"
"github.com/stacklok/minder/internal/verifier/verifyif"
pb "github.com/stacklok/minder/pkg/api/protobuf/go/minder/v1"
v1 "github.com/stacklok/minder/pkg/providers/v1"
Expand Down Expand Up @@ -75,6 +76,14 @@ func (r *Reconciler) handleArtifactsReconcilerEvent(ctx context.Context, evt *me
return fmt.Errorf("error instantiating provider: %w", err)
}

_, err = r.repos.RefreshRepositoryByUpstreamID(ctx, repository.RepoID)
if errors.Is(err, v1.ErrEntityNotFound) || errors.Is(err, ghreposvc.ErrRepoNotFound) {
zerolog.Ctx(ctx).Debug().Err(err).Str("repository", repository.ID.String()).Msg("repository not found")
} else if err != nil {
zerolog.Ctx(ctx).Debug().Err(err).Str("repository", repository.ID.String()).Msg("error refreshing repository")
return fmt.Errorf("error refreshing repository: %w", err)
}

cli, err := v1.As[v1.GitHub](p)
if err != nil {
// Keeping this behaviour to match the existing logic
Expand Down
8 changes: 7 additions & 1 deletion internal/reconcilers/run_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,15 @@ func (r *Reconciler) publishProfileInitEvents(
}

for _, dbrepo := range dbrepos {
_, err := r.repos.RefreshRepositoryByUpstreamID(ctx, dbrepo.RepoID)
if err != nil {
zerolog.Ctx(ctx).Debug().Err(err).Str("repository", dbrepo.ID.String()).Msg("error refreshing repository")
continue
}

// protobufs are our API, so we always execute on these instead of the DB directly.
repo := repositories.PBRepositoryFromDB(dbrepo)
err := entities.NewEntityInfoWrapper().
err = entities.NewEntityInfoWrapper().
WithProviderID(dbrepo.ProviderID).
WithProjectID(projectID).
WithRepository(repo).
Expand Down

0 comments on commit f6e1b9b

Please sign in to comment.