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
4 changes: 0 additions & 4 deletions mantle/cmd/kola/kola.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ package main
import (
"encoding/json"
"fmt"
"math/rand"
"net/http"
"os"
"path/filepath"
"regexp"
"sort"
"strings"
"text/tabwriter"
"time"

"github.com/coreos/pkg/capnslog"
"github.com/pkg/errors"
Expand Down Expand Up @@ -160,8 +158,6 @@ func init() {
}

func main() {
// initialize global state
rand.Seed(time.Now().UnixNano())
cli.Execute(root)
}

Expand Down
9 changes: 7 additions & 2 deletions mantle/platform/api/azure/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package azure

import (
"crypto/rand"
"fmt"
"math/rand"
"os"
"strings"
"time"
Expand All @@ -27,10 +27,13 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
"github.com/coreos/pkg/capnslog"

"github.com/coreos/coreos-assembler/mantle/auth"
)

var plog = capnslog.NewPackageLogger("github.com/coreos/coreos-assembler/mantle", "platform/api/azure")

type API struct {
azIdCred *azidentity.DefaultAzureCredential
rgClient *armresources.ResourceGroupsClient
Expand Down Expand Up @@ -116,7 +119,9 @@ func (a *API) SetupClients() error {

func randomName(prefix string) string {
b := make([]byte, 5)
rand.Read(b)
if _, err := rand.Read(b); err != nil {
plog.Errorf("randomName: failed to generate a random name: %v", err)
}
return fmt.Sprintf("%s-%x", prefix, b)
}

Expand Down
24 changes: 13 additions & 11 deletions mantle/platform/api/gcloud/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,20 @@ func (a *API) mkinstance(userdata, name string, keys []*agent.Key, opts platform
})
}
// create confidential instance
ConfidentialType := strings.ToUpper(a.options.ConfidentialType)
ConfidentialType = strings.Replace(ConfidentialType, "-", "_", -1)
if ConfidentialType == "SEV" || ConfidentialType == "SEV_SNP" {
fmt.Printf("Using confidential type for confidential computing %s\n", ConfidentialType)
instance.ConfidentialInstanceConfig = &compute.ConfidentialInstanceConfig{
ConfidentialInstanceType: ConfidentialType,
}
instance.Scheduling = &compute.Scheduling{
OnHostMaintenance: "TERMINATE",
if a.options.ConfidentialType != "" {
ConfidentialType := strings.ToUpper(a.options.ConfidentialType)
ConfidentialType = strings.Replace(ConfidentialType, "-", "_", -1)
if ConfidentialType == "SEV" || ConfidentialType == "SEV_SNP" {
fmt.Printf("Using confidential type for confidential computing %s\n", ConfidentialType)
instance.ConfidentialInstanceConfig = &compute.ConfidentialInstanceConfig{
ConfidentialInstanceType: ConfidentialType,
}
instance.Scheduling = &compute.Scheduling{
OnHostMaintenance: "TERMINATE",
}
} else {
return nil, fmt.Errorf("Does not support confidential type %s, should be: sev, sev_snp\n", a.options.ConfidentialType)
}
} else {
return nil, fmt.Errorf("Does not support confidential type %s, should be: sev, sev_snp\n", a.options.ConfidentialType)
}
// attach aditional disk
for _, spec := range opts.AdditionalDisks {
Expand Down
6 changes: 4 additions & 2 deletions mantle/platform/machine/azure/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package azure

import (
"crypto/rand"
"errors"
"fmt"
"math/rand"
"os"
"path/filepath"

Expand All @@ -35,7 +35,9 @@ type cluster struct {

func (ac *cluster) vmname() string {
b := make([]byte, 5)
rand.Read(b)
if _, err := rand.Read(b); err != nil {
plog.Errorf("failed to generate a random vmname: %v", err)
}
return fmt.Sprintf("%s-%x", ac.Name()[0:13], b)
}

Expand Down
6 changes: 4 additions & 2 deletions mantle/platform/machine/esx/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package esx

import (
"crypto/rand"
"errors"
"fmt"
"math/rand"
"os"
"path/filepath"

Expand All @@ -32,7 +32,9 @@ type cluster struct {

func (ec *cluster) vmname() string {
b := make([]byte, 5)
rand.Read(b)
if _, err := rand.Read(b); err != nil {
plog.Errorf("failed to generate a random vmname: %v", err)
}
return fmt.Sprintf("%s-%x", ec.Name(), b)
}

Expand Down
Loading