Skip to content

Commit

Permalink
fixed machine-id taking
Browse files Browse the repository at this point in the history
Signed-off-by: viktor.kramarenko <[email protected]>
  • Loading branch information
ViktorKram committed Jan 19, 2024
1 parent 3d95db1 commit 9713f94
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions images/agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ limitations under the License.
package config

import (
"bytes"
"fmt"
"os"
"os/exec"
"sds-node-configurator/pkg/logger"
"time"
)
Expand Down Expand Up @@ -75,12 +77,17 @@ func NewConfig() (*Options, error) {
func getMachineId() (string, error) {
id := os.Getenv(MachineID)
if id == "" {
byteId, err := os.ReadFile("/host-root/etc/machine-id")
args := []string{"-m", "-u", "-i", "-n", "-p", "-t", "1", "cat", "/etc/machine-id"}

var stdout *bytes.Buffer
cmd := exec.Command("/usr/bin/nsenter", args...)
cmd.Stdout = stdout
err := cmd.Run()
if err != nil {
return "", err
}

id = string(byteId)
id = stdout.String()
}

return id, nil
Expand Down

0 comments on commit 9713f94

Please sign in to comment.