-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use SNO check to disable node-removal controller
node-removal controller wouldn't be necessary at the end of the lifecycle of SNO nodes as the entire cluster would go down Signed-off-by: jakobmoellerdev <[email protected]>
- Loading branch information
1 parent
6353580
commit 3982605
Showing
4 changed files
with
56 additions
and
33 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
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,33 @@ | ||
package cluster | ||
|
||
import ( | ||
"context" | ||
corev1 "k8s.io/api/core/v1" | ||
"os" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/log" | ||
) | ||
|
||
type SNOCheck interface { | ||
IsSNO(ctx context.Context) bool | ||
} | ||
|
||
func NewMasterSNOCheck(clnt client.Client) SNOCheck { | ||
return &masterSNOCheck{clnt: clnt} | ||
} | ||
|
||
type masterSNOCheck struct { | ||
clnt client.Client | ||
} | ||
|
||
func (chk *masterSNOCheck) IsSNO(ctx context.Context) bool { | ||
logger := log.FromContext(ctx) | ||
nodes := &corev1.NodeList{} | ||
if err := chk.clnt.List(context.Background(), nodes, client.MatchingLabels{ | ||
ControlPlaneIDLabel: "", | ||
}); err != nil { | ||
logger.Error(err, "unable to retrieve nodes for SNO check with lease configuration") | ||
os.Exit(1) | ||
} | ||
return nodes.Items != nil && len(nodes.Items) == 1 | ||
} |