Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion platformd/checkpoint/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (s *ServiceImpl) podConfig(id string) *runtimev1.PodSandboxConfig {
func (s *ServiceImpl) ctrConfig(checkID string, baseImgURL string) *runtimev1.ContainerConfig {
return &runtimev1.ContainerConfig{
Metadata: &runtimev1.ContainerMetadata{
Name: "payload",
Name: "payload_" + checkID,
},
Image: &runtimev1.ImageSpec{
UserSpecifiedImage: baseImgURL,
Expand Down
26 changes: 13 additions & 13 deletions platformd/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"log/slog"
"maps"
"strconv"
"sync"
"time"

instancev1alpha1 "github.com/spacechunks/explorer/api/instance/v1alpha1"
Expand Down Expand Up @@ -139,10 +140,18 @@ func (r *reconciler) tick(ctx context.Context) {
return
}

var wg sync.WaitGroup

for _, ins := range discResp.Instances {
go r.reconcile(ctx, ins)
wg.Add(1)
go func() {
r.reconcile(ctx, ins)
wg.Done()
}()
}

wg.Wait()

var (
statuses = r.store.View()
items = make([]*instancev1alpha1.InstanceStatusReport, 0, len(statuses))
Expand Down Expand Up @@ -238,14 +247,12 @@ func (r *reconciler) reconcile(ctx context.Context, ins *instancev1alpha1.Instan
}
}

func (r *reconciler) handleInstanceCreation(ctx context.Context, instance *instancev1alpha1.Instance) error {
func (r *reconciler) handleInstanceCreation(ctx context.Context, instance *instancev1alpha1.Instance) (reterr error) {
var (
id = instance.GetId()
attempt = r.attempts[id]
)

r.logger.InfoContext(ctx, "handling pending instance", "instance_id", id, "attempt", attempt)

// if the instance is not in state CREATING, skip it.
// this check is necessary, because it can happen that we
// receive an instance that is still in PENDING state from the
Expand All @@ -256,18 +263,11 @@ func (r *reconciler) handleInstanceCreation(ctx context.Context, instance *insta
if st := r.store.Get(id); st != nil &&
st.WorkloadStatus != nil &&
st.WorkloadStatus.State != status.WorkloadStateCreating {
r.logger.InfoContext(ctx, "skip", "instance_id", id)
r.logger.InfoContext(ctx, "instance currently creating, skip", "instance_id", id)
return nil
}

if attempt >= r.cfg.MaxAttempts {
r.store.Update(id, status.Status{
WorkloadStatus: &status.WorkloadStatus{
State: status.WorkloadStateCreationFailed,
},
})
return errMaxAttemptsReached
}
r.logger.InfoContext(ctx, "handling pending instance", "instance_id", id, "attempt", attempt)

attempt++

Expand Down
Loading