Skip to content

Commit 8c376a3

Browse files
committed
mantle/platform/gcloud: fix confidential compute check
In db803c3 we add support for ConfidentialType but we made it so that we always execute this code where we don't want to do that if the user didn't specify any ConfidentialType for GCP. The way the code is now we can't run any GCP tests on non confidential instances. ``` failed to create instance "kola-dd144aac7413f66c85e9": Does not support confidential type , should be: sev, sev_snp ```
1 parent c211431 commit 8c376a3

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

mantle/platform/api/gcloud/compute.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,20 @@ func (a *API) mkinstance(userdata, name string, keys []*agent.Key, opts platform
147147
})
148148
}
149149
// create confidential instance
150-
ConfidentialType := strings.ToUpper(a.options.ConfidentialType)
151-
ConfidentialType = strings.Replace(ConfidentialType, "-", "_", -1)
152-
if ConfidentialType == "SEV" || ConfidentialType == "SEV_SNP" {
153-
fmt.Printf("Using confidential type for confidential computing %s\n", ConfidentialType)
154-
instance.ConfidentialInstanceConfig = &compute.ConfidentialInstanceConfig{
155-
ConfidentialInstanceType: ConfidentialType,
156-
}
157-
instance.Scheduling = &compute.Scheduling{
158-
OnHostMaintenance: "TERMINATE",
150+
if a.options.ConfidentialType != "" {
151+
ConfidentialType := strings.ToUpper(a.options.ConfidentialType)
152+
ConfidentialType = strings.Replace(ConfidentialType, "-", "_", -1)
153+
if ConfidentialType == "SEV" || ConfidentialType == "SEV_SNP" {
154+
fmt.Printf("Using confidential type for confidential computing %s\n", ConfidentialType)
155+
instance.ConfidentialInstanceConfig = &compute.ConfidentialInstanceConfig{
156+
ConfidentialInstanceType: ConfidentialType,
157+
}
158+
instance.Scheduling = &compute.Scheduling{
159+
OnHostMaintenance: "TERMINATE",
160+
}
161+
} else {
162+
return nil, fmt.Errorf("Does not support confidential type %s, should be: sev, sev_snp\n", a.options.ConfidentialType)
159163
}
160-
} else {
161-
return nil, fmt.Errorf("Does not support confidential type %s, should be: sev, sev_snp\n", a.options.ConfidentialType)
162164
}
163165
// attach aditional disk
164166
for _, spec := range opts.AdditionalDisks {

0 commit comments

Comments
 (0)