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

Warn, instead of exiting on error #26

Merged
merged 1 commit into from
Aug 23, 2022
Merged

Conversation

alexellis
Copy link
Member

Signed-off-by: Alex Ellis (OpenFaaS Ltd) [email protected]

Description

Warn, instead of exiting on error

Motivation and Context

Fixes: zeerorg/cron-connector#25

How Has This Been Tested?

Testing pending, it should stop the code from hanging when the list functions endpoint returns an error though.

main.go Outdated Show resolved Hide resolved
@nitishkumar71
Copy link
Member

Did a quick testing for the above MR code. It looks working fine

  1. Install faasd
git clone https://github.com/openfaas/faasd --depth=1
cd faasd
./hack/install.sh
  1. Login to faasd
sudo cat /var/lib/faasd/secrets/basic-auth-password | faas-cli login -s
faas-cli ls
  1. Export Gateway URL and secret path for cron-connector
export gateway_url=http://127.0.0.1:8081
export basic_auth=true
export secret_mount_path=/var/lib/faasd/secrets
  1. Add current user to root
sudo usermod -a -G groupname username
  1. Build Cron Connector and start
go build --ldflags "-s -w  -X github.com/openfaas/cron-connector/version.GitCommit=${GIT_COMMIT} -X github.com/openfaas/cron-connector/version.Version=${VERSION}" -a -installsuffix cgo -o cron-connector .

sudo -E bash -c './cron-connector'
  1. deploy sleep and nodeinfo function from store
faas-cli store deploy sleep --annotation topic=cron-function --annotation schedule="*/1 * * * *"
faas-cli store deploy nodeinfo --annotation schedule="*/5 * * * *" --annotation topic=cron-function
  1. Remove nodeinfo function after first run then sleep function. The first time remove command causes failure, a quick second one removes it.
faas-cli remove nodeinfo
faas-cli remove sleep
  1. Logs for cron-connector
2022/08/17 22:27:56 Version:    Commit: dev
2022/08/17 22:27:56 Gateway URL: http://127.0.0.1:8080
2022/08/17 22:27:56 Async Invocation: false
2022/08/17 22:27:56 Rebuild interval: 10s       Rebuild timeout: 5s
2022/08/17 22:31:46 Added: nodeinfo.openfaas-fn [*/5 * * * *]
2022/08/17 22:32:26 Added: sleep.openfaas-fn [*/1 * * * *]
2022/08/17 22:33:00 Invoking: sleep.openfaas-fn [*/1 * * * *]
2022/08/17 22:33:02 Response: sleep [200] (2.06s)
2022/08/17 22:34:00 Invoking: sleep.openfaas-fn [*/1 * * * *]
2022/08/17 22:34:02 Response: sleep [200] (2.04s)
2022/08/17 22:35:00 Invoking: nodeinfo.openfaas-fn [*/5 * * * *]
2022/08/17 22:35:00 Invoking: sleep.openfaas-fn [*/1 * * * *]
2022/08/17 22:35:00 Response: nodeinfo [200] (107ms)
2022/08/17 22:35:02 Response: sleep [200] (2.09s)
2022/08/17 22:35:26 Removed: nodeinfo.openfaas-fn [*/5 * * * *]
2022/08/17 22:36:00 Invoking: sleep.openfaas-fn [*/1 * * * *]
2022/08/17 22:36:02 Response: sleep [200] (2.02s)
2022/08/17 22:36:36 error listing functions in openfaas-fn: server returned unexpected status code: 500 - Metrics hander: unexpected status code retrieving functions from backend
2022/08/17 22:36:46 error listing functions in openfaas-fn: server returned unexpected status code: 500 - Metrics hander: unexpected status code retrieving functions from backend
2022/08/17 22:36:56 error listing functions in openfaas-fn: server returned unexpected status code: 500 - Metrics hander: unexpected status code retrieving functions from backend
2022/08/17 22:37:00 Invoking: sleep.openfaas-fn [*/1 * * * *]
2022/08/17 22:37:02 Response: sleep [200] (2.28s)
2022/08/17 22:37:06 error listing functions in openfaas-fn: server returned unexpected status code: 500 - Metrics hander: unexpected status code retrieving functions from backend
2022/08/17 22:37:16 error listing functions in openfaas-fn: server returned unexpected status code: 500 - Metrics hander: unexpected status code retrieving functions from backend
2022/08/17 22:37:26 error listing functions in openfaas-fn: server returned unexpected status code: 500 - Metrics hander: unexpected status code retrieving functions from backend
2022/08/17 22:38:00 Invoking: sleep.openfaas-fn [*/1 * * * *]
2022/08/17 22:38:02 Response: sleep [200] (2.30s)
2022/08/17 22:38:56 Removed: sleep.openfaas-fn [*/1 * * * *]

@alexellis
Copy link
Member Author

Thank you

Fixes: zeerorg/cron-connector#25

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
@alexellis alexellis force-pushed the openfaasltd/warn-dont-exit branch from 6fa8d3e to b95598f Compare August 23, 2022 09:29
@alexellis alexellis merged commit 53b0fc7 into master Aug 23, 2022
@alexellis alexellis deleted the openfaasltd/warn-dont-exit branch August 23, 2022 09:29
@alexellis
Copy link
Member Author

I've removed the sleep statements and am merging the fix for a release.

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.

cron-connector container stops working after removing a function (faasd)
2 participants