Skip to content

Commit 3397ed0

Browse files
committed
log host iptables on failure
1 parent 5c4b8cf commit 3397ed0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

e2e/validation.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/Azure/agentbaker/e2e/toolkit"
1313
"github.com/Azure/agentbaker/pkg/agent"
1414
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
15+
"github.com/stretchr/testify/assert"
1516
"github.com/stretchr/testify/require"
1617
corev1 "k8s.io/api/core/v1"
1718
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -97,10 +98,18 @@ func ValidateCommonLinux(ctx context.Context, s *Scenario) {
9798
_ = execScriptOnVMForScenarioValidateExitCode(ctx, s, "sudo curl http://168.63.129.16:32526/vmSettings", 0, "curl to wireserver failed")
9899

99100
execResult = execOnVMForScenarioOnUnprivilegedPod(ctx, s, "curl https://168.63.129.16/machine/?comp=goalstate -H 'x-ms-version: 2015-04-05' -s --connect-timeout 4")
100-
require.Equal(s.T, "28", execResult.exitCode, "curl to wireserver should fail")
101+
if !assert.Equal(s.T, "28", execResult.exitCode, "curl to wireserver expected to fail, but it didn't") {
102+
// Log debug information. This validator seems to be flaky, hard to catch
103+
s.T.Logf("host IPTABLES: %s", execScriptOnVMForScenario(ctx, s, "sudo iptables -t filter -L FORWARD -v -n --line-numbers").String())
104+
s.T.FailNow()
105+
}
101106

102107
execResult = execOnVMForScenarioOnUnprivilegedPod(ctx, s, "curl http://168.63.129.16:32526/vmSettings --connect-timeout 4")
103-
require.Equal(s.T, "28", execResult.exitCode, "curl to wireserver port 32526 shouldn't succeed")
108+
if !assert.Equal(s.T, "28", execResult.exitCode, "curl to wireserver port 32526 expected to fail, but it didn't") {
109+
// Log debug information. This validator seems to be flaky, hard to catch
110+
s.T.Logf("host IPTABLES: %s", execScriptOnVMForScenario(ctx, s, "sudo iptables -t filter -L FORWARD -v -n --line-numbers").String())
111+
s.T.FailNow()
112+
}
104113

105114
// base NBC templates define a mock service principal profile that we can still use to test
106115
// the correct bootstrapping logic: https://github.com/Azure/AgentBaker/blob/master/e2e/node_config.go#L438-L441

0 commit comments

Comments
 (0)