Skip to content

Commit

Permalink
Populating pod annotation with conf file.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Jan 30, 2024
1 parent d6e6aa1 commit 7f9e2fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 0 additions & 3 deletions pkg/common-env.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package pkg
import (
goctx "context"
"os"
"strconv"
"strings"

"github.com/go-logr/logr"
Expand All @@ -27,7 +26,6 @@ type InitParams struct {
networkInfo *networkInfo
podName string
namespace string
rackID string
nodeID string
workDir string
tlsName string
Expand Down Expand Up @@ -108,7 +106,6 @@ func PopulateInitParams(ctx goctx.Context) (*InitParams, error) {
k8sClient: k8sClient,
podName: podName,
namespace: namespace,
rackID: strconv.Itoa(rack.ID),
nodeID: nodeID,
workDir: workDir,
logger: logger,
Expand Down
27 changes: 27 additions & 0 deletions pkg/update_pod_status_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/util/retry"
"sigs.k8s.io/controller-runtime/pkg/client"

asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1"
Expand Down Expand Up @@ -597,6 +598,32 @@ func (initp *InitParams) manageVolumesAndUpdateStatus(ctx context.Context, resta
metadata.InitializedVolumes = initializedVolumes
metadata.DirtyVolumes = dirtyVolumes

data, err := os.ReadFile(aerospikeConf)
if err != nil {
return err
}

if pod.Annotations == nil {
pod.Annotations = make(map[string]string)
}

pod.Annotations["aerospikeConf"] = string(data)

if err := retry.OnError(retry.DefaultBackoff, func(err error) bool {
// Customize the error check for retrying, return true to retry, false to stop retrying
return true
}, func() error {
// Patch the resource
if err := initp.k8sClient.Update(ctx, pod); err != nil {
return err
}

initp.logger.Info("Pod status patched successfully", "podname", initp.podName)
return nil
}); err != nil {
return err
}

initp.logger.Info("Updating pod status", "podname", initp.podName)

return initp.updateStatus(ctx, metadata)
Expand Down

0 comments on commit 7f9e2fd

Please sign in to comment.