Skip to content

Commit

Permalink
Fix annotation, Skip nil response (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
HomayoonAlimohammadi authored Aug 30, 2024
1 parent b532314 commit 0985ddb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions pkg/ck8s/config_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ func GenerateInitControlPlaneConfig(cfg InitControlPlaneConfig) (apiv1.Bootstrap

// Since CAPI handles the lifecycle management of Kubernetes nodes, k8s-snap should only focus on
// cleaning up microcluster and files during upgrades.
if out.ClusterConfig.Annotations != nil {
if _, ok := out.ClusterConfig.Annotations[apiv1.AnnotationSkipCleanupKubernetesNodeOnRemove]; !ok {
out.ClusterConfig.Annotations[apiv1.AnnotationSkipCleanupKubernetesNodeOnRemove] = "true"
}
if out.ClusterConfig.Annotations == nil {
out.ClusterConfig.Annotations = map[string]string{}
}

if _, ok := out.ClusterConfig.Annotations[apiv1.AnnotationSkipCleanupKubernetesNodeOnRemove]; !ok {
out.ClusterConfig.Annotations[apiv1.AnnotationSkipCleanupKubernetesNodeOnRemove] = "true"
}

// features
Expand Down
2 changes: 1 addition & 1 deletion pkg/ck8s/workload_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (w *Workload) doK8sdRequest(ctx context.Context, method, endpoint string, r
if responseBody.Error != "" {
return fmt.Errorf("k8sd request failed: %s", responseBody.Error)
}
if responseBody.Metadata == nil {
if responseBody.Metadata == nil || response == nil {
// Nothing to decode
return nil
}
Expand Down

0 comments on commit 0985ddb

Please sign in to comment.