Skip to content

Commit

Permalink
bump the addon framework to v0.10.0 (#1113)
Browse files Browse the repository at this point in the history
* bump the addon framework to v0.10.0

Signed-off-by: myan <[email protected]>

* fix the line

Signed-off-by: myan <[email protected]>

---------

Signed-off-by: myan <[email protected]>
  • Loading branch information
yanmxa authored Sep 20, 2024
1 parent d55201c commit 604bed7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ require (
k8s.io/klog v1.0.0
k8s.io/kube-aggregator v0.31.0
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
open-cluster-management.io/addon-framework v0.9.0
open-cluster-management.io/addon-framework v0.10.0
open-cluster-management.io/api v0.13.0
open-cluster-management.io/governance-policy-propagator v0.11.1-0.20230815182526-b4ee1b24b1d0
open-cluster-management.io/multicloud-operators-channel v0.11.0
Expand Down Expand Up @@ -103,7 +103,7 @@ require (
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
Expand Down Expand Up @@ -213,7 +213,7 @@ require (
k8s.io/component-base v0.31.0 // indirect
k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
open-cluster-management.io/sdk-go v0.13.0 // indirect
open-cluster-management.io/sdk-go v0.13.1-0.20240416062924-20307e6fe090 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kube-storage-version-migrator v0.0.6-0.20230721195810-5c8923c5ff96 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/z
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/gregjones/httpcache v0.0.0-20170728041850-787624de3eb7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
Expand Down Expand Up @@ -1975,8 +1975,8 @@ modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I=
open-cluster-management.io/addon-framework v0.9.0 h1:7QKLgfRns2BRLFigjIaWVTPCwG9feM+CNtZ22Yf2I20=
open-cluster-management.io/addon-framework v0.9.0/go.mod h1:OEIFCEXhZKO/Grv08CB0T+TGzS0bLshw4G9u7Vw8dw0=
open-cluster-management.io/addon-framework v0.10.0 h1:bwI1XujcbkDoqlCFG1mKuwXNzoED4im/9/9BVu4xpRo=
open-cluster-management.io/addon-framework v0.10.0/go.mod h1:HayKCznnlyW+0dUJQGj5sNR6i3tvylSySD3YnvZkBtY=
open-cluster-management.io/api v0.13.0 h1:dlcJEZlNlE0DmSDctK2s7iWKg9l+Tgb0V78Z040nMuk=
open-cluster-management.io/api v0.13.0/go.mod h1:CuCPEzXDvOyxBB0H1d1eSeajbHqaeGEKq9c63vQc63w=
open-cluster-management.io/governance-policy-propagator v0.11.1-0.20230815182526-b4ee1b24b1d0 h1:r20lNdYf/dZll6d9MRlWv9CAMcW+YO5PGG25odV+FgY=
Expand All @@ -1985,8 +1985,8 @@ open-cluster-management.io/multicloud-operators-channel v0.11.0 h1:Uprx8ShWY2P/n
open-cluster-management.io/multicloud-operators-channel v0.11.0/go.mod h1:XpOQgTYxprwTGQBKXwI+6TaJKdOjltO5+jHkTU+LfVA=
open-cluster-management.io/multicloud-operators-subscription v0.11.0 h1:OLpohu92lMEmWk4LriTyxD1SIJrzHOvuhS3UsnEOElk=
open-cluster-management.io/multicloud-operators-subscription v0.11.0/go.mod h1:0YDADTwQiNoLc7ihyHhTaCNAxx9VSVvrTUQf3W+AyGk=
open-cluster-management.io/sdk-go v0.13.0 h1:ddMGsPUekQr9z03tVN6vF39Uf+WEKMtGU/xSd81HdoA=
open-cluster-management.io/sdk-go v0.13.0/go.mod h1:UnsjzYOrDTF9a8rHEXksoIAtAdO1o5CD5Jtaw6T5B9w=
open-cluster-management.io/sdk-go v0.13.1-0.20240416062924-20307e6fe090 h1:zFmHuW+ztdfUUNslqNW+H1WEcfdEUQHoRDbmdajX340=
open-cluster-management.io/sdk-go v0.13.1-0.20240416062924-20307e6fe090/go.mod h1:w2OaxtCyegxeyFLU42UQ3oxUz01QdsBQkcHI17T/l48=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/letsencrypt v0.0.3 h1:H7xDfhkaFFSYEJlKeq38RwX2jYcnTeHuDQyT+mMNMwM=
rsc.io/letsencrypt v0.0.3/go.mod h1:buyQKZ6IXrRnB7TdkHP0RyEybLx18HHyOSoTyoOLqNY=
Expand Down
27 changes: 19 additions & 8 deletions operator/pkg/controllers/agent/addon_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (r *AddonInstaller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
if !clusterManagementAddOn.DeletionTimestamp.IsZero() {
return ctrl.Result{}, nil
}

cluster := &clusterv1.ManagedCluster{
ObjectMeta: metav1.ObjectMeta{
Name: req.NamespacedName.Name,
Expand All @@ -86,18 +85,20 @@ func (r *AddonInstaller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
// delete the resources
if !cluster.DeletionTimestamp.IsZero() ||
deployMode == operatorconstants.GHAgentDeployModeNone {
r.Log.Info("deleting resourcs and addon", "cluster", cluster.Name, "deployMode", deployMode)
r.Log.Info("deleting resources and addon", "cluster", cluster.Name, "deployMode", deployMode)
if err := r.removeResourcesAndAddon(ctx, cluster); err != nil {
return ctrl.Result{}, fmt.Errorf("failed to remove resources and addon %s: %v", cluster.Name, err)
}
return ctrl.Result{}, nil
}

return ctrl.Result{}, r.reconclieAddonAndResources(ctx, cluster)
return ctrl.Result{}, r.reconcileAddonAndResources(ctx, cluster, clusterManagementAddOn)
}

func (r *AddonInstaller) reconclieAddonAndResources(ctx context.Context, cluster *clusterv1.ManagedCluster) error {
expectedAddon, err := expectedManagedClusterAddon(cluster)
func (r *AddonInstaller) reconcileAddonAndResources(ctx context.Context, cluster *clusterv1.ManagedCluster,
cma *v1alpha1.ClusterManagementAddOn,
) error {
expectedAddon, err := expectedManagedClusterAddon(cluster, cma)
if err != nil {
return err
}
Expand All @@ -112,7 +113,7 @@ func (r *AddonInstaller) reconclieAddonAndResources(ctx context.Context, cluster
// create is not found, update if err == nil
if err != nil {
if errors.IsNotFound(err) {
r.Log.Info("creating resourcs and addon", "cluster", cluster.Name, "addon", existingAddon.Name)
r.Log.Info("creating resources and addon", "cluster", cluster.Name, "addon", existingAddon.Name)
if e := r.Create(ctx, expectedAddon); e != nil {
return e
}
Expand All @@ -122,7 +123,7 @@ func (r *AddonInstaller) reconclieAddonAndResources(ctx context.Context, cluster
} else {
// delete
if !existingAddon.DeletionTimestamp.IsZero() {
r.Log.Info("deleting resourcs and addon", "cluster", cluster.Name, "addon", existingAddon.Name)
r.Log.Info("deleting resources and addon", "cluster", cluster.Name, "addon", existingAddon.Name)
return r.removeResourcesAndAddon(ctx, cluster)
}

Expand Down Expand Up @@ -184,14 +185,24 @@ func (r *AddonInstaller) removeResourcesAndAddon(ctx context.Context, cluster *c
return trans.Prune(cluster.Name)
}

func expectedManagedClusterAddon(cluster *clusterv1.ManagedCluster) (*v1alpha1.ManagedClusterAddOn, error) {
func expectedManagedClusterAddon(cluster *clusterv1.ManagedCluster, cma *v1alpha1.ClusterManagementAddOn) (
*v1alpha1.ManagedClusterAddOn, error,
) {
expectedAddon := &v1alpha1.ManagedClusterAddOn{
ObjectMeta: metav1.ObjectMeta{
Name: operatorconstants.GHManagedClusterAddonName,
Namespace: cluster.Name,
Labels: map[string]string{
constants.GlobalHubOwnerLabelKey: constants.GHOperatorOwnerLabelVal,
},
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: "addon.open-cluster-management.io/v1alpha1",
Kind: "ClusterManagementAddOn",
Name: cma.Name,
UID: cma.GetUID(),
},
},
},
Spec: v1alpha1.ManagedClusterAddOnSpec{
InstallNamespace: constants.GHAgentNamespace,
Expand Down

0 comments on commit 604bed7

Please sign in to comment.