Skip to content

Commit

Permalink
Merge branch 'master' into fix-nsg-e2e-error
Browse files Browse the repository at this point in the history
  • Loading branch information
nwnt committed Sep 12, 2023
2 parents 0ac69cb + c4cf22a commit 602938f
Show file tree
Hide file tree
Showing 20 changed files with 216 additions and 139 deletions.
12 changes: 0 additions & 12 deletions docs/publish-rhcos-image.md

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/api/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func DefaultOperatorFlags() OperatorFlags {
"aro.routefix.enabled": flagTrue,
"aro.storageaccounts.enabled": flagTrue,
"aro.workaround.enabled": flagTrue,
"aro.autosizednodes.enabled": flagFalse,
"aro.autosizednodes.enabled": flagTrue,
"rh.srep.muo.enabled": flagTrue,
"rh.srep.muo.managed": flagTrue,
"aro.guardrails.enabled": flagFalse,
Expand Down
4 changes: 3 additions & 1 deletion pkg/deploy/assets/cluster-development-predeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
},
{
"properties": {
"addressPrefix": "[parameters('masterAddressPrefix')]",
"addressPrefixes": [
"[parameters('masterAddressPrefix')]"
],
"routeTable": {
"id": "[resourceid('Microsoft.Network/routeTables', concat(parameters('clusterName'), '-rt'))]",
"tags": null
Expand Down
4 changes: 3 additions & 1 deletion pkg/deploy/generator/resources_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ func (g *generator) clusterMasterSubnet() *arm.Resource {
return &arm.Resource{
Resource: &mgmtnetwork.Subnet{
SubnetPropertiesFormat: &mgmtnetwork.SubnetPropertiesFormat{
AddressPrefix: to.StringPtr("[parameters('masterAddressPrefix')]"),
AddressPrefixes: &[]string{
*to.StringPtr("[parameters('masterAddressPrefix')]"),
},
RouteTable: &mgmtnetwork.RouteTable{
ID: to.StringPtr("[resourceid('Microsoft.Network/routeTables', concat(parameters('clusterName'), '-rt'))]"),
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/monitor/cluster/clusterflagsandbanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestEmitOperatorFlagsAndSupportBanner(t *testing.T) {
"aro.imageconfig.enabled": "false",
"aro.dnsmasq.enabled": "false",
"aro.genevalogging.enabled": "false",
"aro.autosizednodes.enabled": "true",
"aro.autosizednodes.enabled": "false",
},
expectBannerMetricsValue: 0,
expectBannerMetricsDims: nil,
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestEmitOperatorFlagsAndSupportBanner(t *testing.T) {
"aro.imageconfig.enabled": "false",
"aro.dnsmasq.enabled": "false",
"aro.genevalogging.enabled": "false",
"aro.autosizednodes.enabled": "true",
"aro.autosizednodes.enabled": "false",
},
expectBannerMetricsValue: 1,
expectBannerMetricsDims: map[string]string{"msg": "contact support"},
Expand Down
6 changes: 3 additions & 3 deletions pkg/portal/assets/v2/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"files": {
"main.js": "/static/js/main.f27c737c.js",
"main.js": "/static/js/main.f1999c11.js",
"index.html": "/index.html",
"main.f27c737c.js.map": "/static/js/main.f27c737c.js.map"
"main.f1999c11.js.map": "/static/js/main.f1999c11.js.map"
},
"entrypoints": [
"static/js/main.f27c737c.js"
"static/js/main.f1999c11.js"
]
}
2 changes: 1 addition & 1 deletion pkg/portal/assets/v2/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>ARO Portal</title><script defer="defer" src="/static/js/main.f27c737c.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>ARO Portal</title><script defer="defer" src="/static/js/main.f1999c11.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
3 changes: 3 additions & 0 deletions pkg/portal/assets/v2/build/static/js/main.f1999c11.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pkg/portal/assets/v2/build/static/js/main.f1999c11.js.map

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions pkg/portal/assets/v2/build/static/js/main.f27c737c.js

This file was deleted.

1 change: 0 additions & 1 deletion pkg/portal/assets/v2/build/static/js/main.f27c737c.js.map

This file was deleted.

46 changes: 33 additions & 13 deletions pkg/validate/dynamic/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ var (
errMsgInvalidVNetLocation = "The vnet location '%s' must match the cluster location '%s'."
)

const minimumSubnetMaskSize int = 27

type Subnet struct {
// ID is a resource id of the subnet
ID string
Expand Down Expand Up @@ -766,23 +768,41 @@ func (dv *dynamic) ValidateSubnets(ctx context.Context, oc *api.OpenShiftCluster
)
}

_, net, err := net.ParseCIDR(*ss.AddressPrefix)
if err != nil {
return err
// Handle both addressPrefix & addressPrefixes
if ss.AddressPrefix == nil {
for _, address := range *ss.AddressPrefixes {
if err = validateSubnetSize(s, address); err != nil {
return err
}
}
} else {
if err = validateSubnetSize(s, *ss.AddressPrefix); err != nil {
return err
}
}
}

ones, _ := net.Mask.Size()
if ones > 27 {
return api.NewCloudError(
http.StatusBadRequest,
api.CloudErrorCodeInvalidLinkedVNet,
s.Path,
errMsgSubnetInvalidSize,
s.ID,
)
}
return nil
}

// validateSubnetSize checks if the subnet mask is >27, and returns
// an error if so as it is too small for OCP
func validateSubnetSize(s Subnet, address string) error {
_, net, err := net.ParseCIDR(address)
if err != nil {
return err
}

ones, _ := net.Mask.Size()
if ones > minimumSubnetMaskSize {
return api.NewCloudError(
http.StatusBadRequest,
api.CloudErrorCodeInvalidLinkedVNet,
s.Path,
errMsgSubnetInvalidSize,
s.ID,
)
}
return nil
}

Expand Down
29 changes: 29 additions & 0 deletions pkg/validate/dynamic/dynamic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package dynamic
import (
"context"
"errors"
"fmt"
"net/http"
"testing"
"time"
Expand Down Expand Up @@ -1896,3 +1897,31 @@ func TestValidatePreconfiguredNSGPermissions(t *testing.T) {
})
}
}

func TestValidateSubnetSize(t *testing.T) {
subnetId := "id"
subnetPath := "path"
for _, tt := range []struct {
name string
address string
subnet Subnet
wantErr string
}{
{
name: "subnet size is too small",
address: "10.0.0.0/32",
subnet: Subnet{ID: subnetId, Path: subnetPath},
wantErr: fmt.Sprintf("400: InvalidLinkedVNet: %s: The provided subnet '%s' is invalid: must be /27 or larger.", subnetPath, subnetId),
},
{
name: "subnet size is gucci gang",
address: "10.0.0.0/27",
subnet: Subnet{ID: subnetId, Path: subnetPath},
},
} {
t.Run(tt.name, func(t *testing.T) {
err := validateSubnetSize(tt.subnet, tt.address)
utilerror.AssertErrorMessage(t, err, tt.wantErr)
})
}
}
5 changes: 3 additions & 2 deletions portal/v2/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ registerIcons({
version="1.1"
xmlns="http://www.w3.org/2000/svg"
width="22"
height="22"
height="16"
style={{ overflow: "visible" }}>
<g id="svgg" transform="translate(0.000000,18.000000) scale(0.05000000,-0.05000000)">
<path
Expand Down Expand Up @@ -331,6 +331,7 @@ function App(props: { params: any }) {
<Stack.Item grow>
<ClusterDetailPanel
csrfToken={csrfRef}
sshBox={sshRef}
loaded={fetching}
currentCluster={currentCluster}
onClose={_onCloseDetailPanel}
Expand All @@ -343,4 +344,4 @@ function App(props: { params: any }) {
)
}

export default App
export default App
12 changes: 8 additions & 4 deletions portal/v2/src/ClusterDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { AxiosResponse } from "axios"
import { fetchClusterInfo } from "./Request"
import { ICluster, headerStyles } from "./App"
import { Nav, INavLink, INavStyles } from "@fluentui/react/lib/Nav"
import { ToolIcons } from "./ToolIcons"
import { ClusterDetailComponent, MemoisedClusterDetailListComponent } from "./ClusterDetailList"
import React from "react"

Expand Down Expand Up @@ -79,6 +80,7 @@ const errorBarStyles: Partial<IMessageBarStyles> = { root: { marginBottom: 15 }
export function ClusterDetailPanel(props: {
csrfToken: MutableRefObject<string>
currentCluster: ICluster | null
sshBox: any
onClose: any
loaded: string
}) {
Expand Down Expand Up @@ -183,7 +185,8 @@ export function ClusterDetailPanel(props: {

const _dismissPanel = () => {
dismissPanel()
props.onClose() // useEffect?
props.sshBox.current.hidePopup()
props.onClose()
setData([])
setFetching("")
setDataLoaded(false)
Expand Down Expand Up @@ -261,7 +264,7 @@ export function ClusterDetailPanel(props: {
},
})
}

const onRenderHeader = (): ReactElement => {
return (
<>
Expand All @@ -280,7 +283,8 @@ export function ClusterDetailPanel(props: {
</Stack.Item>
<Stack.Item>
<div className={headerStyles.titleText}>{props.currentCluster?.name}</div>
<div className={headerStyles.subtitleText}>Cluster</div>
<div className={headerStyles.subtitleText}>Cluster</div>
<ToolIcons resourceId={props.currentCluster? props.currentCluster?.resourceId:""} version={Number(props.currentCluster?.version) !== undefined ? Number(props.currentCluster?.version) : 0} csrfToken={props.csrfToken} sshBox={props.sshBox}/>
</Stack.Item>
</Stack>
</>
Expand Down Expand Up @@ -321,4 +325,4 @@ export function ClusterDetailPanel(props: {
</Stack>
</Panel>
)
}
}
62 changes: 6 additions & 56 deletions portal/v2/src/ClusterList.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import React, { useState, useEffect, useRef, MutableRefObject, Component } from "react"
import {
Stack,
IconButton,
Stack,
MessageBarType,
MessageBar,
CommandBar,
ICommandBarItemProps,
Separator,
Text,
IMessageBarStyles,
mergeStyleSets,
TooltipHost,
mergeStyleSets,
TextField,
Link,
Layer,
Expand All @@ -27,7 +25,7 @@ import {
} from "@fluentui/react/lib/DetailsList"
import { useBoolean } from "@fluentui/react-hooks"
import { fetchClusters } from "./Request"
import { KubeconfigButton } from "./Kubeconfig"
import { ToolIcons } from "./ToolIcons"
import { AxiosResponse } from "axios"
import { ICluster, headerStyles } from "./App"

Expand Down Expand Up @@ -287,45 +285,8 @@ class ClusterListComponent extends Component<ClusterListComponentProps, ICluster
data: "string",
isPadded: true,
onRender: (item: ICluster) => (
<Stack horizontal verticalAlign="center" className={classNames.iconContainer}>
<TooltipHost content={`Copy Resource ID`}>
<IconButton
iconProps={{ iconName: "Copy" }}
aria-label="Copy Resource ID"
onClick={() => this._onCopyResourceID(item)}
/>
</TooltipHost>
<TooltipHost content={`Prometheus`}>
<IconButton
iconProps={{ iconName: "BIDashboard" }}
aria-label="Prometheus"
href={
item.resourceId + (+item.version >= 4.11 ? `/prometheus` : `/prometheus/graph`)
}
/>
</TooltipHost>
<TooltipHost content={`SSH`}>
<IconButton
iconProps={{ iconName: "CommandPrompt" }}
aria-label="SSH"
onClick={() => this._onSSHClick(item)}
/>
</TooltipHost>
<KubeconfigButton resourceId={item.resourceId} csrfToken={props.csrfToken} />
{/* <TooltipHost content={`Geneva`}>
<IconButton
iconProps={{iconName: "Health"}}
aria-label="Geneva"
href={item.resourceId + `/geneva`}
/>
</TooltipHost>
<TooltipHost content={`Feature Flags`}>
<IconButton
iconProps={{iconName: "IconSetsFlag"}}
aria-label="featureFlags"
href={item.resourceId + `/feature-flags`}
/>
</TooltipHost> */}
<Stack horizontal verticalAlign="center" className={classNames.iconContainer}>
<ToolIcons resourceId={item.resourceId} csrfToken={props.csrfToken} version={Number(item.version)} sshBox={props.sshModalRef}/>
</Stack>
),
},
Expand Down Expand Up @@ -380,17 +341,6 @@ class ClusterListComponent extends Component<ClusterListComponentProps, ICluster
})
}

private _onSSHClick(item: any): void {
const modal = this._sshModal
if (modal && modal.current) {
modal.current.LoadSSH(item.resourceId)
}
}

private _onCopyResourceID(item: any): void {
navigator.clipboard.writeText(item.resourceId)
}

private _onClusterInfoLinkClick(item: ICluster): void {
this.props.setCurrentCluster(item)
}
Expand Down Expand Up @@ -523,4 +473,4 @@ export function ClusterList(props: {
/>
</Stack>
)
}
}
Loading

0 comments on commit 602938f

Please sign in to comment.