Skip to content

Commit

Permalink
Merge branch 'main' into aso-pause-azuremanagedcontrolplane
Browse files Browse the repository at this point in the history
  • Loading branch information
nojnhuh committed Aug 4, 2023
2 parents 7eb8ae3 + 3d85151 commit 08c13fe
Show file tree
Hide file tree
Showing 110 changed files with 253 additions and 109 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/cover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:
with:
go-version: '1.20'
- run: "PATH=/usr/local/go/bin:$PATH make test-cover"
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
- uses: Wandalen/wretry.action@a163f62ae554a8f3cbe27b23db15b60c0ae2e93c # v1.3.0 Retry codecov upload. It is flaky due to a known issue https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
with:
file: ./coverage.out
fail_ci_if_error: true
attempt_limit: 20
action: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
with: |
file: ./coverage.out
fail_ci_if_error: true
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ KUSTOMIZE_VER := v4.5.2
KUSTOMIZE_BIN := kustomize
KUSTOMIZE := $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER)

MOCKGEN_VER := v1.6.0
MOCKGEN_VER := v0.2.0
MOCKGEN_BIN := mockgen
MOCKGEN := $(TOOLS_BIN_DIR)/$(MOCKGEN_BIN)-$(MOCKGEN_VER)

Expand Down Expand Up @@ -800,7 +800,7 @@ $(KUSTOMIZE): ## Build kustomize from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) sigs.k8s.io/kustomize/kustomize/v4 $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER)

$(MOCKGEN): ## Build mockgen from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/golang/mock/mockgen $(MOCKGEN_BIN) $(MOCKGEN_VER)
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) go.uber.org/mock/mockgen $(MOCKGEN_BIN) $(MOCKGEN_VER)

$(KPROMO): ## Build kpromo from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) sigs.k8s.io/promo-tools/v3/cmd/kpromo $(KPROMO_BIN) $(KPROMO_VER)
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/azuremanagedmachinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,11 @@ type AzureManagedMachinePoolSpec struct {
// Immutable.
// +optional
SubnetName *string `json:"subnetName,omitempty"`

// EnableFIPS indicates whether FIPS is enabled on the node pool.
// Immutable.
// +optional
EnableFIPS *bool `json:"enableFIPS,omitempty"`
}

// ManagedMachinePoolScaling specifies scaling options.
Expand Down
7 changes: 7 additions & 0 deletions api/v1beta1/azuremanagedmachinepool_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ func (mw *azureManagedMachinePoolWebhook) ValidateUpdate(ctx context.Context, ol
allErrs = append(allErrs, err)
}

if err := webhookutils.ValidateImmutable(
field.NewPath("Spec", "EnableFIPS"),
old.Spec.EnableFIPS,
m.Spec.EnableFIPS); err != nil && old.Spec.EnableFIPS != nil {
allErrs = append(allErrs, err)
}

// custom headers are immutable
oldCustomHeaders := maps.FilterByKeyPrefix(old.ObjectMeta.Annotations, CustomHeaderPrefix)
newCustomHeaders := maps.FilterByKeyPrefix(m.ObjectMeta.Annotations, CustomHeaderPrefix)
Expand Down
14 changes: 14 additions & 0 deletions api/v1beta1/azuremanagedmachinepool_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,20 @@ func TestAzureManagedMachinePoolUpdatingWebhook(t *testing.T) {
},
wantErr: false,
},
{
name: "Cannot update enableFIPS",
new: &AzureManagedMachinePool{
Spec: AzureManagedMachinePoolSpec{
EnableFIPS: pointer.Bool(true),
},
},
old: &AzureManagedMachinePool{
Spec: AzureManagedMachinePoolSpec{
EnableFIPS: pointer.Bool(false),
},
},
wantErr: true,
},
}
var client client.Client
for _, tc := range tests {
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions azure/converters/managedagentpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func AgentPoolToManagedClusterAgentPoolProfile(pool containerservice.AgentPool)
Tags: properties.Tags,
KubeletDiskType: properties.KubeletDiskType,
LinuxOSConfig: properties.LinuxOSConfig,
EnableFIPS: properties.EnableFIPS,
}
if properties.KubeletConfig != nil {
agentPool.KubeletConfig = properties.KubeletConfig
Expand Down
2 changes: 2 additions & 0 deletions azure/converters/managedagentpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func Test_AgentPoolToManagedClusterAgentPoolProfile(t *testing.T) {
Tags: map[string]*string{
"custom": pointer.String("default"),
},
EnableFIPS: pointer.Bool(true),
},
},

Expand Down Expand Up @@ -84,6 +85,7 @@ func Test_AgentPoolToManagedClusterAgentPoolProfile(t *testing.T) {
Tags: map[string]*string{
"custom": pointer.String("default"),
},
EnableFIPS: pointer.Bool(true),
}))
},
},
Expand Down
2 changes: 1 addition & 1 deletion azure/mock_azure/azure_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azure/regional_baseuri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package azure
import (
"testing"

"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
"sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure"
)

