-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rokibul Hasan <[email protected]>
- Loading branch information
1 parent
47d289a
commit 7421a95
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package manager | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/kluster-manager/cluster-auth/pkg/common" | ||
|
||
agentapi "open-cluster-management.io/addon-framework/pkg/agent" | ||
workapiv1 "open-cluster-management.io/api/work/v1" | ||
) | ||
|
||
// agentHealthProber returns an instance of the agent's health prober. It is used for | ||
// probing and checking the health status of the agent. | ||
func agentHealthProber() *agentapi.HealthProber { | ||
return &agentapi.HealthProber{ | ||
Type: agentapi.HealthProberTypeWork, | ||
WorkProber: &agentapi.WorkHealthProber{ | ||
ProbeFields: []agentapi.ProbeField{ | ||
{ | ||
ResourceIdentifier: workapiv1.ResourceIdentifier{ | ||
Group: "apps", | ||
Resource: "deployments", | ||
Name: "cluster-auth-agent", | ||
Namespace: common.AddonAgentInstallNamespace, | ||
}, | ||
ProbeRules: []workapiv1.FeedbackRule{ | ||
{ | ||
Type: workapiv1.WellKnownStatusType, | ||
}, | ||
}, | ||
}, | ||
}, | ||
HealthCheck: func(identifier workapiv1.ResourceIdentifier, result workapiv1.StatusFeedbackResult) error { | ||
if len(result.Values) == 0 { | ||
return fmt.Errorf("no values are probed for deployment %s/%s", identifier.Namespace, identifier.Name) | ||
} | ||
for _, value := range result.Values { | ||
if value.Name != "ReadyReplicas" { | ||
continue | ||
} | ||
|
||
if *value.Value.Integer >= 1 { | ||
return nil | ||
} | ||
return fmt.Errorf("readyReplica is %d for deployement %s/%s", *value.Value.Integer, identifier.Namespace, identifier.Name) | ||
} | ||
return fmt.Errorf("readyReplica is not probed") | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters