-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculate percentage of maxUnavailable from matching nodes
Instead of calculating number of maxUnavailable nodes from all nmstate enabled nodes, use matching nodes only. Signed-off-by: Radim Hrazdil <[email protected]>
- Loading branch information
Radim Hrazdil
committed
Mar 25, 2021
1 parent
a0c316b
commit 28be74c
Showing
7 changed files
with
75 additions
and
44 deletions.
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
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,22 @@ | ||
package enactment | ||
|
||
import ( | ||
"context" | ||
|
||
nmstateapi "github.com/nmstate/kubernetes-nmstate/api/shared" | ||
nmstatev1beta1 "github.com/nmstate/kubernetes-nmstate/api/v1beta1" | ||
enactmentconditions "github.com/nmstate/kubernetes-nmstate/pkg/enactmentstatus/conditions" | ||
"github.com/pkg/errors" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
func CountByPolicy(cli client.Client, policy *nmstatev1beta1.NodeNetworkConfigurationPolicy) (enactmentconditions.ConditionCount, error) { | ||
enactments := nmstatev1beta1.NodeNetworkConfigurationEnactmentList{} | ||
policyLabelFilter := client.MatchingLabels{nmstateapi.EnactmentPolicyLabel: policy.GetName()} | ||
err := cli.List(context.TODO(), &enactments, policyLabelFilter) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "getting enactment list failed") | ||
} | ||
enactmentCount := enactmentconditions.Count(enactments, policy.Generation) | ||
return enactmentCount, nil | ||
} |
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
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
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