mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-08-23 22:26:49 +00:00
Check the template type addon status immediately when the cluster status changes (#350)
Signed-off-by: zhujian <jiazhu@redhat.com>
This commit is contained in:
@@ -33,7 +33,7 @@ require (
|
||||
k8s.io/klog/v2 v2.110.1
|
||||
k8s.io/kube-aggregator v0.29.0
|
||||
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
|
||||
open-cluster-management.io/addon-framework v0.8.1-0.20240102072130-44852ea0722f
|
||||
open-cluster-management.io/addon-framework v0.8.1-0.20240119025526-d2afcef1ff66
|
||||
open-cluster-management.io/api v0.12.1-0.20240115071352-3d94ce8f3499
|
||||
open-cluster-management.io/sdk-go v0.0.0-20240117083639-69270b03020c
|
||||
sigs.k8s.io/controller-runtime v0.16.2
|
||||
|
||||
@@ -450,8 +450,8 @@ k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/A
|
||||
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA=
|
||||
k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ=
|
||||
k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||
open-cluster-management.io/addon-framework v0.8.1-0.20240102072130-44852ea0722f h1:R5IbFdM4g+kDyONZ1/q67/czRwgDkq9Q7ETZ3RhGaAg=
|
||||
open-cluster-management.io/addon-framework v0.8.1-0.20240102072130-44852ea0722f/go.mod h1:aj97pgpGJ0/LpQzBVtU2oDFqqIiZLOPnsjLKG/sVkFw=
|
||||
open-cluster-management.io/addon-framework v0.8.1-0.20240119025526-d2afcef1ff66 h1:d6vkhLLdam7/DLmZ4onPSbsRNHP3Rze0/0OkmjJgVjk=
|
||||
open-cluster-management.io/addon-framework v0.8.1-0.20240119025526-d2afcef1ff66/go.mod h1:aj97pgpGJ0/LpQzBVtU2oDFqqIiZLOPnsjLKG/sVkFw=
|
||||
open-cluster-management.io/api v0.12.1-0.20240115071352-3d94ce8f3499 h1:Odh200i57Z9V44eJak98VqdKMCAlj3m9dtnUp8285nE=
|
||||
open-cluster-management.io/api v0.12.1-0.20240115071352-3d94ce8f3499/go.mod h1:K3Rza3qN/W1+E1a+wbLtFatvdI8UlQWkSqBlpeRHMPw=
|
||||
open-cluster-management.io/sdk-go v0.0.0-20240117083639-69270b03020c h1:0/Y9YSSLT6+D6kc3ZNiHKK53tsxJJyrfSo0U3NUfB2U=
|
||||
|
||||
@@ -110,6 +110,7 @@ func (a *CRDTemplateAgentAddon) GetAgentAddonOptions() agent.AgentAddonOptions {
|
||||
for gvr := range utils.BuiltInAddOnConfigGVRs {
|
||||
supportedConfigGVRs = append(supportedConfigGVRs, gvr)
|
||||
}
|
||||
|
||||
agentAddonOptions := agent.AgentAddonOptions{
|
||||
AddonName: a.addonName,
|
||||
InstallStrategy: nil,
|
||||
@@ -125,7 +126,11 @@ func (a *CRDTemplateAgentAddon) GetAgentAddonOptions() agent.AgentAddonOptions {
|
||||
AgentInstallNamespace: utils.AgentInstallNamespaceFromDeploymentConfigFunc(
|
||||
utils.NewAddOnDeploymentConfigGetter(a.addonClient)),
|
||||
},
|
||||
AgentDeployTriggerClusterFilter: utils.ClusterImageRegistriesAnnotationChanged,
|
||||
AgentDeployTriggerClusterFilter: func(old, new *clusterv1.ManagedCluster) bool {
|
||||
return utils.ClusterImageRegistriesAnnotationChanged(old, new) ||
|
||||
// if the cluster changes from unknow to true, recheck the health of the addon immediately
|
||||
utils.ClusterAvailableConditionChanged(old, new)
|
||||
},
|
||||
}
|
||||
|
||||
template, err := a.GetDesiredAddOnTemplate(nil, "", a.addonName)
|
||||
|
||||
Vendored
+1
-1
@@ -1487,7 +1487,7 @@ k8s.io/utils/pointer
|
||||
k8s.io/utils/ptr
|
||||
k8s.io/utils/strings/slices
|
||||
k8s.io/utils/trace
|
||||
# open-cluster-management.io/addon-framework v0.8.1-0.20240102072130-44852ea0722f
|
||||
# open-cluster-management.io/addon-framework v0.8.1-0.20240119025526-d2afcef1ff66
|
||||
## explicit; go 1.20
|
||||
open-cluster-management.io/addon-framework/pkg/addonfactory
|
||||
open-cluster-management.io/addon-framework/pkg/addonmanager
|
||||
|
||||
+29
-1
@@ -386,8 +386,36 @@ func MapValueChanged(old, new map[string]string, key string) bool {
|
||||
// ClusterImageRegistriesAnnotationChanged returns true if the value of the ClusterImageRegistriesAnnotationKey
|
||||
// in the new managed cluster annotation is different from the old managed cluster annotation
|
||||
func ClusterImageRegistriesAnnotationChanged(old, new *clusterv1.ManagedCluster) bool {
|
||||
return ClusterAnnotationChanged(old, new, clusterv1.ClusterImageRegistriesAnnotationKey)
|
||||
}
|
||||
|
||||
// ClusterAnnotationChanged returns true if the value of the specified annotation in the new managed cluster annotation
|
||||
// is different from the old managed cluster annotation
|
||||
func ClusterAnnotationChanged(old, new *clusterv1.ManagedCluster, annotation string) bool {
|
||||
if new == nil || old == nil {
|
||||
return false
|
||||
}
|
||||
return MapValueChanged(old.Annotations, new.Annotations, clusterv1.ClusterImageRegistriesAnnotationKey)
|
||||
return MapValueChanged(old.Annotations, new.Annotations, annotation)
|
||||
}
|
||||
|
||||
// ClusterAvailableConditionChanged returns true if the value of the Available condition in the new managed cluster
|
||||
// is different from the old managed cluster
|
||||
func ClusterAvailableConditionChanged(old, new *clusterv1.ManagedCluster) bool {
|
||||
return ClusterConditionChanged(old, new, clusterv1.ManagedClusterConditionAvailable)
|
||||
}
|
||||
|
||||
// ClusterAvailableConditionChanged returns true if the value of the specified conditionType in the new managed cluster
|
||||
// is different from the old managed cluster
|
||||
func ClusterConditionChanged(old, new *clusterv1.ManagedCluster, conditionType string) bool {
|
||||
if new == nil || old == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
oldAvailableCondition := meta.FindStatusCondition(old.Status.Conditions, conditionType)
|
||||
newAvailableCondition := meta.FindStatusCondition(new.Status.Conditions, conditionType)
|
||||
|
||||
return (oldAvailableCondition == nil && newAvailableCondition != nil) ||
|
||||
(oldAvailableCondition != nil && newAvailableCondition == nil) ||
|
||||
(oldAvailableCondition != nil && newAvailableCondition != nil &&
|
||||
oldAvailableCondition.Status != newAvailableCondition.Status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user