From 803e35da1122082125601d4249cd130561f2afdc Mon Sep 17 00:00:00 2001 From: Gerard Nguyen Date: Mon, 9 Dec 2024 21:43:02 +1100 Subject: [PATCH 1/2] wip --- Makefile | 2 +- dev/dockerfiles/kotsadm/Dockerfile.local | 2 +- pkg/operator/client/delete.go | 7 +++++++ pkg/operator/client/gvkn.go | 7 ++++--- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 8e03a180b9..0af03185c4 100644 --- a/Makefile +++ b/Makefile @@ -125,7 +125,7 @@ debug-build: .PHONY: debug debug: debug-build - LOG_LEVEL=$(LOG_LEVEL) dlv --listen=:2345 --headless=true --api-version=2 exec ./bin/kotsadm-debug api + LOG_LEVEL=$(LOG_LEVEL) /dlv --listen=:30001 --headless=true --api-version=2 exec ./bin/kotsadm-debug api .PHONY: web web: diff --git a/dev/dockerfiles/kotsadm/Dockerfile.local b/dev/dockerfiles/kotsadm/Dockerfile.local index 0eb5324cd7..db1f505a51 100644 --- a/dev/dockerfiles/kotsadm/Dockerfile.local +++ b/dev/dockerfiles/kotsadm/Dockerfile.local @@ -1,6 +1,6 @@ FROM golang:1.23-alpine AS dlv-builder -RUN go install github.com/go-delve/delve/cmd/dlv@v1.22.1 +RUN go install github.com/go-delve/delve/cmd/dlv@v1.23.1 FROM golang:1.23-alpine diff --git a/pkg/operator/client/delete.go b/pkg/operator/client/delete.go index 90477a0dfa..3f51284011 100644 --- a/pkg/operator/client/delete.go +++ b/pkg/operator/client/delete.go @@ -79,6 +79,13 @@ func (c *Client) diffAndDeleteManifests(opts DiffAndDeleteOptions) error { } } + // if this is a keep resource, don't delete it + // e.g. for migration to Helm v1beta2 + if keep, ok := o.Metadata.Annotations["kots.io/keep"]; ok && keep == "true" { + logger.Infof("Skipping deletion of resource %s/%s", o.Kind, o.Metadata.Name) + delete = false + } + decodedPreviousMap[k] = previousObject{ spec: string(decodedPreviousDoc), delete: delete, diff --git a/pkg/operator/client/gvkn.go b/pkg/operator/client/gvkn.go index 169571e534..b1bba34ee4 100644 --- a/pkg/operator/client/gvkn.go +++ b/pkg/operator/client/gvkn.go @@ -14,9 +14,10 @@ type OverlySimpleGVKWithName struct { } type OverlySimpleMetadata struct { - Name string `yaml:"name"` - Namespace string `yaml:"namespace"` - Labels map[string]string `yaml:"labels,omitempty"` + Name string `yaml:"name"` + Namespace string `yaml:"namespace"` + Labels map[string]string `yaml:"labels,omitempty"` + Annotations map[string]string `yaml:"annotations,omitempty"` } func GetGVKWithNameAndNs(content []byte, baseNS string) (string, OverlySimpleGVKWithName) { From e5e5969cd52316de8cc43b69575eb2e2dd9dbc28 Mon Sep 17 00:00:00 2001 From: Gerard Nguyen Date: Tue, 10 Dec 2024 12:26:57 +1100 Subject: [PATCH 2/2] misc --- dev/manifests/kotsadm/minio.yaml | 1 - pkg/operator/client/delete.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/manifests/kotsadm/minio.yaml b/dev/manifests/kotsadm/minio.yaml index 3665d80a9b..06beaf1191 100644 --- a/dev/manifests/kotsadm/minio.yaml +++ b/dev/manifests/kotsadm/minio.yaml @@ -70,7 +70,6 @@ spec: volumeMounts: - mountPath: /data name: miniodata # this is where the data is stored - volumeClaimTemplates: - metadata: name: miniodata diff --git a/pkg/operator/client/delete.go b/pkg/operator/client/delete.go index 3f51284011..8b89e564cf 100644 --- a/pkg/operator/client/delete.go +++ b/pkg/operator/client/delete.go @@ -82,7 +82,7 @@ func (c *Client) diffAndDeleteManifests(opts DiffAndDeleteOptions) error { // if this is a keep resource, don't delete it // e.g. for migration to Helm v1beta2 if keep, ok := o.Metadata.Annotations["kots.io/keep"]; ok && keep == "true" { - logger.Infof("Skipping deletion of resource %s/%s", o.Kind, o.Metadata.Name) + logger.Infof("skipping deletion of resource %s/%s", o.Kind, o.Metadata.Name) delete = false }