I created a sensor which should alert us on 1 of 2...
# ask-community
j
I created a sensor which should alert us on 1 of 2 slack channels (depending on whether we’re on prd or dev environment). this is where I defined the sensor
Copy code
slack_failure_sensor = make_slack_on_run_failure_sensor(
    channel=f"#dagster-notifications-{os.getenv('RUNTIME_ENVIRONMENT')}",
    slack_token=os.getenv("DAGSTER_SLACK_TOKEN"),
    blocks_fn=get_error_blocks,
)
I checked that the daemon has those 2 environment variables set, here is the slack channel. I’m omitting the slack token of course, but it is set as well.
Copy code
>>> import os
>>> print(f"#dagster-notifications-{os.getenv('RUNTIME_ENVIRONMENT')}")
#dagster-notifications-prd
When a pipeline fails I’m getting this error:
Copy code
slack_sdk.errors.SlackApiError: The request to the Slack API failed. (url: <https://www.slack.com/api/chat.postMessage>)
The server responded with: {'ok': False, 'error': 'channel_not_found'}
any idea where I’m going wrong here? our slack has the channel `dagster-notifications-prd`I should also say that it works when I run it locally (run dagster & dagit & daemon on my laptop & make a job fail -> it posts on our slack)
I ssh’d into the daemon and managed to send a slack message in a python shell with
Copy code
from slack_sdk.web.client import WebClient
slack_client = WebClient(token=os.getenv("DAGSTER_SLACK_TOKEN"))
slack_client.chat_postMessage(channel=f"#dagster-notifications-{os.getenv('RUNTIME_ENVIRONMENT')}", blocks=[], text="asd")
but before I was able to that I had to pip install
dagster-slack
on the daemon. I wasn’t able to import
Copy code
from slack_sdk.web.client import WebClient
I think that means that my daemon isn’t running the correct image. I didn’t set it explicitly so I’m guessing it’s just running the image
"<http://docker.io/dagster/dagster-celery-k8s|docker.io/dagster/dagster-celery-k8s>"
. is there an image that has all dagster dependencies (including
dagster-slack
) installed?
I couldn’t find one on docker hub. is it intentional that
dagster-slack
isn’t part of the docker image or should that be added?
d
Hi, is this in kubernetes or some other environment where you are building your code in an image? The daemon doesn't run your code directly - you would want to add dagster-slack to the image that you build your code in
(sensor code runs in your user code deployment)
j
the image is build in Google Cloud Build whenever we push to master. hmm, but then I don’t know what’s wrong.. because the image that’s running in
dagster-user-deployments
has
dagster-slack
installed
d
the error you posted looks like something on the slack API side, rather than dagster-slack not being installed
j
oh I see, I think
dagster-user-deployments
might actually be missing my
RUNTIME_ENVIRONMENT
environment variable. sorry thought that had to be set in the daemon
I’ll try if this fixes it! thanks
condagster 1