Skip to content

Commit cea85b7

Browse files
committed
feat: refactor AWSAzChaos field names
Renames fields to be more descriptive and makes RemoteCluster optional for AWSAzChaos.
1 parent f2056bf commit cea85b7

File tree

18 files changed

+172
-66
lines changed

18 files changed

+172
-66
lines changed

api/v1alpha1/awsazchaos_types.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ type AWSAzChaos struct {
1919
Status AWSAzChaosStatus `json:"status,omitempty"`
2020
}
2121

22-
var _ InnerObjectWithCustomStatus = (*AWSAzChaos)(nil)
23-
var _ InnerObjectWithSelector = (*AWSAzChaos)(nil)
24-
var _ InnerObject = (*AWSAzChaos)(nil)
22+
var (
23+
_ InnerObjectWithCustomStatus = (*AWSAzChaos)(nil)
24+
_ InnerObjectWithSelector = (*AWSAzChaos)(nil)
25+
_ InnerObject = (*AWSAzChaos)(nil)
26+
)
2527

2628
// AWSAzChaosSpec is the content of the specification for a AWSAzChaos
2729
type AWSAzChaosSpec struct {
@@ -32,6 +34,8 @@ type AWSAzChaosSpec struct {
3234
// +optional
3335
Duration *string `json:"duration,omitempty"`
3436

37+
// RemoteCluster represents the remote cluster where the chaos will be deployed
38+
// +optional
3539
RemoteCluster string `json:"remoteCluster,omitempty"`
3640
}
3741

@@ -49,8 +53,8 @@ type AWSAZSelector struct {
4953
// AWSRegion defines the region of aws.
5054
Stack string `json:"stack"`
5155

52-
// AZ indicates the Availability zone to be taken down
53-
AZ string `json:"az"`
56+
// AvailabilityZone indicates the Availability zone to be taken down
57+
AvailabilityZone string `json:"az"`
5458
}
5559

5660
// GetSelectorSpecs is a getter for selectors

api/v1alpha1/awschaos_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ type AWSChaos struct {
3636
Status AWSChaosStatus `json:"status,omitempty"`
3737
}
3838

39-
var _ InnerObjectWithSelector = (*AWSChaos)(nil)
40-
var _ InnerObject = (*AWSChaos)(nil)
39+
var (
40+
_ InnerObjectWithSelector = (*AWSChaos)(nil)
41+
_ InnerObject = (*AWSChaos)(nil)
42+
)
4143

4244
// AWSChaosAction represents the chaos action about aws.
4345
type AWSChaosAction string

config/crd/bases/chaos-mesh.org_awsazchaos.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ spec:
4242
AWSAzChaos
4343
properties:
4444
az:
45-
description: AZ indicates the Availability zone to be taken down
45+
description: AvailabilityZone indicates the Availability zone to be
46+
taken down
4647
type: string
4748
duration:
4849
description: Duration represents the duration of the chaos action
4950
type: string
5051
remoteCluster:
52+
description: RemoteCluster represents the remote cluster where the
53+
chaos will be deployed
5154
type: string
5255
stack:
5356
description: AWSRegion defines the region of aws.

config/crd/bases/chaos-mesh.org_schedules.yaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,15 @@ spec:
8787
a AWSAzChaos
8888
properties:
8989
az:
90-
description: AZ indicates the Availability zone to be taken down
90+
description: AvailabilityZone indicates the Availability zone
91+
to be taken down
9192
type: string
9293
duration:
9394
description: Duration represents the duration of the chaos action
9495
type: string
9596
remoteCluster:
97+
description: RemoteCluster represents the remote cluster where
98+
the chaos will be deployed
9699
type: string
97100
stack:
98101
description: AWSRegion defines the region of aws.
@@ -3350,14 +3353,16 @@ spec:
33503353
for a AWSAzChaos
33513354
properties:
33523355
az:
3353-
description: AZ indicates the Availability zone to be
3354-
taken down
3356+
description: AvailabilityZone indicates the Availability
3357+
zone to be taken down
33553358
type: string
33563359
duration:
33573360
description: Duration represents the duration of the
33583361
chaos action
33593362
type: string
33603363
remoteCluster:
3364+
description: RemoteCluster represents the remote cluster
3365+
where the chaos will be deployed
33613366
type: string
33623367
stack:
33633368
description: AWSRegion defines the region of aws.
@@ -6464,14 +6469,16 @@ spec:
64646469
for a AWSAzChaos
64656470
properties:
64666471
az:
6467-
description: AZ indicates the Availability zone
6468-
to be taken down
6472+
description: AvailabilityZone indicates the Availability
6473+
zone to be taken down
64696474
type: string
64706475
duration:
64716476
description: Duration represents the duration of
64726477
the chaos action
64736478
type: string
64746479
remoteCluster:
6480+
description: RemoteCluster represents the remote
6481+
cluster where the chaos will be deployed
64756482
type: string
64766483
stack:
64776484
description: AWSRegion defines the region of aws.

config/crd/bases/chaos-mesh.org_workflownodes.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,15 @@ spec:
9393
a AWSAzChaos
9494
properties:
9595
az:
96-
description: AZ indicates the Availability zone to be taken down
96+
description: AvailabilityZone indicates the Availability zone
97+
to be taken down
9798
type: string
9899
duration:
99100
description: Duration represents the duration of the chaos action
100101
type: string
101102
remoteCluster:
103+
description: RemoteCluster represents the remote cluster where
104+
the chaos will be deployed
102105
type: string
103106
stack:
104107
description: AWSRegion defines the region of aws.
@@ -3004,14 +3007,16 @@ spec:
30043007
for a AWSAzChaos
30053008
properties:
30063009
az:
3007-
description: AZ indicates the Availability zone to be taken
3008-
down
3010+
description: AvailabilityZone indicates the Availability zone
3011+
to be taken down
30093012
type: string
30103013
duration:
30113014
description: Duration represents the duration of the chaos
30123015
action
30133016
type: string
30143017
remoteCluster:
3018+
description: RemoteCluster represents the remote cluster where
3019+
the chaos will be deployed
30153020
type: string
30163021
stack:
30173022
description: AWSRegion defines the region of aws.
@@ -6339,14 +6344,16 @@ spec:
63396344
for a AWSAzChaos
63406345
properties:
63416346
az:
6342-
description: AZ indicates the Availability zone
6343-
to be taken down
6347+
description: AvailabilityZone indicates the Availability
6348+
zone to be taken down
63446349
type: string
63456350
duration:
63466351
description: Duration represents the duration of
63476352
the chaos action
63486353
type: string
63496354
remoteCluster:
6355+
description: RemoteCluster represents the remote
6356+
cluster where the chaos will be deployed
63506357
type: string
63516358
stack:
63526359
description: AWSRegion defines the region of aws.
@@ -9548,14 +9555,16 @@ spec:
95489555
specification for a AWSAzChaos
95499556
properties:
95509557
az:
9551-
description: AZ indicates the Availability zone
9552-
to be taken down
9558+
description: AvailabilityZone indicates the
9559+
Availability zone to be taken down
95539560
type: string
95549561
duration:
95559562
description: Duration represents the duration
95569563
of the chaos action
95579564
type: string
95589565
remoteCluster:
9566+
description: RemoteCluster represents the remote
9567+
cluster where the chaos will be deployed
95599568
type: string
95609569
stack:
95619570
description: AWSRegion defines the region of

config/crd/bases/chaos-mesh.org_workflows.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,16 @@ spec:
9999
for a AWSAzChaos
100100
properties:
101101
az:
102-
description: AZ indicates the Availability zone to be taken
103-
down
102+
description: AvailabilityZone indicates the Availability
103+
zone to be taken down
104104
type: string
105105
duration:
106106
description: Duration represents the duration of the chaos
107107
action
108108
type: string
109109
remoteCluster:
110+
description: RemoteCluster represents the remote cluster
111+
where the chaos will be deployed
110112
type: string
111113
stack:
112114
description: AWSRegion defines the region of aws.
@@ -3125,14 +3127,16 @@ spec:
31253127
for a AWSAzChaos
31263128
properties:
31273129
az:
3128-
description: AZ indicates the Availability zone to be
3129-
taken down
3130+
description: AvailabilityZone indicates the Availability
3131+
zone to be taken down
31303132
type: string
31313133
duration:
31323134
description: Duration represents the duration of the
31333135
chaos action
31343136
type: string
31353137
remoteCluster:
3138+
description: RemoteCluster represents the remote cluster
3139+
where the chaos will be deployed
31363140
type: string
31373141
stack:
31383142
description: AWSRegion defines the region of aws.

controllers/chaosimpl/awsazchaos/impl.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ func (impl *Impl) Apply(ctx context.Context, index int, records []*v1alpha1.Reco
3838
return v1alpha1.NotInjected, err
3939
}
4040

41-
azLoss, err := subnetloss.NewAWSAzLoss(ctx, selected.Stack, selected.AZ, impl.Log)
41+
azLoss, err := subnetloss.NewAWSAzLoss(ctx, selected.Stack, selected.AvailabilityZone, impl.Log)
4242
if err != nil {
4343
impl.Log.Error(err, "fail to create NewAWSAzLoss")
4444
return v1alpha1.NotInjected, err
4545
}
4646

4747
phase := record.Phase
4848
if phase == waitForApplySync {
49-
impl.Log.Info(fmt.Sprintf("Applying awsazchaos chaos for stack (%s) and AZ (%s)", selected.Stack, selected.AZ))
49+
impl.Log.Info(fmt.Sprintf("Applying awsazchaos chaos for stack (%s) and AZ (%s)", selected.Stack, selected.AvailabilityZone))
5050
err := azLoss.Start(ctx, awsAZChaos.Status.SubnetToACL)
5151
if err != nil {
5252
impl.Log.Error(err, "fail to start NewAWSAzLoss")
@@ -78,15 +78,15 @@ func (impl *Impl) Recover(ctx context.Context, index int, records []*v1alpha1.Re
7878
return v1alpha1.Injected, err
7979
}
8080

81-
azLoss, err := subnetloss.NewAWSAzLoss(ctx, selected.Stack, selected.AZ, impl.Log)
81+
azLoss, err := subnetloss.NewAWSAzLoss(ctx, selected.Stack, selected.AvailabilityZone, impl.Log)
8282
if err != nil {
8383
impl.Log.Error(err, "fail to create NewAWSAzLoss")
8484
return v1alpha1.Injected, err
8585
}
86-
impl.Log.Info(fmt.Sprintf("Recovering awsazchaos chaos for stack (%s) and AZ (%s)", selected.Stack, selected.AZ))
86+
impl.Log.Info(fmt.Sprintf("Recovering awsazchaos chaos for stack (%s) and AZ (%s)", selected.Stack, selected.AvailabilityZone))
8787
err = azLoss.Stop(ctx, awsAZChaos.Status.SubnetToACL)
8888
if err != nil {
89-
impl.Log.Error(err, fmt.Sprintf("failed to recover awsazchaos chaos for stack (%s) and AZ (%s)", selected.Stack, selected.AZ))
89+
impl.Log.Error(err, fmt.Sprintf("failed to recover awsazchaos chaos for stack (%s) and AZ (%s)", selected.Stack, selected.AvailabilityZone))
9090
return v1alpha1.Injected, err
9191
}
9292
return v1alpha1.NotInjected, nil

controllers/chaosimpl/fx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
package chaosimpl
1717

1818
import (
19-
"github.com/chaos-mesh/chaos-mesh/controllers/chaosimpl/awsazchaos"
2019
"go.uber.org/fx"
2120

21+
"github.com/chaos-mesh/chaos-mesh/controllers/chaosimpl/awsazchaos"
2222
"github.com/chaos-mesh/chaos-mesh/controllers/chaosimpl/awschaos"
2323
"github.com/chaos-mesh/chaos-mesh/controllers/chaosimpl/azurechaos"
2424
"github.com/chaos-mesh/chaos-mesh/controllers/chaosimpl/blockchaos"

helm/chaos-mesh/crds/chaos-mesh.org_awsazchaos.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ spec:
4242
AWSAzChaos
4343
properties:
4444
az:
45-
description: AZ indicates the Availability zone to be taken down
45+
description: AvailabilityZone indicates the Availability zone to be
46+
taken down
4647
type: string
4748
duration:
4849
description: Duration represents the duration of the chaos action
4950
type: string
5051
remoteCluster:
52+
description: RemoteCluster represents the remote cluster where the
53+
chaos will be deployed
5154
type: string
5255
stack:
5356
description: AWSRegion defines the region of aws.

helm/chaos-mesh/crds/chaos-mesh.org_schedules.yaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,15 @@ spec:
8787
a AWSAzChaos
8888
properties:
8989
az:
90-
description: AZ indicates the Availability zone to be taken down
90+
description: AvailabilityZone indicates the Availability zone
91+
to be taken down
9192
type: string
9293
duration:
9394
description: Duration represents the duration of the chaos action
9495
type: string
9596
remoteCluster:
97+
description: RemoteCluster represents the remote cluster where
98+
the chaos will be deployed
9699
type: string
97100
stack:
98101
description: AWSRegion defines the region of aws.
@@ -3350,14 +3353,16 @@ spec:
33503353
for a AWSAzChaos
33513354
properties:
33523355
az:
3353-
description: AZ indicates the Availability zone to be
3354-
taken down
3356+
description: AvailabilityZone indicates the Availability
3357+
zone to be taken down
33553358
type: string
33563359
duration:
33573360
description: Duration represents the duration of the
33583361
chaos action
33593362
type: string
33603363
remoteCluster:
3364+
description: RemoteCluster represents the remote cluster
3365+
where the chaos will be deployed
33613366
type: string
33623367
stack:
33633368
description: AWSRegion defines the region of aws.
@@ -6464,14 +6469,16 @@ spec:
64646469
for a AWSAzChaos
64656470
properties:
64666471
az:
6467-
description: AZ indicates the Availability zone
6468-
to be taken down
6472+
description: AvailabilityZone indicates the Availability
6473+
zone to be taken down
64696474
type: string
64706475
duration:
64716476
description: Duration represents the duration of
64726477
the chaos action
64736478
type: string
64746479
remoteCluster:
6480+
description: RemoteCluster represents the remote
6481+
cluster where the chaos will be deployed
64756482
type: string
64766483
stack:
64776484
description: AWSRegion defines the region of aws.

0 commit comments

Comments
 (0)