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

Initial init changes for dynamic config. #27

Merged
merged 9 commits into from
Apr 10, 2024
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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this change can be put in a separate function. Let's keep functions short.

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 {
abhishekdwivedi3060 marked this conversation as resolved.
Show resolved Hide resolved
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)
abhishekdwivedi3060 marked this conversation as resolved.
Show resolved Hide resolved

return initp.updateStatus(ctx, metadata)
Expand Down
Loading