mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
go.mod still declared `module github.com/hanzoai/deploy` after the repo was renamed. A Go module path is not cosmetic — it is the resolvable location. So `go get github.com/hanzoai/cd` could not work, and anything importing this module had to spell a name that no longer exists at that address. The build log of v3.6.0 is where it surfaced: the compiler was still emitting github.com/hanzoai/deploy/cmd/cd/commands. 3541 import paths across 690 .go, 19 .proto, 4 .yaml, 3 .sh, 2 .mod, Procfile and Makefile. Plus the 62 ghcr.io/hanzoai/deploy image references, moved to ghcr.io/hanzoai/cd to match hanzo.yml's build target — a distinct string from the module path, replaced separately so neither could clobber the other. go mod tidy clean, CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./... clean. Co-authored-by: Hanzo Dev <[email protected]>
58 lines
2.3 KiB
Go
58 lines
2.3 KiB
Go
package health
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
appsv1 "k8s.io/api/apps/v1"
|
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
|
|
"github.com/hanzoai/cd/gitops-engine/pkg/utils/kube"
|
|
)
|
|
|
|
func getDaemonSetHealth(obj *unstructured.Unstructured) (*HealthStatus, error) {
|
|
gvk := obj.GroupVersionKind()
|
|
switch gvk {
|
|
case appsv1.SchemeGroupVersion.WithKind(kube.DaemonSetKind):
|
|
var daemon appsv1.DaemonSet
|
|
err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &daemon)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to convert unstructured DaemonSet to typed: %w", err)
|
|
}
|
|
return getAppsv1DaemonSetHealth(&daemon)
|
|
default:
|
|
return nil, fmt.Errorf("unsupported DaemonSet GVK: %s", gvk)
|
|
}
|
|
}
|
|
|
|
func getAppsv1DaemonSetHealth(daemon *appsv1.DaemonSet) (*HealthStatus, error) {
|
|
// Borrowed at kubernetes/kubectl/rollout_status.go https://github.com/kubernetes/kubernetes/blob/5232ad4a00ec93942d0b2c6359ee6cd1201b46bc/pkg/kubectl/rollout_status.go#L110
|
|
if daemon.Generation > daemon.Status.ObservedGeneration {
|
|
return &HealthStatus{
|
|
Status: HealthStatusProgressing,
|
|
Message: "Waiting for rollout to finish: observed daemon set generation less than desired generation",
|
|
}, nil
|
|
}
|
|
if daemon.Spec.UpdateStrategy.Type == appsv1.OnDeleteDaemonSetStrategyType {
|
|
return &HealthStatus{
|
|
Status: HealthStatusHealthy,
|
|
Message: fmt.Sprintf("daemon set %d out of %d new pods have been updated", daemon.Status.UpdatedNumberScheduled, daemon.Status.DesiredNumberScheduled),
|
|
}, nil
|
|
}
|
|
if daemon.Status.UpdatedNumberScheduled < daemon.Status.DesiredNumberScheduled {
|
|
return &HealthStatus{
|
|
Status: HealthStatusProgressing,
|
|
Message: fmt.Sprintf("Waiting for daemon set %q rollout to finish: %d out of %d new pods have been updated...", daemon.Name, daemon.Status.UpdatedNumberScheduled, daemon.Status.DesiredNumberScheduled),
|
|
}, nil
|
|
}
|
|
if daemon.Status.NumberAvailable < daemon.Status.DesiredNumberScheduled {
|
|
return &HealthStatus{
|
|
Status: HealthStatusProgressing,
|
|
Message: fmt.Sprintf("Waiting for daemon set %q rollout to finish: %d of %d updated pods are available...", daemon.Name, daemon.Status.NumberAvailable, daemon.Status.DesiredNumberScheduled),
|
|
}, nil
|
|
}
|
|
return &HealthStatus{
|
|
Status: HealthStatusHealthy,
|
|
}, nil
|
|
}
|