Skip to content

Conversation

@vikash-s1
Copy link
Member

@vikash-s1 vikash-s1 commented Nov 11, 2025

Issue #, if available: N/A

Description of changes:
Add active node validation with nodeadm init command.

Description: Nodeadm init command performs hybrid node initialization process. However, there is no guarantee that the node is successfully registered with the Kubernetes cluster and is in "Ready" state. This change adds the Post-Initialization steps in nodeadm init command and validates if kubernetes client on node is able to fetch the required status from kubernetes api-server.

This validation is enabled by default and users can disable or update the validation wait-timeout duration. Default timeout is 10 minutes.

nodeadm int command update:
-w / --wait-timeout (optional flag) to disable or change the nodeadm init validation timeout

Internally it perform the validation in three steps:
Node Registration Validation - Verifies node is registered with the cluster
CNI Detection - Detects CNI plugin type (Cilium, Calico, or none)
Node Readiness Validation - Ensures node is in Ready state with proper network configuration

Testing (if applicable):
Added unit tests and tested on hybrid node

Successful case

{"level":"info","ts":"2025-08-22T21:55:22.160Z","caller":"init/init.go:163","msg":"Node initialization finished. Running post-initialization validation to check node status in cluster","timeout":600}
{"level":"info","ts":"2025-08-22T21:55:22.161Z","caller":"nodevalidator/node_registration.go:66","msg":"Starting node registration validation..."}

{"level":"info","ts":"2025-08-22T21:55:22.314Z","caller":"nodevalidator/node_registration.go:53","msg":"Node registered with cluster","nodeName":"mi-054xxxxxxxx","nodeUID":"bed194d3-xxxx-xxxx-xxxx-xxxxxxxx"}
{"level":"info","ts":"2025-08-22T21:55:22.314Z","caller":"nodevalidator/node_registration.go:96","msg":"Node registration validation completed successfully","nodeName":"mi-054xxxxxxxx"}
{"level":"info","ts":"2025-08-22T21:55:22.314Z","caller":"nodevalidator/cni_detector.go:248","msg":"Starting CNI detection validation..."}
{"level":"info","ts":"2025-08-22T21:55:22.314Z","caller":"nodevalidator/cni_detector.go:47","msg":"detected cni config file","cniType":"cilium"}
{"level":"info","ts":"2025-08-22T21:55:22.314Z","caller":"nodevalidator/cni_detector.go:144","msg":"CNI binaries","hasCilium":true,"hasCalico":false}
{"level":"info","ts":"2025-08-22T21:55:22.314Z","caller":"nodevalidator/cni_detector.go:54","msg":"detected cni binary files","cniType":"cilium"}
{"level":"info","ts":"2025-08-22T21:55:22.359Z","caller":"nodevalidator/cni_detector.go:171","msg":"CNI detected from NetworkUnavailable condition","reason":"CiliumIsUp"}
{"level":"info","ts":"2025-08-22T21:55:22.359Z","caller":"nodevalidator/cni_detector.go:65","msg":"CNI dynamically detected from node condition","cniType":"cilium"}
{"level":"info","ts":"2025-08-22T21:55:22.360Z","caller":"nodevalidator/cni_detector.go:279","msg":"CNI detection validation completed successfully","cniType":"cilium"}
{"level":"info","ts":"2025-08-22T21:55:22.360Z","caller":"nodevalidator/node_readiness.go:105","msg":"Starting node readiness validation..."}
{"level":"info","ts":"2025-08-22T21:55:22.404Z","caller":"nodevalidator/node_readiness.go:135","msg":"Node readiness validation completed successfully"}
{"level":"info","ts":"2025-08-22T21:55:22.404Z","caller":"init/init.go:167","msg":"Post-initialization validation successful. Node is ready in the Kubernetes cluster"}

Failed case when CNI supported binary not found

