Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cloud config support in hub-net-controller-manager #205

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jwtty
Copy link

@jwtty jwtty commented Oct 29, 2024

What type of PR is this?
/kind feature

What this PR does / why we need it:
Add support to read cloud config from file and update hub-net-controller-manager chart to use the cloud config.

Which issue(s) this PR fixes:

Fixes #

Requirements:

How has this code been tested

Special notes for your reviewer

@jwtty jwtty changed the title add cloud config parser and update hub-net-controller-manager chart feat: add cloud config support in hub-net-controller-manager Oct 29, 2024
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 94.64286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 78.37%. Comparing base (4749a33) to head (2543e2b).

Files with missing lines Patch % Lines
pkg/common/cloudconfig/config.go 94.64% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #205      +/-   ##
==========================================
+ Coverage   77.90%   78.37%   +0.46%     
==========================================
  Files          27       28       +1     
  Lines        3431     3487      +56     
==========================================
+ Hits         2673     2733      +60     
+ Misses        607      602       -5     
- Partials      151      152       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

cmd/hub-net-controller-manager/main.go Outdated Show resolved Hide resolved
pkg/common/cloudconfig/azure/azure.go Outdated Show resolved Hide resolved
cmd/hub-net-controller-manager/main.go Outdated Show resolved Hide resolved
charts/hub-net-controller-manager/values.yaml Show resolved Hide resolved
pkg/common/cloudconfig/azure/azure.go Outdated Show resolved Hide resolved
},
}
config.trimSpace()
if config != expected {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use diff as the structure contains a lot of fields

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

pkg/common/cloudconfig/azure/azure_test.go Outdated Show resolved Hide resolved
pkg/common/cloudconfig/azure/azure_test.go Outdated Show resolved Hide resolved
charts/hub-net-controller-manager/values.yaml Show resolved Hide resolved
t.Errorf("failed to test LoadCloudConfigFromFile: expected no error, got %v", err)
}
if !reflect.DeepEqual(config, test.expectedConfig) {
t.Errorf("config parsed does not match, expected: %v, got: %v", test.expectedConfig, config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test failures message needs to identify the function.
https://go.dev/wiki/TestComments#identify-the-function

"Where you would write “actual” and “expected”, prefer using the words “got” and “want”, respectively."
https://google.github.io/styleguide/go/decisions#got-before-want

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed


## Override Azure cloud config

**If AzureTrafficManager feature is enabled, then an Azure cloud configuration is required.** Azure cloud configuration provides resource metadata and credentials for `fleet-hub-net-controller-manager` and `fleet-member-net-controller-manager` to manipulate Azure resources. It's embedded into a Kubernetes secret and mounted to the pods. The values can be modified under `config.azureCloudConfig` section in values.yaml or can be provided as a separate file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a param to enable azure traffic manager feature?

so that we only install the azure cloud config when the feature is on.

cmd/hub-net-controller-manager/main.go Outdated Show resolved Hide resolved
*/

// Package cloudconfig defines azure cloud provider configuration.
package cloudconfig
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this package to fleet repo? so that it can be shared by both repo.

pkg/common/cloudconfig/config_test.go Outdated Show resolved Hide resolved
pkg/common/cloudconfig/config_test.go Outdated Show resolved Hide resolved
if got := err != nil; got != test.expectErr {
t.Errorf("failed to run NewCloudConfigFromFile(%s): got %v, want %v", test.filePath, got, test.expectErr)
}
if !cmp.Equal(config, test.expectedConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use the diff instead? otherwise, when it fails, it hard to figure out what's the diff as it contains too many fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants