Skip to content

Commit eae72ac

Browse files
committed
Move MTC validation to GKE orchestrator
1 parent f45c6aa commit eae72ac

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

cmd/job/submit.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ func validateGKENAPFlags() error {
380380
if gkeNapProvisioning != "reservation" && gkeNapReservation != "" {
381381
return fmt.Errorf("--gke-nap-reservation should only be provided when --gke-nap-provisioning=reservation")
382382
}
383+
384+
if pathways.MTCEnabled {
385+
// MTC Addon validation is now handled by the GKE Orchestrator preflight checks.
386+
}
387+
383388
return nil
384389
}
385390

pkg/orchestrator/gke/gke_job_orchestrator.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import (
3232
"strings"
3333
"time"
3434

35+
container "google.golang.org/api/container/v1"
36+
3537
"github.com/google/safetext/yamltemplate"
3638

3739
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -97,6 +99,12 @@ func (g *GKEOrchestrator) SubmitJob(job orchestrator.JobDefinition) error {
9799
return err
98100
}
99101

102+
if job.Pathways.MTCEnabled {
103+
if err := g.checkMTCAddonEnabled(job.ProjectID, job.ClusterLocation, job.ClusterName); err != nil {
104+
return err
105+
}
106+
}
107+
100108
if err := g.fetchClusterState(&job); err != nil {
101109
return err
102110
}
@@ -133,6 +141,25 @@ func (g *GKEOrchestrator) SubmitJob(job orchestrator.JobDefinition) error {
133141
return nil
134142
}
135143

144+
func (g *GKEOrchestrator) checkMTCAddonEnabled(projectID, location, clusterName string) error {
145+
ctx := context.Background()
146+
svc, err := container.NewService(ctx)
147+
if err != nil {
148+
return fmt.Errorf("failed to create cluster manager client: %v", err)
149+
}
150+
151+
name := fmt.Sprintf("projects/%s/locations/%s/clusters/%s", projectID, location, clusterName)
152+
resp, err := svc.Projects.Locations.Clusters.Get(name).Context(ctx).Do()
153+
if err != nil {
154+
return fmt.Errorf("failed to get cluster details for MTC validation: %v", err)
155+
}
156+
157+
if resp.AddonsConfig == nil || resp.AddonsConfig.HighScaleCheckpointingConfig == nil || !resp.AddonsConfig.HighScaleCheckpointingConfig.Enabled {
158+
return fmt.Errorf("Multi-Tier Checkpointing (MTC) requires the HighScaleCheckpointing addon to be enabled on the target GKE cluster. Please update your cluster blueprint to set 'enable_multi_tier_checkpointing: true' and deploy the cluster before submitting jobs with --pathways-mtc-enabled")
159+
}
160+
return nil
161+
}
162+
136163
// ListJobs retrieves a list of jobs in the GKE cluster.
137164
// It filters jobs based on the provided ListOptions.
138165
func (g *GKEOrchestrator) ListJobs(opts orchestrator.ListOptions) ([]orchestrator.JobStatus, error) {

0 commit comments

Comments
 (0)