sensu / sensu-flow

Github Action for Sensu flow resource management pattern.
MIT License
7 stars 6 forks source link

Namespace not automatically being created. #38

Open MichaelCharles opened 2 years ago

MichaelCharles commented 2 years ago

I tried to follow the instructions listed in the README, but when the action is run I get this output

=== Active Configuration
API URL:                  ***
Namespace:                default
Format:                   tabular
Timeout:                  15s
Username:                 ***
JWT Expiration Timestamp: 56652836
Directory test-namespace exists in namespaces/ but is not a defined namespace in sensu, skipping

It seems like I need to perhaps create the namespace manually beforehand? Although it doesn't seem that way according to the README.

edit: Currently using 0.5.0

MichaelCharles commented 2 years ago

I updated to use the most recent commit rather than 0.5.0, and I'm still getting the same result

Error: Unable to locate credentials. You can either configure credentials by running "sensuctl configure" or by using the --api-key command line option
Directory test-namespace exists in namespaces/ but is not a defined namespace in sensu, skipping

However, I'm also getting an error concerning using the --api-key command line option.

MichaelCharles commented 2 years ago

I reverted back to 0.5.0 and created the namespace manually, and after that it seems to have solved the problem. But if the namespaces are meant to be created automatically, then this seems to be broken.

jspaleta commented 2 years ago

I think I understand.

It doesn't automatically make namespaces that exist in 'namespaces_dir' It will create namespaces that exist in the 'namspaces_file' as a separate control.

Take a look at this CI test for an example: https://github.com/sensu/sensu-flow/blob/79d5bdc1855fc9aa4e9926d36c10f31aa9cbc73e/.github/workflows/ci.yml#L96

    - name: Sensuflow matching label with dashes
      uses: ./
      id: matching-label-with-dash
      with:
        sensu_api_url: http://sensu-backend:8080
        sensu_user: ${{ secrets.SENSU_USER }}
        sensu_password: ${{ secrets.SENSU_PASSWORD }} 
        namespaces_dir: .sensu.test/namespaces/
        namespaces_file: .sensu.test/cluster/namespaces.yaml
        matching_label: "sensu.io/workflow"
        matching_condition: "== 'sensu-flow'"

In this CI test the namespace resources included in .sensu.test/cluster/namespaces.yaml will get created before the contents of .sensu.test/namespaces/ are processed.

MichaelCharles commented 2 years ago

In my case, the namespace was defined in .sensu/cluster/namespaces.yaml, but I still got the error described.

I had just followed the steps listed on the sensu/sensu-flow readme, although perhaps I missed something? I'd like to try and reproduce the problem but I need to find time to do so.

jspaleta commented 2 years ago

If your able to find a reproducer I can add it as a CI test. But as of right now I'm not sure how to help. There is a CI test in github actions that covers this.

Best guess is your using a sensu user that does not have RBAC access to create namespace resources.