Skip to content

Commit

Permalink
check ephemeral metadata is set before delete
Browse files Browse the repository at this point in the history
  • Loading branch information
com6056 committed Jan 30, 2025
1 parent 4f5d93b commit e89d0ad
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions utils/replicaset/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,18 +640,26 @@ func SyncEphemeralPodMetadata(metadata *metav1.ObjectMeta, existingPodMetadata,
if existingPodMetadata != nil {
for k := range existingPodMetadata.Annotations {
if desiredPodMetadata == nil || !isMetadataStillDesired(k, desiredPodMetadata.Annotations) {
if metadata.Annotations != nil {
delete(metadata.Annotations, k)
modified = true
if metadata.Annotations == nil {
continue
}
if _, ok := metadata.Annotations[k]; !ok {
continue
}
delete(metadata.Annotations, k)
modified = true
}
}
for k := range existingPodMetadata.Labels {
if desiredPodMetadata == nil || !isMetadataStillDesired(k, desiredPodMetadata.Labels) {
if metadata.Labels != nil {
delete(metadata.Labels, k)
modified = true
if metadata.Labels == nil {
continue
}
if _, ok := metadata.Labels[k]; !ok {
continue
}
delete(metadata.Labels, k)
modified = true
}
}
}
Expand Down

0 comments on commit e89d0ad

Please sign in to comment.