Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [sc-117029] Add keep annotation to KOTS #5037

Merged
merged 2 commits into from
Dec 10, 2024
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion dev/dockerfiles/kotsadm/Dockerfile.local
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 0 additions & 1 deletion dev/manifests/kotsadm/minio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ spec:
volumeMounts:
- mountPath: /data
name: miniodata # this is where the data is stored

volumeClaimTemplates:
- metadata:
name: miniodata
Expand Down
7 changes: 7 additions & 0 deletions pkg/operator/client/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

would be nice to mention the reason in the log message as well

Suggested change
logger.Infof("skipping deletion of resource %s/%s", o.Kind, o.Metadata.Name)
logger.Infof("skipping deletion of resource %s/%s because kots.io/keep annotation is set", o.Kind, o.Metadata.Name)

delete = false
}

decodedPreviousMap[k] = previousObject{
spec: string(decodedPreviousDoc),
delete: delete,
Expand Down
7 changes: 4 additions & 3 deletions pkg/operator/client/gvkn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading