Skip to content

Commit

Permalink
Add cpu arch flag to network verifier command
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Byrne <[email protected]>
  • Loading branch information
AlexVulaj and abyrne55 committed Jul 25, 2024
1 parent b994063 commit df3c2c9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cmd/network/verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"github.com/openshift/osd-network-verifier/pkg/data/cpu"
"log"
"os"
"strings"
Expand Down Expand Up @@ -77,6 +78,9 @@ type EgressVerification struct {
Version bool
// Probe The type of probe to use for the verifier
Probe string
// CpuArchName the architecture to use for the compute instance
CpuArchName string
cpuArch cpu.Architecture
}

func NewCmdValidateEgress() *cobra.Command {
Expand Down Expand Up @@ -130,9 +134,10 @@ func NewCmdValidateEgress() *cobra.Command {
validateEgressCmd.Flags().BoolVar(&e.Debug, "debug", false, "(optional) if provided, enable additional debug-level logging")
validateEgressCmd.Flags().BoolVarP(&e.AllSubnets, "all-subnets", "A", false, "(optional) an option for Privatelink clusters to run osd-network-verifier against all subnets listed by ocm.")
validateEgressCmd.Flags().StringVar(&e.PlatformType, "platform", "", "(optional) override for which endpoints to test. Either 'aws' or 'hostedcluster'")
validateEgressCmd.Flags().DurationVar(&e.EgressTimeout, "egress-timeout", 2*time.Second, "(optional) timeout for individual egress verification requests")
validateEgressCmd.Flags().DurationVar(&e.EgressTimeout, "egress-timeout", 5*time.Second, "(optional) timeout for individual egress verification requests")
validateEgressCmd.Flags().BoolVar(&e.Version, "version", false, "When present, prints out the version of osd-network-verifier being used")
validateEgressCmd.Flags().StringVar(&e.Probe, "probe", "curl", "(optional) select the probe to be used for egress testing. Either 'curl' (default) or 'legacy'")
validateEgressCmd.Flags().StringVar(&e.CpuArchName, "cpu-arch", "x86", "(optional) compute instance CPU architecture. E.g., 'x86' or 'arm'")

// If a cluster-id is specified, don't allow the foot-gun of overriding region
validateEgressCmd.MarkFlagsMutuallyExclusive("cluster-id", "region")
Expand Down Expand Up @@ -214,6 +219,11 @@ func (e *EgressVerification) setup(ctx context.Context) (*aws.Config, error) {
}
e.log = logger

e.cpuArch = cpu.ArchitectureByName(e.CpuArchName)
if e.CpuArchName != "" && !e.cpuArch.IsValid() {
return nil, fmt.Errorf("%s is not a valid architecture", e.CpuArchName)
}

// If ClusterId is supplied, leverage ocm and ocm-backplane to get an AWS client
if e.ClusterId != "" {
e.log.Debug(ctx, "searching OCM for cluster: %s", e.ClusterId)
Expand Down Expand Up @@ -307,6 +317,8 @@ func (e *EgressVerification) generateAWSValidateEgressInput(ctx context.Context,
e.log.Info(ctx, "using platform: %s", platform)
input.PlatformType = platform

input.CPUArchitecture = e.cpuArch

// Setup proxy configuration that is not automatically determined
input.Proxy.NoTls = e.NoTls
if e.CaCert != "" {
Expand Down Expand Up @@ -761,8 +773,6 @@ func defaultValidateEgressInput(ctx context.Context, cluster *cmv1.Cluster, regi
return &onv.ValidateEgressInput{
Ctx: ctx,
SubnetID: "",
CloudImageID: onvAwsClient.GetAMIForRegion(region),
InstanceType: "t3.micro",
Proxy: proxy.ProxyConfig{},
PlatformType: helpers.PlatformAWS,
Tags: networkVerifierDefaultTags,
Expand Down

0 comments on commit df3c2c9

Please sign in to comment.