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

fix: relays annotation value is readonly and cannot be updated #227

Merged
merged 3 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ RUN go mod download
COPY . .
RUN make build

FROM alpine:latest as runtime
# pinning to 3.14.10 which does not have any vulnerabilities
# track https://hub.docker.com/_/alpine/tags for vulnerability fixes in latest version and move back to using latest
FROM alpine:3.14.10 as runtime
LABEL description="Run container"

WORKDIR /usr/bin
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.initialize
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ RUN wget -O migrate.tar.gz -q https://github.com/golang-migrate/migrate/releases
COPY . /build
RUN go build -ldflags "-s" -o paralus-init scripts/initialize/main.go

FROM alpine:latest as runtime
# pinning to 3.14.10 which does not have any vulnerabilities
# track https://hub.docker.com/_/alpine/tags for vulnerability fixes in latest version and move back to using latest
FROM alpine:3.14.10 as runtime
LABEL description="Run container"

WORKDIR /usr/bin
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.synchronizer
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ COPY . /build
WORKDIR /build
RUN go build -ldflags "-s" -o start-sync scripts/kratos/providers_sync.go

FROM alpine:latest as runtime
# pinning to 3.14.10 which does not have any vulnerabilities
# track https://hub.docker.com/_/alpine/tags for vulnerability fixes in latest version and move back to using latest
FROM alpine:3.14.10 as runtime
LABEL description="Run container"

WORKDIR /usr/bin
Expand Down
15 changes: 15 additions & 0 deletions pkg/service/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,24 @@ func (s *clusterService) Update(ctx context.Context, cluster *infrav3.Cluster) (
cdb.ShareMode = cluster.Spec.ShareMode.String()
cdb.Labels = json.RawMessage(lbsBytes)

// validate cluster annotation to retain the relay information within annotations
existingAnnotations := make(map[string]string)
if cdb.Annotations != nil {
if err = json.Unmarshal(cdb.Annotations, &existingAnnotations); err != nil {
return nil, err
}
}
if len(cluster.Metadata.Annotations) > 0 {
if existingAnnotations["relays"] != cluster.Metadata.Annotations["relays"] {
_log.Warn("relays annotation populated during cluster bootstrapping is readonly, ignoring updates from user")
}
cluster.Metadata.Annotations["relays"] = existingAnnotations["relays"]
annBytes, _ := json.Marshal(cluster.Metadata.Annotations)
cdb.Annotations = json.RawMessage(annBytes)
} else {
// update back the relay information
cluster.Metadata.Annotations = make(map[string]string)
cluster.Metadata.Annotations["relays"] = existingAnnotations["relays"]
}

//location of cluster is updated
Expand Down