Skip to content

Commit

Permalink
add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
christeredvartsen committed Feb 16, 2024
1 parent fbb4e19 commit f4c03a2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/reconcilers/google/gcp/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,22 @@ func (r *googleGcpReconciler) Name() string {

func (r *googleGcpReconciler) Reconcile(ctx context.Context, client *apiclient.APIClient, naisTeam *protoapi.Team, log logrus.FieldLogger) error {
if len(r.clusters) == 0 {
log.Debugf("no active environments, skipping reconcile")
return nil
}

if naisTeam.GoogleGroupEmail == nil {
return fmt.Errorf("no Google Workspace group exists for team %q yet", naisTeam.Slug)
}

it := iterator.New[*protoapi.TeamEnvironment](ctx, 100, func(limit, offset int64) (*protoapi.ListTeamEnvironmentsResponse, error) {
it := iterator.New(ctx, 100, func(limit, offset int64) (*protoapi.ListTeamEnvironmentsResponse, error) {
return client.Teams().Environments(ctx, &protoapi.ListTeamEnvironmentsRequest{Limit: limit, Offset: offset, Slug: naisTeam.Slug})
})

for it.Next() {
env := it.Value()
if !env.Gcp {
log.WithField("environment", env.EnvironmentName).Debug("environment is not a GCP environment, skipping")
continue
}

Expand All @@ -135,6 +137,7 @@ func (r *googleGcpReconciler) Reconcile(ctx context.Context, client *apiclient.A
}

projectID := GenerateProjectID(r.tenantDomain, env.EnvironmentName, naisTeam.Slug)
log.WithField("project_id", projectID).Debugf("generated GCP project ID")
teamProject, err := r.getOrCreateProject(ctx, client, projectID, env, cluster.TeamsFolderID, naisTeam)
if err != nil {
return fmt.Errorf("get or create a GCP project %q for team %q in environment %q: %w", projectID, naisTeam.Slug, env.EnvironmentName, err)
Expand Down Expand Up @@ -188,7 +191,7 @@ func (r *googleGcpReconciler) Reconcile(ctx context.Context, client *apiclient.A
func (r *googleGcpReconciler) Delete(ctx context.Context, client *apiclient.APIClient, naisTeam *protoapi.Team, log logrus.FieldLogger) error {
var errors []error

it := iterator.New[*protoapi.TeamEnvironment, *protoapi.ListTeamEnvironmentsResponse](ctx, 100, func(limit, offset int64) (*protoapi.ListTeamEnvironmentsResponse, error) {
it := iterator.New(ctx, 100, func(limit, offset int64) (*protoapi.ListTeamEnvironmentsResponse, error) {
return client.Teams().Environments(ctx, &protoapi.ListTeamEnvironmentsRequest{Limit: limit, Offset: offset, Slug: naisTeam.Slug})
})

Expand Down

0 comments on commit f4c03a2

Please sign in to comment.