Skip to content

Commit f3db02a

Browse files
author
Nathan Sullivan
authored
Collector/Analyzer - Subnet Available (#1004)
* Adding a new Subnet Available Collector and Analyzer, used to check if a subnet is available for use on a K8s node.
1 parent 5b51018 commit f3db02a

22 files changed

+1166
-0
lines changed

config/crds/troubleshoot.sh_analyzers.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,6 +2056,55 @@ spec:
20562056
required:
20572057
- outcomes
20582058
type: object
2059+
subnetAvailable:
2060+
properties:
2061+
annotations:
2062+
additionalProperties:
2063+
type: string
2064+
type: object
2065+
checkName:
2066+
type: string
2067+
collectorName:
2068+
type: string
2069+
exclude:
2070+
type: BoolString
2071+
outcomes:
2072+
items:
2073+
properties:
2074+
fail:
2075+
properties:
2076+
message:
2077+
type: string
2078+
uri:
2079+
type: string
2080+
when:
2081+
type: string
2082+
type: object
2083+
pass:
2084+
properties:
2085+
message:
2086+
type: string
2087+
uri:
2088+
type: string
2089+
when:
2090+
type: string
2091+
type: object
2092+
warn:
2093+
properties:
2094+
message:
2095+
type: string
2096+
uri:
2097+
type: string
2098+
when:
2099+
type: string
2100+
type: object
2101+
type: object
2102+
type: array
2103+
strict:
2104+
type: BoolString
2105+
required:
2106+
- outcomes
2107+
type: object
20592108
systemPackages:
20602109
properties:
20612110
annotations:

config/crds/troubleshoot.sh_hostcollectors.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,55 @@ spec:
633633
required:
634634
- outcomes
635635
type: object
636+
subnetAvailable:
637+
properties:
638+
annotations:
639+
additionalProperties:
640+
type: string
641+
type: object
642+
checkName:
643+
type: string
644+
collectorName:
645+
type: string
646+
exclude:
647+
type: BoolString
648+
outcomes:
649+
items:
650+
properties:
651+
fail:
652+
properties:
653+
message:
654+
type: string
655+
uri:
656+
type: string
657+
when:
658+
type: string
659+
type: object
660+
pass:
661+
properties:
662+
message:
663+
type: string
664+
uri:
665+
type: string
666+
when:
667+
type: string
668+
type: object
669+
warn:
670+
properties:
671+
message:
672+
type: string
673+
uri:
674+
type: string
675+
when:
676+
type: string
677+
type: object
678+
type: object
679+
type: array
680+
strict:
681+
type: BoolString
682+
required:
683+
- outcomes
684+
type: object
636685
systemPackages:
637686
properties:
638687
annotations:
@@ -1176,6 +1225,20 @@ spec:
11761225
- args
11771226
- command
11781227
type: object
1228+
subnetAvailable:
1229+
properties:
1230+
CIDRRangeAlloc:
1231+
type: string
1232+
collectorName:
1233+
type: string
1234+
desiredCIDR:
1235+
type: integer
1236+
exclude:
1237+
type: BoolString
1238+
required:
1239+
- CIDRRangeAlloc
1240+
- desiredCIDR
1241+
type: object
11791242
systemPackages:
11801243
properties:
11811244
amzn:

config/crds/troubleshoot.sh_hostpreflights.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,55 @@ spec:
633633
required:
634634
- outcomes
635635
type: object
636+
subnetAvailable:
637+
properties:
638+
annotations:
639+
additionalProperties:
640+
type: string
641+
type: object
642+
checkName:
643+
type: string
644+
collectorName:
645+
type: string
646+
exclude:
647+
type: BoolString
648+
outcomes:
649+
items:
650+
properties:
651+
fail:
652+
properties:
653+
message:
654+
type: string
655+
uri:
656+
type: string
657+
when:
658+
type: string
659+
type: object
660+
pass:
661+
properties:
662+
message:
663+
type: string
664+
uri:
665+
type: string
666+
when:
667+
type: string
668+
type: object
669+
warn:
670+
properties:
671+
message:
672+
type: string
673+
uri:
674+
type: string
675+
when:
676+
type: string
677+
type: object
678+
type: object
679+
type: array
680+
strict:
681+
type: BoolString
682+
required:
683+
- outcomes
684+
type: object
636685
systemPackages:
637686
properties:
638687
annotations:
@@ -1176,6 +1225,20 @@ spec:
11761225
- args
11771226
- command
11781227
type: object
1228+
subnetAvailable:
1229+
properties:
1230+
CIDRRangeAlloc:
1231+
type: string
1232+
collectorName:
1233+
type: string
1234+
desiredCIDR:
1235+
type: integer
1236+
exclude:
1237+
type: BoolString
1238+
required:
1239+
- CIDRRangeAlloc
1240+
- desiredCIDR
1241+
type: object
11791242
systemPackages:
11801243
properties:
11811244
amzn:
@@ -1548,6 +1611,20 @@ spec:
15481611
exclude:
15491612
type: BoolString
15501613
type: object
1614+
subnetAvailable:
1615+
properties:
1616+
CIDRRangeAlloc:
1617+
type: string
1618+
collectorName:
1619+
type: string
1620+
desiredCIDR:
1621+
type: integer
1622+
exclude:
1623+
type: BoolString
1624+
required:
1625+
- CIDRRangeAlloc
1626+
- desiredCIDR
1627+
type: object
15511628
systemPackages:
15521629
properties:
15531630
collectorName:

config/crds/troubleshoot.sh_preflights.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10153,6 +10153,20 @@ spec:
1015310153
exclude:
1015410154
type: BoolString
1015510155
type: object
10156+
subnetAvailable:
10157+
properties:
10158+
CIDRRangeAlloc:
10159+
type: string
10160+
collectorName:
10161+
type: string
10162+
desiredCIDR:
10163+
type: integer
10164+
exclude:
10165+
type: BoolString
10166+
required:
10167+
- CIDRRangeAlloc
10168+
- desiredCIDR
10169+
type: object
1015610170
systemPackages:
1015710171
properties:
1015810172
collectorName:

config/crds/troubleshoot.sh_remotecollectors.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,20 @@ spec:
283283
exclude:
284284
type: BoolString
285285
type: object
286+
subnetAvailable:
287+
properties:
288+
CIDRRangeAlloc:
289+
type: string
290+
collectorName:
291+
type: string
292+
desiredCIDR:
293+
type: integer
294+
exclude:
295+
type: BoolString
296+
required:
297+
- CIDRRangeAlloc
298+
- desiredCIDR
299+
type: object
286300
systemPackages:
287301
properties:
288302
collectorName:

config/crds/troubleshoot.sh_supportbundles.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10565,6 +10565,55 @@ spec:
1056510565
required:
1056610566
- outcomes
1056710567
type: object
10568+
subnetAvailable:
10569+
properties:
10570+
annotations:
10571+
additionalProperties:
10572+
type: string
10573+
type: object
10574+
checkName:
10575+
type: string
10576+
collectorName:
10577+
type: string
10578+
exclude:
10579+
type: BoolString
10580+
outcomes:
10581+
items:
10582+
properties:
10583+
fail:
10584+
properties:
10585+
message:
10586+
type: string
10587+
uri:
10588+
type: string
10589+
when:
10590+
type: string
10591+
type: object
10592+
pass:
10593+
properties:
10594+
message:
10595+
type: string
10596+
uri:
10597+
type: string
10598+
when:
10599+
type: string
10600+
type: object
10601+
warn:
10602+
properties:
10603+
message:
10604+
type: string
10605+
uri:
10606+
type: string
10607+
when:
10608+
type: string
10609+
type: object
10610+
type: object
10611+
type: array
10612+
strict:
10613+
type: BoolString
10614+
required:
10615+
- outcomes
10616+
type: object
1056810617
systemPackages:
1056910618
properties:
1057010619
annotations:
@@ -11108,6 +11157,20 @@ spec:
1110811157
- args
1110911158
- command
1111011159
type: object
11160+
subnetAvailable:
11161+
properties:
11162+
CIDRRangeAlloc:
11163+
type: string
11164+
collectorName:
11165+
type: string
11166+
desiredCIDR:
11167+
type: integer
11168+
exclude:
11169+
type: BoolString
11170+
required:
11171+
- CIDRRangeAlloc
11172+
- desiredCIDR
11173+
type: object
1111111174
systemPackages:
1111211175
properties:
1111311176
amzn:
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: troubleshoot.sh/v1beta2
2+
kind: HostPreflight
3+
metadata:
4+
name: subnet-available
5+
spec:
6+
collectors:
7+
# would output yes/no depending if there is a /22 available in 10.0.0.0/8
8+
- subnetAvailable:
9+
CIDRRangeAlloc: "10.0.0.0/8"
10+
desiredCIDR: 22
11+
analyzers:
12+
- subnetAvailable:
13+
outcomes:
14+
- fail:
15+
when: "no-subnet-available"
16+
message: failed to find available subnet
17+
- pass:
18+
when: "a-subnet-is-available"
19+
message: available /22 subnet found

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ require (
5151

5252
require (
5353
cloud.google.com/go/compute/metadata v0.2.3 // indirect
54+
github.com/apparentlymart/go-cidr v1.1.0 // indirect
5455
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
5556
github.com/docker/distribution v2.8.1+incompatible // indirect
5657
github.com/emicklei/go-restful/v3 v3.9.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:C
249249
github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc=
250250
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
251251
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
252+
github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU=
253+
github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
252254
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
253255
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
254256
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=

pkg/analyze/host_analyzer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func GetHostAnalyzer(analyzer *troubleshootv1beta2.HostAnalyze) (HostAnalyzer, b
3838
return &AnalyzeHostTCPConnect{analyzer.TCPConnect}, true
3939
case analyzer.IPV4Interfaces != nil:
4040
return &AnalyzeHostIPV4Interfaces{analyzer.IPV4Interfaces}, true
41+
case analyzer.SubnetAvailable != nil:
42+
return &AnalyzeHostSubnetAvailable{analyzer.SubnetAvailable}, true
4143
case analyzer.FilesystemPerformance != nil:
4244
return &AnalyzeHostFilesystemPerformance{analyzer.FilesystemPerformance}, true
4345
case analyzer.Certificate != nil:

0 commit comments

Comments
 (0)