Files
compute/service/kind_tab_test.go
zeekayandHanzo Dev 86f85934e1 visor is the multi-cloud path: no Kubernetes client at all
visor manages VMs across DO/Hetzner/Lightsail/Azure/GCP/Proxmox. It is
deliberately the non-cluster path, and it linked client-go twice.

autoscaler/ is deleted. It listed Pending pods via rest.InClusterConfig and
scaled DOKS node pools — a cluster autoscaler living inside the VM manager. It
was gated on autoscalerClusters, which is set in no deployment, so it had never
run. service/doks.go is untouched: pure godo, still serving node-pool CRUD.

object/coordinator.go now elects over ha.Membership — the interface hanzoai/ha
already defines, reused rather than re-declared. With nothing registered the
default reports an ERROR, not an empty set: an empty set is the positive claim
"I have no peers", which is exactly the lie that double-debits a two-replica
Deployment. Only an error carries "I don't know who my peers are".

That default means no source, no metering, so a source had to be chosen. It is
ha.Static in main.go's serve(), paired with replicas: 1 in universe. The sole
process is the sole writer, so exactly-once holds by construction. It is
registered in serve() and NOT in visor.Bootstrap(), which is shared verbatim
with the embedded cloud mount whose replica count is cloud's, not ours.

The two halves are one change: ha.Static at replicas: 2 bills every customer
twice an hour. Both sides now carry a comment pointing at the other.

Also corrects the comment that made this invisible. Shared() said "Postgres
under both backends"; under Base it is the pod-local _global SQLite coord, so
the lease PK does not span pods and the election is the only thing holding the
line — not belt-and-braces over a global constraint, as the doc implied.

k8s/rbac.yaml is a bare ServiceAccount: visor holds zero cluster permissions.
go.mod loses every k8s.io/* and sigs.k8s.io/* entry, not just client-go.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-05 19:07:11 -07:00

57 lines
2.2 KiB
Go

// Copyright 2023 Hanzo Industries Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package service
import "testing"
// A tab is a machine you can OPEN. The kinds nest — machine ⊂ tab ⊂ bot — so a
// terminal appears at tab and everything richer keeps it. Writing it as a
// threshold rather than a set is what makes a bot openable in Tabs for free;
// before there was no way to look inside one you had launched.
func TestKindTab_OpensIsAThresholdNotASet(t *testing.T) {
for _, tc := range []struct {
kind string
want bool
}{
{KindTab, true}, // the reason the kind exists
{KindBot, true}, // a bot is a tab that also runs the agent
{KindMachine, false}, // bare compute publishes nothing
{KindCluster, false},
{KindFunction, false},
{"", false}, // unknown falls back to machine
{"garbage", false},
} {
if got := Opens(tc.kind); got != tc.want {
t.Errorf("Opens(%q) = %v, want %v", tc.kind, got, tc.want)
}
}
}
// tab has to survive the tag round trip, or a launch records it and every
// read-back — emit, sweep, destroy — silently sees `machine` instead.
func TestKindTab_SurvivesCanonicalisationAndTagging(t *testing.T) {
if got := CanonicalKind("tab"); got != KindTab {
t.Fatalf("CanonicalKind(tab) = %q — an unknown kind falls back to machine, so tab would never reach a droplet", got)
}
if got := CanonicalKind(" tab "); got != KindTab {
t.Errorf("CanonicalKind trims, so padded input must still be tab, got %q", got)
}
spec := &CreateMachineSpec{}
SetKind(spec, KindTab)
if got := spec.Tags[kindTagKey]; got != KindTab {
t.Errorf("SetKind wrote %q to the kind tag, want %q", got, KindTab)
}
}