Skip to content

Commit

Permalink
assorted changes (#3635)
Browse files Browse the repository at this point in the history
Co-authored-by: David Townley <[email protected]>
  • Loading branch information
d-g-town and David Townley authored Sep 22, 2023
1 parent 663fb3f commit 395f01b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 35 deletions.
20 changes: 10 additions & 10 deletions dashboard/src/components/AzureCostConsent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const AzureCostConsent: React.FC<Props> = ({
noWrapper
expandText="[+] Show details"
collapseText="[-] Hide details"
Header={<Cost>$314.92 / mo</Cost>}
Header={<Cost>$210.24 / mo</Cost>}
ExpandedSection={
<>
<Spacer height="15px" />
Expand All @@ -62,14 +62,14 @@ const AzureCostConsent: React.FC<Props> = ({
<Spacer height="15px" />
• Amazon EC2:
<Spacer height="15px" />
<Tab />+ System workloads: Standard_D2ps_v5 instance (2) =
$110.88/mo
<Tab />+ System workloads: Standard_B2als_v2 instance (3) =
$82.34/mo
<Spacer height="15px" />
<Tab />+ Monitoring workloads: Standard_A2_v2 instance (1) =
$65.52/mo
<Tab />+ Monitoring workloads: Standard_B2als_v2 instance (1) =
$27.45/mo
<Spacer height="15px" />
<Tab />+ Application workloads: Standard_A2_v2 instance (1) =
$65.52/mo
<Tab />+ Application workloads: Standard_B2als_v2 instance (1) =
$27.45/mo
</Fieldset>
</>
}
Expand Down Expand Up @@ -103,20 +103,20 @@ const AzureCostConsent: React.FC<Props> = ({
<Spacer y={0.5} />
<Text color="helper">
All Azure resources will be automatically deleted when you delete your
Porter project. Please enter the Azure base cost ("314.92") below to
Porter project. Please enter the Azure base cost ("210.24") below to
proceed:
</Text>
<Spacer y={1} />
<Input
placeholder="314.92"
placeholder="210.24"
value={confirmCost}
setValue={setConfirmCost}
width="100%"
height="40px"
/>
<Spacer y={1} />
<Button
disabled={confirmCost !== "314.92"}
disabled={confirmCost !== "210.24"}
onClick={() => {
setShowCostConfirmModal(false);
setConfirmCost("");
Expand Down
24 changes: 21 additions & 3 deletions dashboard/src/components/AzureProvisionerSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,27 @@ import Text from "./porter/Text";

const locationOptions = [
{ value: "eastus", label: "East US" },
{ value: "eastus2", label: "East US 2" },
{ value: "westus2", label: "West US 2" },
{ value: "westus3", label: "West US 3" },
{ value: "centralus", label: "Central US" },
{ value: "southcentralus", label: "South Central US" },
{ value: "australiaeast", label: "Australia East" },
{ value: "brazilsouth", label: "Brazil South" },
{ value: "centralindia", label: "Central India" },
{ value: "southcentralus", label: "South Central US" },
{ value: "eastasia", label: "East Asia" },
{ value: "francecentral", label: "France Central" },
{ value: "northeurope", label: "North Europe" },
{ value: "norwayeast", label: "Norway East" },
{ value: "swedencentral", label: "Sweden Central" },
{ value: "switzerlandnorth", label: "Switzerland North" },
{ value: "uksouth", label: "UK South" },
{ value: "westeurope", label: "West Europe" },
];

const machineTypeOptions = [
{ value: "Standard_B2als_v2", label: "Standard_B2als_v2"},
{ value: "Standard_A2_v2", label: "Standard_A2_v2" },
{ value: "Standard_A4_v2", label: "Standard_A4_v2" },
];
Expand Down Expand Up @@ -60,7 +78,7 @@ const AzureProvisionerSettings: React.FC<Props> = (props) => {
const [createStatus, setCreateStatus] = useState("");
const [clusterName, setClusterName] = useState("");
const [azureLocation, setAzureLocation] = useState("eastus");
const [machineType, setMachineType] = useState("Standard_A2_v2");
const [machineType, setMachineType] = useState("Standard_B2als_v2");
const [isExpanded, setIsExpanded] = useState(false);
const [minInstances, setMinInstances] = useState(1);
const [maxInstances, setMaxInstances] = useState(10);
Expand Down Expand Up @@ -170,14 +188,14 @@ const AzureProvisionerSettings: React.FC<Props> = (props) => {
location: azureLocation,
nodePools: [
new AKSNodePool({
instanceType: "Standard_D2ps_v5",
instanceType: "Standard_B2als_v2",
minInstances: 1,
maxInstances: 3,
nodePoolType: NodePoolType.SYSTEM,
mode: "User",
}),
new AKSNodePool({
instanceType: "Standard_A2_v2",
instanceType: "Standard_B2als_v2",
minInstances: 1,
maxInstances: 3,
nodePoolType: NodePoolType.MONITORING,
Expand Down
17 changes: 12 additions & 5 deletions internal/porter_app/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,15 @@ func ParseYAML(ctx context.Context, porterYaml []byte, appName string) (*porterv

switch version.Version {
case PorterYamlVersion_V2:
appProto, envVariables, err = v2.AppProtoFromYaml(ctx, porterYaml, appName)
appProto, envVariables, err = v2.AppProtoFromYaml(ctx, porterYaml)
if err != nil {
return nil, nil, telemetry.Error(ctx, span, err, "error converting v2 yaml to proto")
}
// backwards compatibility for old porter.yaml files
// track this span in telemetry and reach out to customers who are still using old porter.yaml if they exist.
// once no one is converting from old porter.yaml, we can remove this code
case PorterYamlVersion_V1, "":
if appName == "" {
return nil, nil, telemetry.Error(ctx, span, nil, "v1 porter yaml requires externally-provided app name")
}
appProto, envVariables, err = v1.AppProtoFromYaml(ctx, porterYaml, appName)
appProto, envVariables, err = v1.AppProtoFromYaml(ctx, porterYaml)
if err != nil {
return nil, nil, telemetry.Error(ctx, span, err, "error converting v1 yaml to proto")
}
Expand All @@ -65,6 +62,16 @@ func ParseYAML(ctx context.Context, porterYaml []byte, appName string) (*porterv
return nil, nil, telemetry.Error(ctx, span, nil, "porter yaml output is nil")
}

if appName != "" {
telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "override-name", Value: appName})
if appProto.Name != "" && appProto.Name != appName {
telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "parsed-name", Value: appProto.Name})
return nil, nil, telemetry.Error(ctx, span, nil, "name specified in porter.yaml does not match app name")
}

appProto.Name = appName
}

return appProto, envVariables, nil
}

Expand Down
8 changes: 2 additions & 6 deletions internal/porter_app/v1/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ import (
)

// AppProtoFromYaml converts an old version Porter YAML file into a PorterApp proto object
func AppProtoFromYaml(ctx context.Context, porterYamlBytes []byte, appName string) (*porterv1.PorterApp, map[string]string, error) {
func AppProtoFromYaml(ctx context.Context, porterYamlBytes []byte) (*porterv1.PorterApp, map[string]string, error) {
ctx, span := telemetry.NewSpan(ctx, "v1-app-proto-from-yaml")
defer span.End()

telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "app-name", Value: appName})

if porterYamlBytes == nil {
return nil, nil, telemetry.Error(ctx, span, nil, "porter yaml is nil")
}
Expand All @@ -31,9 +29,7 @@ func AppProtoFromYaml(ctx context.Context, porterYamlBytes []byte, appName strin
return nil, nil, telemetry.Error(ctx, span, err, "error unmarshaling porter yaml")
}

appProto := &porterv1.PorterApp{
Name: appName,
}
appProto := &porterv1.PorterApp{}

if porterYaml.Build != nil {
appProto.Build = &porterv1.Build{
Expand Down
12 changes: 1 addition & 11 deletions internal/porter_app/v2/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// AppProtoFromYaml converts a Porter YAML file into a PorterApp proto object
func AppProtoFromYaml(ctx context.Context, porterYamlBytes []byte, appName string) (*porterv1.PorterApp, map[string]string, error) {
func AppProtoFromYaml(ctx context.Context, porterYamlBytes []byte) (*porterv1.PorterApp, map[string]string, error) {
ctx, span := telemetry.NewSpan(ctx, "v2-app-proto-from-yaml")
defer span.End()

Expand All @@ -26,20 +26,10 @@ func AppProtoFromYaml(ctx context.Context, porterYamlBytes []byte, appName strin
return nil, nil, telemetry.Error(ctx, span, err, "error unmarshaling porter yaml")
}

// if the porter yaml is missing a name field, use the app name that is provided in the request
if porterYaml.Name == "" {
porterYaml.Name = appName
}

if porterYaml.Name != "" && appName != "" && porterYaml.Name != appName {
return nil, nil, telemetry.Error(ctx, span, nil, "name specified in porter.yaml does not match app name")
}

appProto := &porterv1.PorterApp{
Name: porterYaml.Name,
}


if porterYaml.Build != nil {
appProto.Build = &porterv1.Build{
Context: porterYaml.Build.Context,
Expand Down

0 comments on commit 395f01b

Please sign in to comment.