Skip to content

Commit 5b076d6

Browse files
committed
address comments
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
1 parent a302d9f commit 5b076d6

File tree

9 files changed

+19
-204
lines changed

9 files changed

+19
-204
lines changed

charts/hub-agent/templates/deployment.yaml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ spec:
5656
- --resource-changes-collection-duration={{ .Values.resourceChangesCollectionDuration }}
5757
{{- if .Values.azurePropertyChecker.isEnabled }}
5858
- --azure-property-checker-enabled={{ .Values.azurePropertyChecker.isEnabled }}
59-
- --azure-property-checker-config-file={{ .Values.azurePropertyChecker.configFilePath }}
59+
- --azure-property-checker-config-file={{ .Values.azurePropertyChecker.computeServiceAddressWithBasePath }}
6060
{{- end }}
6161
ports:
6262
- name: metrics
@@ -86,18 +86,6 @@ spec:
8686
fieldPath: metadata.namespace
8787
resources:
8888
{{- toYaml .Values.resources | nindent 12 }}
89-
{{- if .Values.azurePropertyChecker.isEnabled }}
90-
volumeMounts:
91-
- name: property-checker-config
92-
mountPath: /etc/kubernetes/checker
93-
readOnly: true
94-
{{- end }}
95-
{{- if .Values.azurePropertyChecker.isEnabled }}
96-
volumes:
97-
- name: property-checker-config
98-
secret:
99-
secretName: property-config
100-
{{- end }}
10189
{{- with .Values.affinity }}
10290
affinity:
10391
{{- toYaml . | nindent 8 }}

charts/hub-agent/values.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,4 @@ MaxFleetSizeSupported: 100
6262

6363
azurePropertyChecker:
6464
isEnabled: false
65-
configFilePath: /etc/kubernetes/checker/config.json
66-
config:
67-
computeServiceAddressWithBasePath: "http://localhost:8421/compute"
65+
computeServiceAddressWithBasePath: "http://localhost:8421/compute"

