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

fix: inconsistent failures #866

Merged
merged 14 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export default [
{
ignores: ['docs/**/*', 'dist/*'],
},
{
files: ['test/**/*.ts', 'src/**/*.ts'],
{ // all ts files
files: ['**/*.ts'],
plugins: {
headers: headers,
tsdoc: tsdoc,
Expand Down Expand Up @@ -69,6 +69,13 @@ export default [
'space-before-function-paren': 'error',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/class-literal-property-style': 'off',
'no-invalid-this': [ 'error', { capIsConstructor : false } ],
}
},
{ // test ts files
files: ['test/**/*.ts'],
rules: {
'no-invalid-this': [ 'off', { } ],
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"check": "remark . --quiet --frail && eslint . --ignore-pattern 'docs/*' --ignore-pattern 'dist/*'; cd docs; jsdoc -c jsdoc.conf.json && tsc",
"format": "remark . --quiet --frail --output && eslint --fix . --ignore-pattern 'docs/*' --ignore-pattern 'dist/*' && tsc",
"test-setup": "./test/e2e/setup-e2e.sh",
"build": "tsc && node resources/post-build-script.js"
"build": "rm -Rf dist && tsc && node resources/post-build-script.js"
},
"keywords": [
"solo",
Expand Down
16 changes: 16 additions & 0 deletions resources/post-build-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,23 @@ function copyResources(srcDir, targetDir) {
fs.cpSync(srcDir, targetDir, {recursive: true})
}

async function recursiveChmod(dir, mode) {
const files = await fs.promises.readdir(dir);
for (const file of files) {
const filePath = `${dir}/${file}`;
const stats = await fs.promises.stat(filePath);
if (stats.isDirectory()) {
await recursiveChmod(filePath, mode);
} else {
await fs.promises.chmod(filePath, mode);
}
}
}

// Usage
console.time('Copy package.json')
copyPackageJson(srcPackageJsonFilePath, targetPackageJsonFilePath)
console.time('Copy resources')
copyResources(srcResourcesDir, targetResourcesDir)
console.time('Update permissions')
await recursiveChmod(distDir, 0o755);
12 changes: 12 additions & 0 deletions src/commands/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

/**
* Set flag from the flag option
* @param y instance of yargs

Check warning on line 25 in src/commands/flags.ts

View workflow job for this annotation

GitHub Actions / Code Style / Standard

tsdoc-param-tag-missing-hyphen: The @param block should be followed by a parameter name and then a hyphen
* @param commandFlags a set of command flags

Check warning on line 26 in src/commands/flags.ts

View workflow job for this annotation

GitHub Actions / Code Style / Standard

tsdoc-param-tag-missing-hyphen: The @param block should be followed by a parameter name and then a hyphen
*
*/
export function setCommandFlags (y: any, ...commandFlags: CommandFlag[]) {
Expand Down Expand Up @@ -802,6 +802,17 @@
}
}

export const stakeAmounts: CommandFlag = {
constName: 'stakeAmounts',
name: 'stake-amounts',
definition: {
describe:
'The amount to be staked in the same order you list the node aliases with multiple node staked values comma seperated',
defaultValue: '',
type: 'string'
}
}

export const allFlags: CommandFlag[] = [
accountId,
amount,
Expand Down Expand Up @@ -862,6 +873,7 @@
replicaCount,
setAlias,
settingTxt,
stakeAmounts,
tlsClusterIssuerType,
tlsPrivateKey,
tlsPublicKey,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ export class NetworkCommand extends BaseCommand {
title: `Check Node: ${chalk.yellow(nodeAlias)}`,
task: async () =>
await self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
'solo.hedera.com/type=network-node',
`solo.hedera.com/node-name=${nodeAlias}`
`solo.hedera.com/node-name=${nodeAlias}`,
'solo.hedera.com/type=network-node'
], 1, constants.PODS_RUNNING_MAX_ATTEMPTS, constants.PODS_RUNNING_DELAY)
})
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/node/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*
*/
/* eslint-disable no-invalid-this */
import { FREEZE_ADMIN_ACCOUNT } from '../../core/constants.js'
import { constants, Templates } from '../../core/index.js'
import { PrivateKey } from '@hashgraph/sdk'
Expand Down
5 changes: 3 additions & 2 deletions src/commands/node/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,16 @@ export const STOP_FLAGS = {
export const START_FLAGS = {
requiredFlags: [
flags.namespace,
flags.releaseTag
flags.releaseTag,
],
requiredFlagsWithDisabledPrompt: [
flags.app,
],
optionalFlags: [
flags.quiet,
flags.nodeAliasesUnparsed,
flags.debugNodeAlias
flags.debugNodeAlias,
flags.stakeAmounts,
]
}

Expand Down
20 changes: 10 additions & 10 deletions src/commands/node/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type { SoloLogger } from '../../core/logging.js'
import type { NodeCommand } from './index.js'
import type { NodeCommandTasks } from './tasks.js'
import { type Lease } from '../../core/lease/lease.js'
import { NodeSubcommandType } from '../../core/enumerations.js'

export class NodeCommandHandlers {
private readonly accountManager: AccountManager
Expand Down Expand Up @@ -108,14 +109,13 @@ export class NodeCommandHandlers {

deleteExecuteTaskList (argv: any) {
return [
this.tasks.checkAllNodesAreFrozen('existingNodeAliases'),
this.tasks.downloadNodeGeneratedFiles(),
this.tasks.prepareStagingDirectory('existingNodeAliases'),
this.tasks.copyNodeKeysToSecrets(),
this.tasks.refreshNodeList(),
this.tasks.copyNodeKeysToSecrets(),
this.tasks.checkAllNodesAreFrozen('existingNodeAliases'),
this.tasks.getNodeLogsAndConfigs(),
this.tasks.updateChartWithConfigMap('Update chart to use new configMap'),
this.tasks.updateChartWithConfigMap('Delete network node', NodeSubcommandType.DELETE),
this.tasks.killNodes(),
this.tasks.sleep('Give time for pods to come up after being killed', 20000),
this.tasks.checkNodePodsAreRunning(),
Expand All @@ -126,7 +126,7 @@ export class NodeCommandHandlers {
this.tasks.enablePortForwarding(),
this.tasks.checkAllNodesAreActive('allNodeAliases'),
this.tasks.checkAllNodeProxiesAreActive(),
this.tasks.triggerStakeWeightCalculate(),
this.tasks.triggerStakeWeightCalculate(NodeSubcommandType.DELETE),
this.tasks.finalize()
]
}
Expand Down Expand Up @@ -159,12 +159,12 @@ export class NodeCommandHandlers {

addExecuteTasks (argv: any) {
return [
this.tasks.checkAllNodesAreFrozen('existingNodeAliases'),
this.tasks.downloadNodeGeneratedFiles(),
this.tasks.prepareStagingDirectory('allNodeAliases'),
this.tasks.copyNodeKeysToSecrets(),
this.tasks.checkAllNodesAreFrozen('existingNodeAliases'),
this.tasks.getNodeLogsAndConfigs(),
this.tasks.updateChartWithConfigMap('Deploy new network node'),
this.tasks.updateChartWithConfigMap('Deploy new network node', NodeSubcommandType.ADD),
this.tasks.killNodes(),
this.tasks.checkNodePodsAreRunning(),
this.tasks.populateServiceMap(),
Expand All @@ -177,7 +177,7 @@ export class NodeCommandHandlers {
this.tasks.checkAllNodesAreActive('allNodeAliases'),
this.tasks.checkAllNodeProxiesAreActive(),
this.tasks.stakeNewNode(),
this.tasks.triggerStakeWeightCalculate(),
this.tasks.triggerStakeWeightCalculate(NodeSubcommandType.ADD),
this.tasks.finalize()
]
}
Expand All @@ -202,13 +202,13 @@ export class NodeCommandHandlers {

updateExecuteTasks (argv) {
return [
this.tasks.checkAllNodesAreFrozen('existingNodeAliases'),
this.tasks.downloadNodeGeneratedFiles(),
this.tasks.prepareStagingDirectory('allNodeAliases'),
this.tasks.copyNodeKeysToSecrets(),
this.tasks.checkAllNodesAreFrozen('existingNodeAliases'),
this.tasks.getNodeLogsAndConfigs(),
this.tasks.updateChartWithConfigMap(
'Update chart to use new configMap due to account number change',
'Update chart to use new configMap due to account number change', NodeSubcommandType.UPDATE,
(ctx: any) => !ctx.config.newAccountNumber && !ctx.config.debugNodeAlias
),
this.tasks.killNodesAndUpdateConfigMap(),
Expand All @@ -219,7 +219,7 @@ export class NodeCommandHandlers {
this.tasks.enablePortForwarding(),
this.tasks.checkAllNodesAreActive('allNodeAliases'),
this.tasks.checkAllNodeProxiesAreActive(),
this.tasks.triggerStakeWeightCalculate(),
this.tasks.triggerStakeWeightCalculate(NodeSubcommandType.UPDATE),
this.tasks.finalize()
]
}
Expand Down
Loading
Loading