-
Notifications
You must be signed in to change notification settings - Fork 12
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(upstreams): unable remove some fields' value [KM-970] #1978
base: main
Are you sure you want to change the base?
Conversation
f393a53
to
35e50a1
Compare
b61d884
to
476efd5
Compare
packages/entities/entities-upstreams-targets/src/components/UpstreamsForm.vue
Outdated
Show resolved
Hide resolved
2e1cadc
to
d27daac
Compare
packages/entities/entities-upstreams-targets/src/components/UpstreamsForm.vue
Outdated
Show resolved
Hide resolved
packages/entities/entities-upstreams-targets/src/components/UpstreamsForm.vue
Outdated
Show resolved
Hide resolved
packages/entities/entities-upstreams-targets/src/components/UpstreamsForm.vue
Show resolved
Hide resolved
packages/entities/entities-upstreams-targets/src/components/UpstreamsForm.vue
Outdated
Show resolved
Hide resolved
packages/entities/entities-upstreams-targets/src/components/UpstreamsForm.vue
Outdated
Show resolved
Hide resolved
packages/entities/entities-upstreams-targets/src/components/UpstreamsForm.vue
Outdated
Show resolved
Hide resolved
packages/entities/entities-upstreams-targets/src/components/UpstreamsForm.vue
Outdated
Show resolved
Hide resolved
Preview components from this PR in consuming applicationIn consuming application project install preview versions of shared packages generated by this PR:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates
if (state.fields.healthchecksThreshold) { | ||
result.healthchecks.threshold = Number(state.fields.healthchecksThreshold) | ||
} | ||
const getBasePayload = computed((): UpstreamFormPayload => ( { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const getBasePayload = computed((): UpstreamFormPayload => ( { | |
const basePayload = computed((): UpstreamFormPayload => ({ |
}) | ||
const getPayload = computed((): UpstreamFormPayload => { | ||
const basePayload = getBasePayload.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const basePayload = getBasePayload.value |
const payload: UpstreamFormPayload = { | ||
...basePayload, | ||
healthchecks: { | ||
...basePayload.healthchecks, | ||
active: active || undefined, | ||
passive: passive || undefined, | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const payload: UpstreamFormPayload = { | |
...basePayload, | |
healthchecks: { | |
...basePayload.healthchecks, | |
active: active || undefined, | |
passive: passive || undefined, | |
}, | |
} | |
const payload: UpstreamFormPayload = { | |
...basePayload.value, | |
healthchecks: { | |
...basePayload.value.healthchecks, | |
active: active || undefined, | |
passive: passive || undefined, | |
}, | |
} |
packages/entities/entities-upstreams-targets/src/components/UpstreamsForm.vue
Show resolved
Hide resolved
healthy: { | ||
interval: response?.healthchecks.active?.healthy?.interval?.toString() || '0', | ||
successes: response?.healthchecks.active?.healthy?.successes?.toString() || '5', | ||
httpStatuses: response?.healthchecks.active?.healthy?.http_statuses | ||
? numberToStringArray(response.healthchecks.active.healthy.http_statuses) | ||
: ActiveHealthyHttpStatuses, | ||
}, | ||
unhealthy: { | ||
interval: response?.healthchecks.active?.unhealthy?.interval?.toString() || '0', | ||
httpFailures: response?.healthchecks.active?.unhealthy?.http_failures?.toString() || '5', | ||
tcpFailures: response?.healthchecks.active?.unhealthy?.tcp_failures?.toString() || '5', | ||
httpStatuses: response?.healthchecks.active?.unhealthy?.http_statuses | ||
? numberToStringArray(response.healthchecks.active.unhealthy.http_statuses) | ||
: ActiveUnhealthyHttpStatuses, | ||
timeouts: response?.healthchecks.active?.unhealthy?.timeouts?.toString() || '0', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we populate the empty fields with the defaults in the schema?
healthy = {
interval = 0, -- 0 = probing disabled by default
http_statuses = { 200, 302 },
successes = 0, -- 0 = disabled by default
},
unhealthy = {
interval = 0, -- 0 = probing disabled by default
http_statuses = { 429, 404,
500, 501, 502, 503, 504, 505 },
tcp_failures = 0, -- 0 = disabled by default
timeouts = 0, -- 0 = disabled by default
http_failures = 0, -- 0 = disabled by default
}
healthy: { | ||
successes: response?.healthchecks.passive?.healthy?.successes?.toString() || '5', | ||
httpStatuses: response?.healthchecks.passive?.healthy?.http_statuses | ||
? numberToStringArray(response.healthchecks.passive.healthy.http_statuses) | ||
: PassiveHealthyHttpStatuses, | ||
}, | ||
unhealthy: { | ||
timeouts: response?.healthchecks.passive?.unhealthy?.timeouts?.toString() || '0', | ||
httpFailures: response?.healthchecks.passive?.unhealthy?.http_failures?.toString() || '5', | ||
tcpFailures: response?.healthchecks.passive?.unhealthy?.tcp_failures?.toString() || '5', | ||
httpStatuses: response?.healthchecks.passive?.unhealthy?.http_statuses | ||
? numberToStringArray(response.healthchecks.passive.unhealthy.http_statuses) | ||
: PassiveUnhealthyHttpStatuses, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
healthy = {
http_statuses = { 200, 201, 202, 203, 204, 205, 206, 207, 208, 226,
300, 301, 302, 303, 304, 305, 306, 307, 308 },
successes = 0,
},
unhealthy = {
http_statuses = { 429, 500, 503 },
tcp_failures = 0, -- 0 = circuit-breaker disabled by default
timeouts = 0, -- 0 = circuit-breaker disabled by default
http_failures = 0, -- 0 = circuit-breaker disabled by default
}
type: state.fields.activeHealthCheck.type, | ||
healthy: { | ||
interval: Number(state.fields.activeHealthCheck.healthy.interval || '0'), | ||
successes: Number(state.fields.activeHealthCheck.healthy.successes || '5'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use 0
here?
unhealthy: { | ||
interval: Number(state.fields.activeHealthCheck.unhealthy.interval || '0'), | ||
timeouts: Number(state.fields.activeHealthCheck.unhealthy.timeouts || '0'), | ||
tcp_failures: Number(state.fields.activeHealthCheck.unhealthy.tcpFailures || '5'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we default to 0
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch.
interval: response?.healthchecks.active?.healthy?.interval?.toString() || '0', | ||
successes: response?.healthchecks.active?.healthy?.successes?.toString() || '5', | ||
httpStatuses: response?.healthchecks.active?.healthy?.http_statuses | ||
? numberToStringArray(response.healthchecks.active.healthy.http_statuses) | ||
: ActiveHealthyHttpStatuses, | ||
unhealthyInterval: response?.healthchecks.active?.unhealthy?.interval?.toString() || '0', | ||
httpFailures: response?.healthchecks.active?.unhealthy?.http_failures?.toString() || '5', | ||
tcpFailures: response?.healthchecks.active?.unhealthy?.tcp_failures?.toString() || '5', | ||
unhealthyHttpStatuses: response?.healthchecks.active?.unhealthy?.http_statuses | ||
? numberToStringArray(response.healthchecks.active.unhealthy.http_statuses) | ||
: ActiveUnhealthyHttpStatuses, | ||
unhealthyTimeouts: response?.healthchecks.active?.unhealthy?.timeouts?.toString() || '0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why here didn't populate the default value from the schema.
Maybe there is something wrong. Let me check it again.
@sumimakito
state.fields.activeHealthCheck.interval = val ? '5' : '0' | ||
state.fields.activeHealthCheck.successes = val ? '5' : '0' | ||
state.fields.activeHealthCheck.httpFailures = val ? '5' : '0' | ||
state.fields.activeHealthCheck.unhealthyInterval = val ? '5' : '0' | ||
state.fields.activeHealthCheck.tcpFailures = val ? '5' : '0' | ||
state.fields.activeHealthCheck.healthy.interval = val ? '5' : '0' | ||
state.fields.activeHealthCheck.healthy.successes = val ? '5' : '0' | ||
state.fields.activeHealthCheck.healthy.httpStatuses = val ? ActiveHealthyHttpStatuses : [] | ||
state.fields.activeHealthCheck.unhealthy.httpStatuses = val ? ActiveUnhealthyHttpStatuses : [] | ||
state.fields.activeHealthCheck.unhealthy.httpFailures = val ? '5' : '0' | ||
state.fields.activeHealthCheck.unhealthy.interval = val ? '5' : '0' | ||
state.fields.activeHealthCheck.unhealthy.tcpFailures = val ? '5' : '0' | ||
state.fields.activeHealthCheck.unhealthy.timeouts = val ? '5' : '0' | ||
state.fields.activeHealthCheck.timeout = val ? '1' : '0' | ||
state.fields.activeHealthCheck.concurrency = val ? '10' : '0' | ||
state.fields.activeHealthCheck.httpPath = val ? '/' : '' | ||
state.fields.activeHealthCheck.httpsSni = '' | ||
state.fields.activeHealthCheck.type = 'http' | ||
} | ||
const resetOnPassiveSwitch = (val: boolean): void => { | ||
state.fields.passiveHealthCheck.timeouts = val ? '5' : '0' | ||
state.fields.passiveHealthCheck.successes = val ? '80' : '0' | ||
state.fields.passiveHealthCheck.tcpFailures = val ? '5' : '0' | ||
state.fields.passiveHealthCheck.httpFailures = val ? '5' : '0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@2eha0 Why give these default values for these fields when enabling active or passive health?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking into the history of the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be enabled the active health requires the non-zero number.
But Why give these numbers? Where can I find some docs to ref.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the default values have been there since two years ago when it was first added. I also have no idea why we chose them but let's keep them there as the current values serve as a good simple example instead of the all-zero ones.
.
Summary
KM-970
FTI-6493