{"level":"info","ts":"2025-08-22T21:49:51.566Z","caller":"init/init.go:163","msg":"Node initialization finished. Running post-initialization validation to check node status in cluster","timeout":600}. //Started 


{"level":"info","ts":"2025-08-22T21:49:51.568Z","caller":"nodevalidator/node_registration.go:66","msg":"Starting node registration validation..."}
{"level":"info","ts":"2025-08-22T21:49:52.087Z","caller":"nodevalidator/node_registration.go:53","msg":"Node registered with cluster","nodeName":"ira-hybrid-node1","nodeUID":"9e18c479-61bf-4f71-8ded-xxxx"}
{"level":"info","ts":"2025-08-22T21:49:52.088Z","caller":"nodevalidator/node_registration.go:96","msg":"Node registration validation completed successfully","nodeName":"ira-hybrid-node1"}
{"level":"info","ts":"2025-08-22T21:49:52.088Z","caller":"nodevalidator/cni_detector.go:248","msg":"Starting CNI detection validation..."}
{"level":"info","ts":"2025-08-22T21:49:52.088Z","caller":"nodevalidator/cni_detector.go:47","msg":"detected cni config file","cniType":"cilium"}
{"level":"info","ts":"2025-08-22T21:49:52.088Z","caller":"nodevalidator/cni_detector.go:144","msg":"CNI binaries","hasCilium":false,"hasCalico":false}
{"level":"info","ts":"2025-08-22T21:49:54.089Z","caller":"nodevalidator/cni_detector.go:47","msg":"detected cni config file","cniType":"cilium"}
{"level":"info","ts":"2025-08-22T21:49:54.089Z","caller":"nodevalidator/cni_detector.go:144","msg":"CNI binaries","hasCilium":false,"hasCalico":false}
{"level":"info","ts":"2025-08-22T21:49:56.089Z","caller":"nodevalidator/cni_detector.go:47","msg":"detected cni config file","cniType":"cilium"}
{"level":"info","ts":"2025-08-22T21:49:56.089Z","caller":"nodevalidator/cni_detector.go:144","msg":"CNI binaries","hasCilium":false,"hasCalico":false}
{"level":"warn","ts":"2025-08-22T21:49:56.089Z","caller":"init/init.go:165","msg":"Post-initialization validation encountered issues but init completed successfully","error":"CNI detection validation failed: failed all three attempts: cni binary files: neither Cilium or Calico found in /opt/cni/bin"}

Documentation added/planned (if applicable):

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@vikash-s1 vikash-s1 force-pushed the node-active-validation branch from dd8e168 to 754124f Compare November 17, 2025 12:48
Comment on lines +132 to +134
runner.Register(validation.New("node-readiness", func(ctx context.Context, informer validation.Informer, obj *api.NodeConfig) error {
return nodevalidator.ExecuteActiveNodeValidator(ctx, log)
}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you not using the informer on purpose?

init.cmd.String(&init.configSource, "c", "config-source", "Source of node configuration. The format is a URI with supported schemes: [file, imds].")
init.cmd.StringSlice(&init.daemons, "d", "daemon", "Specify one or more of `containerd` and `kubelet`. This is intended for testing and should not be used in a production environment.")
init.cmd.StringSlice(&init.skipPhases, "s", "skip", fmt.Sprintf("Phases of the bootstrap to skip. Allowed values: [%s].", strings.Join(Phases(), ", ")))
init.cmd.String(&init.validationTimeout, "v", "validation-timeout", "Validation timeout duration (e.g., 30s, 10m, 1h). This is the timeout for node validation with the Kubernetes cluster after initialization. Set to '0s' to disable validation. Default: 10m")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make the flag name more specific? this sounds like it's for validations but it's not, it's for checking node registration

defer cancel()

log.Info("Node initialization finished. Running post-initialization validation to check node status in cluster", zap.Duration("timeout", validationTimeout))
if err := nodevalidator.ExecuteActiveNodeValidator(ctx, log); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to run this here instead of the flows.Initer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants