Skip to content

Commit

Permalink
Add validationOptions to nodegroup spec as well
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentportella committed Aug 16, 2024
1 parent 2b6d1db commit 370be58
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 11 deletions.
13 changes: 13 additions & 0 deletions deploy/crds/atlassian.com_nodegroups_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,19 @@ spec:
description: SkipPreTerminationChecks is an optional flag to skip
pre-termination checks during cycling
type: boolean
validationOptions:
description: ValidationOptions stores the settings to use for validating
state of nodegroups in kube and the cloud provider for cycling the
nodes.
properties:
skipMissingNamedNodes:
description: SkipMissingNodeNames is a boolean which determines
whether named nodes selected in a CNR must exist and be valid
nodes before cycling can begin. If set to true named nodes which
don't exist will be ignored rather than transitioning the CNR
to the failed phase.
type: boolean
type: object
required:
- cycleSettings
- nodeGroupName
Expand Down
2 changes: 2 additions & 0 deletions docs/automation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ spec:
cycleSettings:
method: Drain
concurrency: 1
validationOptions:
skipMissingNamedNodes: true
healthChecks:
- endpoint: http://{{ .NodeIP }}:8080/ready
regexMatch: Ready
Expand Down
5 changes: 5 additions & 0 deletions docs/cycling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ spec:
- "node-name-A"
- "node-name-B"

# Optional section - collection of validation options to define stricter or more lenient validation during cycling.
validationOptions:
# Optional field - Skip node names defined in the CNR that do not match any existing nodes in the Kubernetes API.
skipMissingNamedNodes: true|false

cycleNodeSettings:
# Method can be "Wait" or "Drain", defaults to "Drain" if not provided
# "Wait" will wait for pods on the node to complete, while "Drain" will forcefully drain them off the node
Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/atlassian/v1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,12 @@ type TLSConfig struct {
// sent as part of the request to the upstream host for mTLS.
Key string `json:"key,omitempty"`
}

// ValidationOptions stores the settings to use for validating state of nodegroups
// in kube and the cloud provider for cycling the nodes.
type ValidationOptions struct {
// SkipMissingNodeNames is a boolean which determines whether named nodes selected in a CNR must
// exist and be valid nodes before cycling can begin. If set to true named nodes which don't exist
// will be ignored rather than transitioning the CNR to the failed phase.
SkipMissingNamedNodes bool `json:"skipMissingNamedNodes,omitempty"`
}
9 changes: 0 additions & 9 deletions pkg/apis/atlassian/v1/cyclenoderequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ type CycleNodeRequestNode struct {
PrivateIP string `json:"privateIp,omitempty"`
}

// ValidationOptions stores the settings to use for validating state of nodegroups
// in kube and the cloud provider for cycling the nodes.
type ValidationOptions struct {
// SkipMissingNodeNames is a boolean which determines whether named nodes selected in a CNR must
// exist and be valid nodes before cycling can begin. If set to true named nodes which don't exist
// will be ignored rather than transitioning the CNR to the failed phase.
SkipMissingNamedNodes bool `json:"skipMissingNamedNodes,omitempty"`
}

// HealthCheckStatus groups all health checks status information for a node
type HealthCheckStatus struct {
// Ready keeps track of the first timestamp at which the node status was reported as "ready"
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/atlassian/v1/nodegroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ type NodeGroupSpec struct {
// CycleSettings stores the settings to use for cycling the nodes.
CycleSettings CycleSettings `json:"cycleSettings"`

// ValidationOptions stores the settings to use for validating state of nodegroups
// in kube and the cloud provider for cycling the nodes.
ValidationOptions ValidationOptions `json:"validationOptions,omitempty"`

// Healthchecks stores the settings to configure instance custom health checks
HealthChecks []HealthCheck `json:"healthChecks,omitempty"`

Expand Down
1 change: 1 addition & 0 deletions pkg/apis/atlassian/v1/zz_generated.deepcopy.go

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

7 changes: 5 additions & 2 deletions pkg/generation/cnr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package generation
import (
"context"
"fmt"
"github.com/atlassian-labs/cyclops/pkg/controller/cyclenoderequest"
"strings"

"github.com/atlassian-labs/cyclops/pkg/controller/cyclenoderequest"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -73,8 +74,9 @@ func GiveReason(cnr *atlassianv1.CycleNodeRequest, reason string) {
}
cnr.Annotations[cnrReasonAnnotationKey] = reason
}

// SetAPIVersion adds apiVersion annotation to the cnr
func SetAPIVersion(cnr *atlassianv1.CycleNodeRequest, clientVersion string){
func SetAPIVersion(cnr *atlassianv1.CycleNodeRequest, clientVersion string) {
if cnr.Annotations == nil {
cnr.Annotations = map[string]string{}
}
Expand Down Expand Up @@ -110,6 +112,7 @@ func GenerateCNR(nodeGroup atlassianv1.NodeGroup, nodes []string, name, namespac
PreTerminationChecks: nodeGroup.Spec.PreTerminationChecks,
SkipInitialHealthChecks: nodeGroup.Spec.SkipInitialHealthChecks,
SkipPreTerminationChecks: nodeGroup.Spec.SkipPreTerminationChecks,
ValidationOptions: nodeGroup.Spec.ValidationOptions,
},
}
}
Expand Down

0 comments on commit 370be58

Please sign in to comment.