cmd/hubagent/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ func main() {
9191

9292
opts := options.NewOptions()
9393
opts.AddFlags(flag.CommandLine)
94-
95-
azureOpts := options.NewAzurePropertyCheckerOptions()
96-
azureOpts.AddFlags(flag.CommandLine)
94+
opts.AzurePropertyCheckerOptions.AddFlags(flag.CommandLine)
9795

9896
flag.Parse()
9997
defer handleExitFunc()
@@ -182,7 +180,7 @@ func main() {
182180
}
183181

184182
ctx := ctrl.SetupSignalHandler()
185-
if err := workload.SetupControllers(ctx, &wg, mgr, config, opts, azureOpts); err != nil {
183+
if err := workload.SetupControllers(ctx, &wg, mgr, config, opts); err != nil {
186184
klog.ErrorS(err, "unable to set up ready check")
187185
exitWithErrorFunc()
188186
}

cmd/hubagent/options/azureoptions.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@ import (
1111
type AzurePropertyCheckerOptions struct {
1212
// isEnabled indicates whether the Azure property checker is enabled.
1313
isEnabled bool
14-
// configFilePath is the path to the Azure property checker configuration file.
15-
configFilePath string
14+
// computeServiceAddressWithBasePath is the address of the Azure compute service with base path.
15+
computeServiceAddressWithBasePath string
1616
}
1717

1818
// NewAzurePropertyCheckerOptions creates a new AzurePropertyCheckerOptions with default values.
1919
func NewAzurePropertyCheckerOptions() *AzurePropertyCheckerOptions {
2020
return &AzurePropertyCheckerOptions{
21-
isEnabled: false,
22-
configFilePath: "/etc/kubernetes/checker/config.json",
21+
isEnabled: false,
22+
computeServiceAddressWithBasePath: "http://localhost:8421/compute",
2323
}
2424
}
2525

2626
// AddFlags adds flags for Azure Property Checker options to the given FlagSet.
2727
func (o *AzurePropertyCheckerOptions) AddFlags(flags *flag.FlagSet) {
2828
flags.BoolVar(&o.isEnabled, "azure-property-checker-enabled", o.isEnabled, "Enable Azure property checker for validating Azure-specific cluster properties.")
29-
flags.StringVar(&o.configFilePath, "azure-property-checker-config-file", o.configFilePath, "Path to the Azure property checker configuration file.")
29+
flags.StringVar(&o.computeServiceAddressWithBasePath, "azure-compute-server-address", o.computeServiceAddressWithBasePath, "The address of the Azure compute service with base path.")
3030
}
3131

3232
// IsEnabled returns whether the Azure property checker is enabled.
3333
func (o *AzurePropertyCheckerOptions) IsEnabled() bool {
3434
return o.isEnabled
3535
}
3636

37-
// ConfigFilePath returns the path to the Azure property checker configuration file.
38-
func (o *AzurePropertyCheckerOptions) ConfigFilePath() string {
39-
return o.configFilePath
37+
// ComputeServiceAddressWithBasePath returns the address of the Azure compute service with base path.
38+
func (o *AzurePropertyCheckerOptions) ComputeServiceAddressWithBasePath() string {
39+
return o.computeServiceAddressWithBasePath
4040
}

cmd/hubagent/options/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ type Options struct {
111111
ResourceSnapshotCreationMinimumInterval time.Duration
112112
// ResourceChangesCollectionDuration is the duration for collecting resource changes into one snapshot.
113113
ResourceChangesCollectionDuration time.Duration
114+
// AzurePropertyCheckerOptions contains options for Azure property checker
115+
AzurePropertyCheckerOptions *AzurePropertyCheckerOptions
114116
}
115117

116118
// NewOptions builds an empty options.
@@ -133,6 +135,7 @@ func NewOptions() *Options {
133135
PprofPort: 6065,
134136
ResourceSnapshotCreationMinimumInterval: 30 * time.Second,
135137
ResourceChangesCollectionDuration: 15 * time.Second,
138+
AzurePropertyCheckerOptions: NewAzurePropertyCheckerOptions(),
136139
}
137140
}
138141

cmd/hubagent/workload/setup.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ var (
134134
)
135135

136136
// SetupControllers set up the customized controllers we developed
137-
func SetupControllers(ctx context.Context, wg *sync.WaitGroup, mgr ctrl.Manager, config *rest.Config, opts *options.Options, azureOpts *options.AzurePropertyCheckerOptions) error { //nolint:gocyclo
137+
func SetupControllers(ctx context.Context, wg *sync.WaitGroup, mgr ctrl.Manager, config *rest.Config, opts *options.Options) error { //nolint:gocyclo
138138
// TODO: Try to reduce the complexity of this last measured at 33 (failing at > 30) and remove the // nolint:gocyclo
139139
dynamicClient, err := dynamic.NewForConfig(config)
140140
if err != nil {
@@ -388,14 +388,9 @@ func SetupControllers(ctx context.Context, wg *sync.WaitGroup, mgr ctrl.Manager,
388388
// Set up the scheduler
389389
klog.Info("Setting up scheduler")
390390
profileOpts := profile.Options{}
391-
if azureOpts.IsEnabled() {
391+
if opts.AzurePropertyCheckerOptions.IsEnabled() {
392392
klog.Info("Azure property checker is enabled for cluster property validation")
393-
propertyChckerConfig, err := azure.NewPropertyCheckerConfigFromFile(azureOpts.ConfigFilePath())
394-
if err != nil {
395-
klog.ErrorS(err, "unable to load azure property checker config")
396-
return err
397-
}
398-
client, err := compute.NewAttributeBasedVMSizeRecommenderClient(propertyChckerConfig.ComputeServiceAddressWithBasePath, httputil.DefaultClientForAzure)
393+
client, err := compute.NewAttributeBasedVMSizeRecommenderClient(opts.AzurePropertyCheckerOptions.ComputeServiceAddressWithBasePath(), httputil.DefaultClientForAzure)
399394
if err != nil {
400395
klog.ErrorS(err, "unable to create azure vm size recommender client")
401396
return err

pkg/propertychecker/azure/config.go

Lines changed: 0 additions & 61 deletions
This file was deleted.

pkg/propertychecker/azure/config_test.go

Lines changed: 0 additions & 105 deletions
This file was deleted.

test/integration/suite_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,10 @@ var _ = BeforeSuite(func() {
112112

113113
By("Setup custom controllers")
114114
opts := options.NewOptions()
115-
azureOpts := options.NewAzurePropertyCheckerOptions()
116115
opts.LeaderElection.LeaderElect = false
117116
opts.EnableV1Alpha1APIs = true
118117
opts.EnableV1Beta1APIs = false
119-
err = workload.SetupControllers(ctx, nil, mgr, cfg, opts, azureOpts)
118+
err = workload.SetupControllers(ctx, nil, mgr, cfg, opts)
120119
Expect(err).Should(Succeed())
121120

122121
By("Start the controller manager")

0 commit comments

Comments
 (0)