Skip to content

Stanctl-fleet: deploy and config-update#102

Merged
disha-148 merged 4 commits into
instana:fi-featuresfrom
disha-148:INSTA-101343-stanctl-fleet-deploy
Jul 23, 2026
Merged

Stanctl-fleet: deploy and config-update#102
disha-148 merged 4 commits into
instana:fi-featuresfrom
disha-148:INSTA-101343-stanctl-fleet-deploy

Conversation

@disha-148

Copy link
Copy Markdown
Collaborator

Stanctl-fleet: deploy and config-update command

@disha-148
disha-148 requested a review from morningspace July 10, 2026 14:40
Comment thread tools/fleet/src/handlers/restart.ts Outdated
...(tags && { tags }),
...(groups && { groups }),
...(args && { args })
tags

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here, the code always includes tags in the request body, even when parseTags returns undefined, while deploy.ts and update.ts both handle this consistently using spread:

...(tags && { tags }),

But restart.ts does not. Sending tags: undefined may cause the API to behave differently than omitting the field entirely. Fix to match the other two handlers.

Comment thread tools/fleet/src/index.ts Outdated
handleRestart,
handleDeploy,
handleUpdate
}); No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The diff shows \ No newline at end of file. Minor but trips linting.

Comment thread tools/fleet/src/utils.ts
export function createAxiosInstance() {
return axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here, we disabled TLS certificate verification. At minimum, worth a comment explaining why it's intentional rather than an oversight.

Comment thread tools/fleet/src/handlers/deploy.ts Outdated
@@ -0,0 +1,87 @@
import logger from '../logger';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

deploy.ts and update.ts are structurally identical apart from the action string and description strings, which is a strong candidate for a shared helper.

Both handlers have exactly the same structure: resolve server/token, validate, parse tags, build request, POST, log result. The only differences are:

  • action: 'agent.component.deploy' vs 'agent.configuration.update'
  • The interface name
  • The description strings in log output

Consider a shared sendAgentRequest(action, argv) utility that the handlers delegate to, keeping each handler file as a thin wrapper that just supplies the action string.

Comment thread tools/fleet/src/cli.ts Outdated
},
handlers.handleRestart
}, handlers.handleRestart)
.command(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you please double check if there's mixed indentation here? It appears the restart command block uses 4-space indentation, while the new deploy and config-update blocks use tabs. If it does, please normalize to match the rest of the file (spaces).

Comment thread tools/fleet/src/cli.ts Outdated
${execName} config-update --type agentType --tag key1=value1 --configurationId=configID --debug
`;


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There are two consecutive blank lines before the export function declaration. Minor style inconsistency.

Comment thread tools/fleet/src/cli.ts Outdated
})
.option('token', {
alias: 't',
describe: 'API token for authenticating agent restart requests',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks like copy-paste from restart. Should be "authenticating agent fleet management requests" or something similar. The same applies to both deploy and config-update.

Comment thread tools/fleet/src/utils.ts Outdated
* Parse an array of key=value tag strings into a Record.
* Returns undefined if the input array is empty.
*/
export function parseTags(tagsInput: string[]): Record<string, string> | undefined {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

parseTags returns undefined for an empty array, but every caller immediately checks length === 0 before calling it. So, parseTags can never actually receive an empty array in practice. Either remove the early-return guard from parseTags and let the empty-array path be handled by callers, or remove the caller-side pre-checks and let parseTags return undefined for empty input. Right now both layers check for empty, which is redundant.

@morningspace

Copy link
Copy Markdown
Collaborator

Please also check why DCO is failing.

Signed-off-by: dishabhagat <disha.14624@gmail.com>
Signed-off-by: dishabhagat <disha.14624@gmail.com>
Signed-off-by: dishabhagat <disha.14624@gmail.com>
@disha-148
disha-148 force-pushed the INSTA-101343-stanctl-fleet-deploy branch from 21139e8 to 978e6d6 Compare July 22, 2026 20:31
@disha-148

Copy link
Copy Markdown
Collaborator Author

Hi @morningspace, I have refactored the code. I extracted all shared logic into a single sendAgentRequest(action, argv, configurationId?) function in utils.ts, and each handler is now a thin wrapper around it.

Comment thread tools/fleet/src/utils.ts
const request: Record<string, any> = {
action,
type,
tags,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

IIRC, previously deploy.ts and update.ts used ...(tags && { tags }) to conditionally include the field. Now sendAgentRequest always includes tags, even if tags is {}. Is this something intentional?

Also, for parseTags test in utils.test.ts, there's no test for what does happen when an empty array is passed which is now that parseTags returns {} (an empty object).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Previously I had misunderstood the requirements. I thought only --configuration-id was required for deploy and config-update. I corrected that in my second commit: both --tag and --configuration-id are now always required for those commands.

Signed-off-by: dishabhagat <disha.14624@gmail.com>
@disha-148
disha-148 merged commit 5161e9d into instana:fi-features Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants