Skip to content

Commit

Permalink
landscape-config --silent --register-if-needed
Browse files Browse the repository at this point in the history
landscape-client (24.08+git6375-0ubuntu0) added the new
--register-if-needed flag for landscape-config, allowing it to refresh
an existing registration instead of unconditionally creating a new one
for a computer already registered with Landscape.

There are situations when wsl-pro-service subprocesses lansdcape-config
on an already registered computer. That creates a new registration and,
even though Landscape server has some logic to detect that the new
registration belongs to an existing computer, it loses data that takes
long to recover, such as package version information.

Since the landscape-client version in the latest-stable PPA is already
over that version we should be able to add this flag to wsl-pro-service
and prevent that behaviour.
  • Loading branch information
CarlosNihelton committed Jan 16, 2025
1 parent 0df1521 commit 8ba7dab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion wsl-pro-service/internal/system/landscape.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (s *System) fixAndEnableLandscapeFromConfig(ctx context.Context, landscapeC
}

// TODO: check foreground/background
cmd := s.backend.LandscapeConfigExecutable(ctx, "--config", landscapeConfigPath, "--silent")
cmd := s.backend.LandscapeConfigExecutable(ctx, "--config", landscapeConfigPath, "--silent", "--register-if-needed")
if _, err := runCommand(cmd); err != nil {
return fmt.Errorf("could not enable Landscape: %v", err)
}
Expand Down
9 changes: 7 additions & 2 deletions wsl-pro-service/internal/testutils/mock_executables.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ func LandscapeConfigMock(t *testing.T) {
}

return exitOk
case 3:
// landscape-config [--config|-c] FILENAME --silent
case 4:
// landscape-config [--config|-c] FILENAME --silent --register-if-needeed
if argv[0] != "-c" && argv[0] != "--config" {
fmt.Fprintf(os.Stderr, "Mock not implemented for arg %q\n", argv[0])
return exitBadUsage
Expand All @@ -416,6 +416,11 @@ func LandscapeConfigMock(t *testing.T) {
return exitBadUsage
}

if argv[3] != "--register-if-needed" {
fmt.Fprintf(os.Stderr, "Mock not implemented for arg %q\n", argv[3])
return exitBadUsage
}

if envExists(LandscapeEnableErr) {
fmt.Fprintln(os.Stderr, "Enable: Mock error")
return exitError
Expand Down

0 comments on commit 8ba7dab

Please sign in to comment.