Expand Down
2 changes: 1 addition & 1 deletion azure/scope/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (

azureautorest "github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/azure/auth"
"github.com/golang/mock/gomock"
"github.com/google/go-cmp/cmp"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
Expand Down
2 changes: 1 addition & 1 deletion azure/scope/machinepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (

azureautorest "github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/azure/auth"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
2 changes: 1 addition & 1 deletion azure/scope/machinepoolmachine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"context"
"testing"

"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"github.com/pkg/errors"
"go.uber.org/mock/gomock"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
1 change: 1 addition & 0 deletions azure/scope/managedmachinepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func buildAgentPoolSpec(managedControlPlane *infrav1.AzureManagedControlPlane,
AdditionalTags: managedMachinePool.Spec.AdditionalTags,
KubeletDiskType: managedMachinePool.Spec.KubeletDiskType,
LinuxOSConfig: managedMachinePool.Spec.LinuxOSConfig,
EnableFIPS: managedMachinePool.Spec.EnableFIPS,
}

if managedMachinePool.Spec.OSDiskSizeGB != nil {
Expand Down
2 changes: 1 addition & 1 deletion azure/scope/mocks/node_getter_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azure/services/agentpools/agentpools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"testing"

"github.com/Azure/go-autorest/autorest"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
"k8s.io/utils/pointer"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools/mock_agentpools"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions azure/services/agentpools/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ type AgentPoolSpec struct {

// LinuxOSConfig specifies the custom Linux OS settings and configurations
LinuxOSConfig *infrav1.LinuxOSConfig

// EnableFIPS indicates whether FIPS is enabled on the node pool
EnableFIPS *bool
}

// ResourceName returns the name of the agent pool.
Expand Down Expand Up @@ -380,6 +383,7 @@ func (s *AgentPoolSpec) Parameters(ctx context.Context, existing interface{}) (p
EnableNodePublicIP: s.EnableNodePublicIP,
NodePublicIPPrefixID: s.NodePublicIPPrefixID,
Tags: tags,
EnableFIPS: s.EnableFIPS,
LinuxOSConfig: linuxOSConfig,
},
}
Expand Down
21 changes: 14 additions & 7 deletions azure/services/aso/aso.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure"
"sigs.k8s.io/cluster-api-provider-azure/util/maps"
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -156,8 +155,14 @@ func (s *Service) CreateOrUpdateResource(ctx context.Context, spec azure.ASOReso
}
}

labels := make(map[string]string)
annotations := make(map[string]string)
labels := parameters.GetLabels()
if labels == nil {
labels = make(map[string]string)
}
annotations := parameters.GetAnnotations()
if annotations == nil {
annotations = make(map[string]string)
}

if existing == nil {
labels[infrav1.OwnedByClusterLabelKey] = s.clusterName
Expand All @@ -176,12 +181,14 @@ func (s *Service) CreateOrUpdateResource(ctx context.Context, spec azure.ASOReso
annotations[ReconcilePolicyAnnotation] = ReconcilePolicyManage
}

if len(labels) > 0 {
parameters.SetLabels(maps.Merge(parameters.GetLabels(), labels))
if len(labels) == 0 {
labels = nil
}
if len(annotations) > 0 {
parameters.SetAnnotations(maps.Merge(parameters.GetAnnotations(), annotations))
parameters.SetLabels(labels)
if len(annotations) == 0 {
annotations = nil
}
parameters.SetAnnotations(annotations)

diff := cmp.Diff(existing, parameters)
if diff == "" {
Expand Down
2 changes: 1 addition & 1 deletion azure/services/aso/aso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
asoresourcesv1 "github.com/Azure/azure-service-operator/v2/api/resources/v1api20200601"
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
"github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
Expand Down
2 changes: 1 addition & 1 deletion azure/services/aso/mock_aso/aso_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azure/services/aso/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"testing"

asoresourcesv1 "github.com/Azure/azure-service-operator/v2/api/resources/v1api20200601"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/aso/mock_aso"
Expand Down
2 changes: 1 addition & 1 deletion azure/services/asogroups/groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"testing"

asoresourcesv1 "github.com/Azure/azure-service-operator/v2/api/resources/v1api20200601"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
Expand Down
2 changes: 1 addition & 1 deletion azure/services/asogroups/mock_asogroups/groups_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azure/services/async/async_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-05-01/resources"
"github.com/Azure/go-autorest/autorest"
azureautorest "github.com/Azure/go-autorest/autorest/azure"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async"
Expand Down
2 changes: 1 addition & 1 deletion azure/services/async/mock_async/async_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azure/services/availabilitysets/availabilitysets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-11-01/compute"
"github.com/Azure/go-autorest/autorest"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"github.com/pkg/errors"
"go.uber.org/mock/gomock"
"k8s.io/utils/pointer"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azure/services/bastionhosts/bastionhosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"testing"

"github.com/Azure/go-autorest/autorest"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
"k8s.io/client-go/kubernetes/scheme"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azure/services/disks/disks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"testing"

"github.com/Azure/go-autorest/autorest"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async"
Expand Down
2 changes: 1 addition & 1 deletion azure/services/disks/mock_disks/disks_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azure/services/groups/groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (

"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-05-01/resources"
"github.com/Azure/go-autorest/autorest"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
"k8s.io/utils/pointer"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async"
Expand Down
Loading

0 comments on commit 08c13fe

Please sign in to comment.