Skip to content

Commit 75da5d8

Browse files
Wei WengWei Weng
authored andcommitted
rename flag
Signed-off-by: Wei Weng <[email protected]>
1 parent 9a4430d commit 75da5d8

File tree

8 files changed

+22
-22
lines changed

8 files changed

+22
-22
lines changed

charts/hub-agent/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ _See [helm install](https://helm.sh/docs/helm/helm_install/) for command documen
4141
| `MaxFleetSizeSupported` | Max number of member clusters supported | `100` |
4242
| `resourceSnapshotCreationMinimumInterval` | The minimum interval at which resource snapshots could be created. | `30s` |
4343
| `resourceChangesCollectionDuration` | The duration for collecting resource changes into one snapshot. | `15s` |
44-
| `enableCustomWorkload` | Enable custom workload resources (pods and replicasets) in hub cluster. When true, pod and replicaset validating webhooks are disabled | `false` |
44+
| `enableWorkload` | Enable workload resources (pods and replicasets) in hub cluster. When true, pod and replicaset validating webhooks are disabled | `false` |

charts/hub-agent/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
- --enable-webhook={{ .Values.enableWebhook }}
2525
- --webhook-service-name={{ .Values.webhookServiceName }}
2626
- --enable-guard-rail={{ .Values.enableGuardRail }}
27-
- --enable-custom-workload={{ .Values.enableCustomWorkload }}
27+
- --enable-workload={{ .Values.enableWorkload }}
2828
- --whitelisted-users=system:serviceaccount:fleet-system:hub-agent-sa
2929
- --webhook-client-connection-type={{.Values.webhookClientConnectionType}}
3030
- --v={{ .Values.logVerbosity }}

charts/hub-agent/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enableWebhook: true
1616
webhookServiceName: fleetwebhook
1717
enableGuardRail: true
1818
webhookClientConnectionType: service
19-
enableCustomWorkload: false
19+
enableWorkload: false
2020
forceDeleteWaitTime: 15m0s
2121
clusterUnhealthyThreshold: 3m0s
2222
resourceSnapshotCreationMinimumInterval: 30s

cmd/hubagent/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func main() {
156156

157157
if opts.EnableWebhook {
158158
whiteListedUsers := strings.Split(opts.WhiteListedUsers, ",")
159-
if err := SetupWebhook(mgr, options.WebhookClientConnectionType(opts.WebhookClientConnectionType), opts.WebhookServiceName, whiteListedUsers, opts.EnableGuardRail, opts.EnableV1Beta1APIs, opts.DenyModifyMemberClusterLabels, opts.EnableCustomWorkload); err != nil {
159+
if err := SetupWebhook(mgr, options.WebhookClientConnectionType(opts.WebhookClientConnectionType), opts.WebhookServiceName, whiteListedUsers, opts.EnableGuardRail, opts.EnableV1Beta1APIs, opts.DenyModifyMemberClusterLabels, opts.EnableWorkload); err != nil {
160160
klog.ErrorS(err, "unable to set up webhook")
161161
exitWithErrorFunc()
162162
}
@@ -188,9 +188,9 @@ func main() {
188188
}
189189

190190
// SetupWebhook generates the webhook cert and then set up the webhook configurator.
191-
func SetupWebhook(mgr manager.Manager, webhookClientConnectionType options.WebhookClientConnectionType, webhookServiceName string, whiteListedUsers []string, enableGuardRail, isFleetV1Beta1API bool, denyModifyMemberClusterLabels bool, enableCustomWorkload bool) error {
191+
func SetupWebhook(mgr manager.Manager, webhookClientConnectionType options.WebhookClientConnectionType, webhookServiceName string, whiteListedUsers []string, enableGuardRail, isFleetV1Beta1API bool, denyModifyMemberClusterLabels bool, enableWorkload bool) error {
192192
// Generate self-signed key and crt files in FleetWebhookCertDir for the webhook server to start.
193-
w, err := webhook.NewWebhookConfig(mgr, webhookServiceName, FleetWebhookPort, &webhookClientConnectionType, FleetWebhookCertDir, enableGuardRail, denyModifyMemberClusterLabels, enableCustomWorkload)
193+
w, err := webhook.NewWebhookConfig(mgr, webhookServiceName, FleetWebhookPort, &webhookClientConnectionType, FleetWebhookCertDir, enableGuardRail, denyModifyMemberClusterLabels, enableWorkload)
194194
if err != nil {
195195
klog.ErrorS(err, "fail to generate WebhookConfig")
196196
return err

cmd/hubagent/options/options.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ type Options struct {
107107
PprofPort int
108108
// DenyModifyMemberClusterLabels indicates if the member cluster labels cannot be modified by groups (excluding system:masters)
109109
DenyModifyMemberClusterLabels bool
110-
// EnableCustomWorkload enables custom workload resources (pods and replicasets) to be created in the hub cluster.
110+
// EnableWorkload enables workload resources (pods and replicasets) to be created in the hub cluster.
111111
// When set to true, the pod and replicaset validating webhooks are disabled.
112-
EnableCustomWorkload bool
112+
EnableWorkload bool
113113
// ResourceSnapshotCreationMinimumInterval is the minimum interval at which resource snapshots could be created.
114114
// Whether the resource snapshot is created or not depends on the both ResourceSnapshotCreationMinimumInterval and ResourceChangesCollectionDuration.
115115
ResourceSnapshotCreationMinimumInterval time.Duration
@@ -184,7 +184,7 @@ func (o *Options) AddFlags(flags *flag.FlagSet) {
184184
flags.BoolVar(&o.EnablePprof, "enable-pprof", false, "If set, the pprof profiling is enabled.")
185185
flags.IntVar(&o.PprofPort, "pprof-port", 6065, "The port for pprof profiling.")
186186
flags.BoolVar(&o.DenyModifyMemberClusterLabels, "deny-modify-member-cluster-labels", false, "If set, users not in the system:masters cannot modify member cluster labels.")
187-
flags.BoolVar(&o.EnableCustomWorkload, "enable-custom-workload", false, "If set, custom workload can be created in the hub cluster. This disables the pod and replicaset validating webhooks.")
187+
flags.BoolVar(&o.EnableWorkload, "enable-workload", false, "If set, workloads (pods and replicasets) can be created in the hub cluster. This disables the pod and replicaset validating webhooks.")
188188
flags.DurationVar(&o.ResourceSnapshotCreationMinimumInterval, "resource-snapshot-creation-minimum-interval", 30*time.Second, "The minimum interval at which resource snapshots could be created.")
189189
flags.DurationVar(&o.ResourceChangesCollectionDuration, "resource-changes-collection-duration", 15*time.Second,
190190
"The duration for collecting resource changes into one snapshot. The default is 15 seconds, which means that the controller will collect resource changes for 15 seconds before creating a resource snapshot.")

pkg/webhook/webhook.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ type Config struct {
159159
enableGuardRail bool
160160

161161
denyModifyMemberClusterLabels bool
162-
enableCustomWorkload bool
162+
enableWorkload bool
163163
}
164164

165-
func NewWebhookConfig(mgr manager.Manager, webhookServiceName string, port int32, clientConnectionType *options.WebhookClientConnectionType, certDir string, enableGuardRail bool, denyModifyMemberClusterLabels bool, enableCustomWorkload bool) (*Config, error) {
165+
func NewWebhookConfig(mgr manager.Manager, webhookServiceName string, port int32, clientConnectionType *options.WebhookClientConnectionType, certDir string, enableGuardRail bool, denyModifyMemberClusterLabels bool, enableWorkload bool) (*Config, error) {
166166
// We assume the Pod namespace should be passed to env through downward API in the Pod spec.
167167
namespace := os.Getenv("POD_NAMESPACE")
168168
if namespace == "" {
@@ -177,7 +177,7 @@ func NewWebhookConfig(mgr manager.Manager, webhookServiceName string, port int32
177177
clientConnectionType: clientConnectionType,
178178
enableGuardRail: enableGuardRail,
179179
denyModifyMemberClusterLabels: denyModifyMemberClusterLabels,
180-
enableCustomWorkload: enableCustomWorkload,
180+
enableWorkload: enableWorkload,
181181
}
182182
caPEM, err := w.genCertificate(certDir)
183183
if err != nil {
@@ -306,8 +306,8 @@ func (w *Config) createValidatingWebhookConfiguration(ctx context.Context, webho
306306
func (w *Config) buildFleetValidatingWebhooks() []admv1.ValidatingWebhook {
307307
var webHooks []admv1.ValidatingWebhook
308308

309-
// When enableCustomWorkload is true, skip pod and replicaset validating webhooks to allow custom workloads
310-
if !w.enableCustomWorkload {
309+
// When enableWorkload is true, skip pod and replicaset validating webhooks to allow workloads
310+
if !w.enableWorkload {
311311
webHooks = append(webHooks, admv1.ValidatingWebhook{
312312
Name: "fleet.pod.validating",
313313
ClientConfig: w.createClientConfig(pod.ValidationPath),
@@ -468,12 +468,12 @@ func (w *Config) buildFleetGuardRailValidatingWebhooks() []admv1.ValidatingWebho
468468
},
469469
}
470470

471-
// Build core v1 resources list, conditionally including pods if custom workload is enabled
471+
// Build core v1 resources list, conditionally including pods if workload is enabled
472472
coreV1Resources := []string{bindingResourceName, configMapResourceName, endPointResourceName,
473473
limitRangeResourceName, persistentVolumeClaimsName, persistentVolumeClaimsName + "/status", podTemplateResourceName,
474474
replicationControllerResourceName, replicationControllerResourceName + "/status", resourceQuotaResourceName, resourceQuotaResourceName + "/status", secretResourceName,
475475
serviceAccountResourceName, servicesResourceName, servicesResourceName + "/status"}
476-
if w.enableCustomWorkload {
476+
if w.enableWorkload {
477477
coreV1Resources = append(coreV1Resources, podResourceName, podResourceName+"/status")
478478
}
479479

@@ -482,10 +482,10 @@ func (w *Config) buildFleetGuardRailValidatingWebhooks() []admv1.ValidatingWebho
482482
Rule: createRule([]string{corev1.SchemeGroupVersion.Group}, []string{corev1.SchemeGroupVersion.Version}, coreV1Resources, &namespacedScope),
483483
})
484484

485-
// Build apps/v1 resources list, conditionally including replicasets if custom workload is enabled
485+
// Build apps/v1 resources list, conditionally including replicasets if workload is enabled
486486
appsV1Resources := []string{controllerRevisionResourceName, daemonSetResourceName, daemonSetResourceName + "/status",
487487
deploymentResourceName, deploymentResourceName + "/status", statefulSetResourceName, statefulSetResourceName + "/status"}
488-
if w.enableCustomWorkload {
488+
if w.enableWorkload {
489489
appsV1Resources = append(appsV1Resources, replicaSetResourceName, replicaSetResourceName+"/status")
490490
}
491491

pkg/webhook/webhook_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ func TestBuildFleetValidatingWebhooks(t *testing.T) {
5454
},
5555
wantLength: 8,
5656
},
57-
"enable custom workload": {
57+
"enable workload": {
5858
config: Config{
5959
serviceNamespace: "test-namespace",
6060
servicePort: 8080,
6161
serviceURL: "test-url",
6262
clientConnectionType: &url,
63-
enableCustomWorkload: true,
63+
enableWorkload: true,
6464
},
6565
wantLength: 6,
6666
},
@@ -128,7 +128,7 @@ func TestNewWebhookConfig(t *testing.T) {
128128
clientConnectionType: nil,
129129
enableGuardRail: true,
130130
denyModifyMemberClusterLabels: true,
131-
enableCustomWorkload: false,
131+
enableWorkload: false,
132132
},
133133
wantErr: false,
134134
},

test/e2e/setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ helm install hub-agent ../../charts/hub-agent/ \
123123
--set namespace=fleet-system \
124124
--set logVerbosity=5 \
125125
--set enableWebhook=true \
126-
--set enableCustomWorkload=true \
126+
--set enableWorkload=true \
127127
--set webhookClientConnectionType=service \
128128
--set forceDeleteWaitTime="1m0s" \
129129
--set clusterUnhealthyThreshold="3m0s" \

0 commit comments

Comments
 (0)