Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NMO to use latest common version #92

Merged
merged 2 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions api/v1beta1/nodemaintenance_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"os"
"path/filepath"

"github.com/medik8s/common/pkg/nodes"

v1 "k8s.io/api/core/v1"
policyv1 "k8s.io/api/policy/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -41,11 +43,9 @@ const (
)

const (
EtcdQuorumPDBNewName = "etcd-guard-pdb" // The new name of the PDB - From OCP 4.11
EtcdQuorumPDBOldName = "etcd-quorum-guard" // The old name of the PDB - Up to OCP 4.10
EtcdQuorumPDBNamespace = "openshift-etcd"
LabelNameRoleMaster = "node-role.kubernetes.io/master"
LabelNameRoleControlPlane = "node-role.kubernetes.io/control-plane"
EtcdQuorumPDBNewName = "etcd-guard-pdb" // The new name of the PDB - From OCP 4.11
EtcdQuorumPDBOldName = "etcd-quorum-guard" // The old name of the PDB - Up to OCP 4.10
EtcdQuorumPDBNamespace = "openshift-etcd"
)

const (
Expand Down Expand Up @@ -193,7 +193,7 @@ func (v *NodeMaintenanceValidator) validateControlPlaneQuorum(nodeName string) e
} else if node == nil {
// this should have been catched already, but just in case
return fmt.Errorf(ErrorNodeNotExists, nodeName)
} else if !isControlPlaneNode(node) {
} else if !nodes.IsControlPlane(node) {
// not a control-plane node, nothing to do
return nil
}
Expand Down Expand Up @@ -241,13 +241,3 @@ func getNode(nodeName string, client client.Client) (*v1.Node, error) {
}
return &node, nil
}

mshitrit marked this conversation as resolved.
Show resolved Hide resolved
func isControlPlaneNode(node *v1.Node) bool {
if _, ok := node.Labels[LabelNameRoleMaster]; ok {
return true
}
if _, ok := node.Labels[LabelNameRoleControlPlane]; ok {
return true
}
return false
}
2 changes: 1 addition & 1 deletion api/v1beta1/nodemaintenance_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func getTestNode(name string, isControlPlane bool) *v1.Node {
}
if isControlPlane {
node.ObjectMeta.Labels = map[string]string{
LabelNameRoleControlPlane: "",
"node-role.kubernetes.io/control-plane": "",
mshitrit marked this conversation as resolved.
Show resolved Hide resolved
}
}
return node
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/go-logr/logr v1.2.3
github.com/medik8s/common v1.1.0
github.com/medik8s/common v1.2.0
github.com/onsi/ginkgo/v2 v2.9.1
github.com/onsi/gomega v1.27.4
github.com/sirupsen/logrus v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.2 h1:hAHbPm5IJGijwng3PWk09JkG9WeqChjprR5s9bBZ+OM=
github.com/matttproud/golang_protobuf_extensions v1.0.2/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/medik8s/common v1.1.0 h1:JVPQPHKIA0dbVJOX6YUVph7NT88UaMu40SFMTpPac3Q=
github.com/medik8s/common v1.1.0/go.mod h1:ZT/3hfMXJLmZEcqmxRWB5LGC8Wl+qKGGQ4zM8hOE7PY=
github.com/medik8s/common v1.2.0 h1:xgQOijD3rEn+PfCd4lJuV3WFdt5QA6SIaqF01rRp2as=
github.com/medik8s/common v1.2.0/go.mod h1:ZT/3hfMXJLmZEcqmxRWB5LGC8Wl+qKGGQ4zM8hOE7PY=
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8=
Expand Down
10 changes: 10 additions & 0 deletions vendor/github.com/medik8s/common/pkg/labels/labels.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 26 additions & 6 deletions vendor/github.com/medik8s/common/pkg/lease/manager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/github.com/medik8s/common/pkg/nodes/nodes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ github.com/mailru/easyjson/jwriter
# github.com/matttproud/golang_protobuf_extensions v1.0.2
## explicit; go 1.9
github.com/matttproud/golang_protobuf_extensions/pbutil
# github.com/medik8s/common v1.1.0
# github.com/medik8s/common v1.2.0
## explicit; go 1.20
github.com/medik8s/common/pkg/labels
github.com/medik8s/common/pkg/lease
github.com/medik8s/common/pkg/nodes
# github.com/mitchellh/go-wordwrap v1.0.0
## explicit
github.com/mitchellh/go-wordwrap
Expand Down