Skip to content
Draft
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
43 changes: 43 additions & 0 deletions cmd/admin/v2/housekeepeing.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v2

import (
"context"
"fmt"

adminv2 "github.com/metal-stack/api/go/metalstack/admin/v2"
"github.com/metal-stack/cli/cmd/config"
Expand Down Expand Up @@ -50,9 +51,19 @@ func newHousekeepingCmd(c *config.Config) *cobra.Command {
},
}

networksConsistentCmd := &cobra.Command{
Use: "networks-consistent",
Short: "execute a read only check for network and ip inconsistencies",
Long: "identifies inconsistencies between metal networks and ips and ipam networks and ips",
RunE: func(cmd *cobra.Command, args []string) error {
return w.networksConsistent(cmd.Context())
},
}

housekeepingCmd.AddCommand(machineLivelinessCmd)
housekeepingCmd.AddCommand(machineVPNConnectedCmd)
housekeepingCmd.AddCommand(machineResurrectCmd)
housekeepingCmd.AddCommand(networksConsistentCmd)

return housekeepingCmd
}
Expand Down Expand Up @@ -83,3 +94,35 @@ func (h *housekeeping) machineResurrect(ctx context.Context) (err error) {

return h.c.ListPrinter.Print(result.ModifiedMachines)
}

func (h *housekeeping) networksConsistent(ctx context.Context) (err error) {
result, err := h.c.Client.Adminv2().Housekeeping().NetworksConsistent(ctx, &adminv2.HousekeepingServiceNetworksConsistentRequest{})
if err != nil {
return err
}

_ = h.c.DescribePrinter.Print(result)

if len(result.NetworksMissingInMetal) > 0 {
_, _ = fmt.Fprint(h.c.Out, `run the following command inside of a pod of the ipam deployment to get the list of existing prefixes:
kubectl exec -it ipam-xxx-yyy -- /cli prefix list

then select one of the networks listed in networksMissingInMetal and delete it in ipam with
kubectl exec -it ipam-xxx-yyy -- /cli prefix delete --cidr 1.2.3.0/24 [--namespace optional-namespace]


`)
}
if len(result.IpsMissingInMetal) > 0 {
_, _ = fmt.Fprint(h.c.Out, `run the following command inside of a pod of the ipam deployment to get the list of existing ips:
kubectl exec -it ipam-xxx-yyy -- /cli ip list --prefix prefix-of-the-given-metal-network

then select one of the ips listed in ipsMissingInMetal and delete it in ipam with
kubectl exec -it ipam-xxx-yyy -- /cli ip release --ip 1.2.3.4 --prefix 1.2.3.0/24 [--namespace optional-namespace]


`)
}

return
}
38 changes: 20 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/fatih/color v1.19.0
github.com/google/go-cmp v0.7.0
github.com/google/uuid v1.6.0
github.com/metal-stack/api v0.10.0
github.com/metal-stack/api v0.10.1-0.20261124151059-2485f175e693
github.com/metal-stack/metal-console v0.8.2
github.com/metal-stack/metal-lib v0.26.4
github.com/metal-stack/v v1.0.3
Expand All @@ -24,10 +24,10 @@ require (

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.2 // indirect
buf.build/go/protovalidate v1.4.0 // indirect
buf.build/go/protovalidate v1.4.1 // indirect
buf.build/go/protoyaml v0.8.0 // indirect
cel.dev/cel-go v0.33.2 // indirect
cel.dev/expr v0.25.3 // indirect
cel.dev/cel-go v0.33.4 // indirect
cel.dev/expr v0.26.0 // indirect
connectrpc.com/connect/v2 v2.0.2 // indirect
filippo.io/edwards25519 v1.2.0 // indirect
github.com/akutz/memconn v0.1.0 // indirect
Expand Down Expand Up @@ -59,14 +59,15 @@ require (
github.com/huin/goupnp v1.3.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jsimonetti/rtnetlink v1.4.2 // indirect
github.com/klauspost/compress v1.20.3 // indirect
github.com/klauspost/compress v1.20.5 // indirect
github.com/klauspost/connect-compress/v2 v2.1.1 // indirect
github.com/klauspost/cpuid/v2 v2.4.2 // indirect
github.com/mattn/go-colorable v0.1.16 // indirect
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/mattn/go-runewidth v0.0.31 // indirect
github.com/mdlayher/netlink v1.11.2 // indirect
github.com/mdlayher/socket v0.8.0 // indirect
github.com/minio/minlz v1.2.3 // indirect
github.com/minio/minlz v1.3.0 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/oklog/ulid/v2 v2.1.2 // indirect
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
Expand All @@ -79,7 +80,7 @@ require (
github.com/safchain/ethtool v0.7.0 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/spf13/pflag v1.1.0 // indirect
github.com/stretchr/objx v0.8.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tailscale/certstore v0.1.1-0.20260409135935-3638fb84b77d // indirect
Expand All @@ -89,27 +90,28 @@ require (
github.com/tailscale/web-client-prebuilt v0.0.0-20260917222731-e0ed2d0d0fea // indirect
github.com/tailscale/wireguard-go v0.0.0-20260928213032-417aef361226 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/zeebo/xxh3 v1.1.1-0.20260908150653-f7225998cebf // indirect
go.yaml.in/yaml/v2 v2.4.5 // indirect
go.yaml.in/yaml/v3 v3.0.6 // indirect
go4.org/mem v0.0.0-20240501181205-ae6ca9944745 // indirect
go4.org/netipx v0.0.0-20260823151212-3075585bcbeb // indirect
golang.org/x/crypto v0.58.0 // indirect
golang.org/x/exp v0.0.0-20261014143641-f0251eb4aa3e // indirect
golang.org/x/net v0.62.0 // indirect
golang.org/x/oauth2 v0.37.0 // indirect
golang.org/x/sync v0.24.0 // indirect
golang.org/x/sys v0.49.0 // indirect
golang.org/x/term v0.47.0 // indirect
golang.org/x/text v0.43.0 // indirect
golang.org/x/crypto v0.59.0 // indirect
golang.org/x/exp v0.0.0-20261124000051-d6646c509b6d // indirect
golang.org/x/net v0.63.0 // indirect
golang.org/x/oauth2 v0.38.0 // indirect
golang.org/x/sync v0.25.0 // indirect
golang.org/x/sys v0.50.0 // indirect
golang.org/x/term v0.48.0 // indirect
golang.org/x/text v0.44.0 // indirect
golang.org/x/time v0.16.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
golang.zx2c4.com/wireguard/windows v1.1.1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20261104224025-d1e00e9f33ab // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20261104224025-d1e00e9f33ab // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20261123191846-1e707ab9fbc2 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20261123191846-1e707ab9fbc2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gvisor.dev/gvisor v0.0.0-20260915211658-a6f909f08a72 // indirect
k8s.io/apimachinery v0.37.1 // indirect
k8s.io/apimachinery v0.37.2 // indirect
sigs.k8s.io/json v0.0.0-20260909141634-11ed52e25bc5 // indirect
tailscale.com v1.104.5 // indirect
)
Loading